The scanf functions must return EOF if source starts at the end of input.
The $fscanf() and $sscanf() functions are defined to return EOF when
the end of input is reached before any matches or match failures have
occurred.
(cherry picked from commit c5ee1fdbf5)
This commit is contained in:
parent
d0a12f5b14
commit
7acafd128f
|
|
@ -240,6 +240,14 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
|
|||
vpi_get_value(item, &val);
|
||||
fmtp = fmt = strdup(val.value.str);
|
||||
|
||||
/* See if we are at EOF before we even start. */
|
||||
ch = byte_getc(src);
|
||||
if (ch == EOF) {
|
||||
rc = EOF;
|
||||
match_fail = 1;
|
||||
}
|
||||
byte_ungetc(src, ch);
|
||||
|
||||
while ( fmtp && *fmtp != 0 && !match_fail) {
|
||||
|
||||
if (isspace(*fmtp)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue