]> pd.if.org Git - pdclib/commitdiff
scanf() returns -1 on early input error.
authorsolar <unknown>
Mon, 19 Jul 2010 05:19:04 +0000 (05:19 +0000)
committersolar <unknown>
Mon, 19 Jul 2010 05:19:04 +0000 (05:19 +0000)
functions/stdio/vfscanf.c

index 8f121e95e4a73cac03d000cf6a96132e2163e5ab..e1c8b4b40efd8fd28040cbf47600647ab0e9e4bb 100644 (file)
@@ -53,10 +53,14 @@ int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict forma
                 if ( ( ( c = getc( stream ) ) != *format ) || feof( stream ) ) /* TODO: Check EOF status directly */
                 {
                     /* Matching error */
-                    if ( ! feof( stream ) ) /* TODO: Check EOF status directly */
+                    if ( ! feof( stream ) && ! ferror( stream ) ) /* TODO: Check EOF status directly */
                     {
                         ungetc( c, stream );
                     }
+                    else if ( status.n == 0 )
+                    {
+                        return EOF;
+                    }
                     return status.n;
                 }
                 else