]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Handle hexadecimal numbers with leading digit != 1 correctly and more than
authorUlrich Drepper <drepper@redhat.com>
Fri, 7 Apr 2000 03:57:06 +0000 (03:57 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 7 Apr 2000 03:57:06 +0000 (03:57 +0000)
one digit before decimal point.

stdlib/strtod.c

index 7502799edf9de88634b74148821bf6ad50490f50..f2ff79f6df4963906d2e6f7a9368b6b2b202ca9c 100644 (file)
@@ -797,11 +797,15 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
 
       while (!ISXDIGIT (*startp))
        ++startp;
+      while (*startp == L_('0'))
+       ++startp;
       if (ISDIGIT (*startp))
        val = *startp++ - L_('0');
       else
        val = 10 + TOLOWER (*startp++) - L_('a');
       bits = nbits[val];
+      /* We cannot have a leading zero.  */
+      assert (bits != 0);
 
       if (pos + 1 >= 4 || pos + 1 >= bits)
        {
@@ -819,6 +823,9 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
          pos = BITS_PER_MP_LIMB - 1 - (bits - pos - 1);
        }
 
+      /* Adjust the exponent for the bits we are shifting in.  */
+      exponent += bits - 1 + (int_no - 1) * 4;
+
       while (--dig_no > 0 && idx >= 0)
        {
          while (!ISXDIGIT (*startp))