]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-04-26 Ulrich Drepper <drepper@redhat.com>
authorRoland McGrath <roland@gnu.org>
Mon, 18 Jul 2005 04:10:03 +0000 (04:10 +0000)
committerRoland McGrath <roland@gnu.org>
Mon, 18 Jul 2005 04:10:03 +0000 (04:10 +0000)
[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>.

stdio-common/vfscanf.c

index c641d2d37104c89847de88fb4749db13407d56f7..b95c40b84b7b6167cc8de4f2537d42c224f7ab5f 100644 (file)
@@ -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))