diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-04-07 03:57:06 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-04-07 03:57:06 +0000 |
commit | 5942ee569df05b5905cd7744b48b9759710bb101 (patch) | |
tree | cd5dcbb508f2638a894c34deb5fbad98f5707aee | |
parent | 169a244f2173759963510ab29d470e7aad28608c (diff) | |
download | glibc-5942ee569df05b5905cd7744b48b9759710bb101.tar.gz |
Handle hexadecimal numbers with leading digit != 1 correctly and more than
one digit before decimal point.
-rw-r--r-- | stdlib/strtod.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/stdlib/strtod.c b/stdlib/strtod.c index 7502799edf..f2ff79f6df 100644 --- a/stdlib/strtod.c +++ b/stdlib/strtod.c @@ -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)) |