about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-07-18 04:10:03 +0000
committerRoland McGrath <roland@gnu.org>2005-07-18 04:10:03 +0000
commitf8d784018dfe7c1a1e97bf255c3d7b0c357cd7e2 (patch)
tree90ab3ecc6a72e596f3d6142bcc32a29393f3543b
parent47919fd5b55f0b2af0ed091838f08c786e6dbeb2 (diff)
downloadglibc-f8d784018dfe7c1a1e97bf255c3d7b0c357cd7e2.tar.gz
glibc-f8d784018dfe7c1a1e97bf255c3d7b0c357cd7e2.tar.xz
glibc-f8d784018dfe7c1a1e97bf255c3d7b0c357cd7e2.zip
2005-04-26 Ulrich Drepper <drepper@redhat.com>
	[BZ #1110]
	* stdio-common/vfscanf.c: Correctly account for characters of
	decimal points right after +-.
2005-04-24  Ulrich Drepper  <drepper@redhat.com>

	[BZ #1110]
	* stdio-common/vfscanf.c: Fix parsing of decimal point after +-.
	Patch by Hamed Malek <hamed@bamdad.org>.
-rw-r--r--stdio-common/vfscanf.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index c641d2d371..b95c40b84b 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -1602,6 +1602,8 @@ _IO_vfscanf (s, format, argptr, errp)
 	  if (c == EOF)
 	    input_error ();
 
+	  got_dot = got_e = 0;
+
 	  /* Check for a sign.  */
 	  if (c == L_('-') || c == L_('+'))
 	    {
@@ -1629,14 +1631,13 @@ _IO_vfscanf (s, format, argptr, errp)
 		  const char *cmpp = decimal;
 		  int avail = width > 0 ? width : INT_MAX;
 
-		  while ((unsigned char) *cmpp == c && avail > 0)
+		  while ((unsigned char) *cmpp == c && avail-- > 0)
 		    if (*++cmpp == '\0')
 		      break;
 		    else
 		      {
 			if (inchar () == EOF)
 			  break;
-			--avail;
 		      }
 
 		  if (*cmpp != '\0')
@@ -1652,6 +1653,17 @@ _IO_vfscanf (s, format, argptr, errp)
 
 		      conv_error ();
 		    }
+		  else
+		    {
+                     /* Add all the characters.  */
+                     for (cmpp = decimal; *cmpp != '\0'; ++cmpp)
+                       ADDW ((unsigned char) *cmpp);
+                     if (width > 0)
+                       width = avail;
+                     got_dot = 1;
+
+		      c = inchar ();
+		    }
 		  if (width > 0)
 		    width = avail;
 #endif
@@ -1759,7 +1771,6 @@ _IO_vfscanf (s, format, argptr, errp)
 		}
 	    }
 
-	  got_dot = got_e = 0;
 	  do
 	    {
 	      if (ISDIGIT (c))