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.
This commit is contained in:
parent
e932c41587
commit
c5ee1fdbf5
|
|
@ -240,6 +240,14 @@ static int scan_format(vpiHandle callh, struct byte_source*src, vpiHandle argv)
|
||||||
vpi_get_value(item, &val);
|
vpi_get_value(item, &val);
|
||||||
fmtp = fmt = strdup(val.value.str);
|
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) {
|
while ( fmtp && *fmtp != 0 && !match_fail) {
|
||||||
|
|
||||||
if (isspace(*fmtp)) {
|
if (isspace(*fmtp)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue