mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
@@ -1832,8 +1832,8 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
return got;
|
||||
|
||||
done:
|
||||
// Scan stopped early, return parsed or EOF
|
||||
if (_vl_vsss_eof(fp, floc)) return -1;
|
||||
// Scan stopped early; EOF only if input ended before the first conversion
|
||||
if (got == 0 && _vl_vsss_eof(fp, floc)) return -1;
|
||||
return got;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,20 @@ module t;
|
||||
`checks(token, "\0\0\0Hello");
|
||||
`checkh(idx, 1);
|
||||
|
||||
// Input ends after some conversions: return the number assigned, not EOF
|
||||
code = $sscanf("Hi 5", "%s %d %d", token, idx, val);
|
||||
`checkh(code, 2);
|
||||
`checks(token, "\0\0\0\0\0\0Hi");
|
||||
`checkh(idx, 5);
|
||||
|
||||
// Matching failure before the first conversion: 0
|
||||
code = $sscanf("Hi", "%d", idx);
|
||||
`checkh(code, 0);
|
||||
|
||||
// Input ends before the first conversion: EOF
|
||||
code = $sscanf("", "%d", idx);
|
||||
`checkh(code, -1);
|
||||
|
||||
$finish;
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user