about summary refs log tree commit diff
path: root/stdio-common/vfscanf.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/vfscanf.c')
-rw-r--r--stdio-common/vfscanf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 7a3440c99a..cb6d39629e 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -524,7 +524,10 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
 		  if (First)						      \
 		    input_error ();					      \
 		  else							      \
-		    break;						      \
+		    {							      \
+		      --read_in;					      \
+		      break;						      \
+		    }							      \
 		val = c;						      \
 		if (val >= 0x80)					      \
 		  {							      \
@@ -667,6 +670,9 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
 	      STRING_ADD_CHAR (str, c, char);
 	    } while ((width <= 0 || --width > 0) && inchar () != EOF);
 
+	  if (c == EOF)
+	    --read_in;
+
 	  if (!(flags & SUPPRESS))
 	    {
 	      *str = '\0';