X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Fvfscanf.c;h=8f121e95e4a73cac03d000cf6a96132e2163e5ab;hp=99a752ff2db0258fc8ccc67d47faae2162f3e5ac;hb=3fe0b3636381ca114b4b664af4062708d5cddf26;hpb=7e1ea4998255982bbf93539e941991bcf40d2813 diff --git a/functions/stdio/vfscanf.c b/functions/stdio/vfscanf.c index 99a752f..8f121e9 100644 --- a/functions/stdio/vfscanf.c +++ b/functions/stdio/vfscanf.c @@ -42,7 +42,7 @@ int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict forma { ++status.i; } - if ( c != EOF ) + if ( ! feof( stream ) ) /* TODO: Check EOF status directly */ { ungetc( c, stream ); } @@ -50,10 +50,13 @@ int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict forma else { /* Non-whitespace char in format string: Match verbatim */ - if ( ( c = getc( stream ) ) != *format ) + if ( ( ( c = getc( stream ) ) != *format ) || feof( stream ) ) /* TODO: Check EOF status directly */ { /* Matching error */ - ungetc( c, stream ); + if ( ! feof( stream ) ) /* TODO: Check EOF status directly */ + { + ungetc( c, stream ); + } return status.n; } else