From 42d46c816926c250e287fe8500132ec3bab0c749 Mon Sep 17 00:00:00 2001 From: solar Date: Mon, 19 Jul 2010 05:19:04 +0000 Subject: [PATCH] scanf() returns -1 on early input error. git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@443 546481bc-9713-0410-bf18-d3337bbf4a3e --- functions/stdio/vfscanf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/stdio/vfscanf.c b/functions/stdio/vfscanf.c index 8f121e9..e1c8b4b 100644 --- a/functions/stdio/vfscanf.c +++ b/functions/stdio/vfscanf.c @@ -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 -- 2.30.2