From 3fe0b3636381ca114b4b664af4062708d5cddf26 Mon Sep 17 00:00:00 2001 From: solar Date: Fri, 16 Jul 2010 06:13:35 +0000 Subject: [PATCH] Fixed EOF handling. --- functions/stdio/vfscanf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 -- 2.40.0