about summary refs log tree commit diff
path: root/stdio-common/vfscanf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-02-18 19:03:30 +0000
committerUlrich Drepper <drepper@redhat.com>2007-02-18 19:03:30 +0000
commitac2ca0229ab39381e9e92e07f929703981f77a90 (patch)
tree405404c5cfe6d729b4a253cf41a9adb76245e51c /stdio-common/vfscanf.c
parentda50f0010773cd88b34ad8b08f88d5ffabe061df (diff)
downloadglibc-ac2ca0229ab39381e9e92e07f929703981f77a90.tar.gz
glibc-ac2ca0229ab39381e9e92e07f929703981f77a90.tar.xz
glibc-ac2ca0229ab39381e9e92e07f929703981f77a90.zip
* stdio-common/vfscanf.c: Fix problems in width accounting.
	* stdio-common/tst-sscanf.c (double_tests): New tests.
	(main): Hook them up.
Diffstat (limited to 'stdio-common/vfscanf.c')
-rw-r--r--stdio-common/vfscanf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 1149686d75..90e7e36a5f 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -1585,6 +1585,8 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	case L_('a'):
 	case L_('A'):
 	  c = inchar ();
+	  if (width > 0)
+	    --width;
 	  if (__builtin_expect (c == EOF, 0))
 	    input_error ();
 
@@ -1712,7 +1714,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		}
 	    }
 
-	  do
+	  while (1)
 	    {
 	      if (ISDIGIT (c))
 		ADDW (c);
@@ -1818,10 +1820,13 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    }
 #endif
 		}
+
+	      if (width == 0 || inchar () == EOF)
+		break;
+
 	      if (width > 0)
 		--width;
 	    }
-	  while (width != 0 && inchar () != EOF);
 
 	  /* Have we read any character?  If we try to read a number
 	     in hexadecimal notation and we have read only the `0x'