about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-10-29 23:53:04 +0000
committerUlrich Drepper <drepper@redhat.com>1999-10-29 23:53:04 +0000
commitc603b15b4461161f909f9827c294ba6c1d6a4bd5 (patch)
treedfa476417332a778d8440ed0169763d0331ac6e6 /stdlib
parentf720d3d2120ebb9a87af7c10e0939fb9dfee20ef (diff)
downloadglibc-c603b15b4461161f909f9827c294ba6c1d6a4bd5.tar.gz
glibc-c603b15b4461161f909f9827c294ba6c1d6a4bd5.tar.xz
glibc-c603b15b4461161f909f9827c294ba6c1d6a4bd5.zip
Update.
1999-10-29  Ulrich Drepper  <drepper@cygnus.com>

	* stdlib/strtod.c: Handle hexadecimal numbers with leading digit
	!= 1 correctly.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/strtod.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 7502799edf..4a3c8a2725 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;
+
       while (--dig_no > 0 && idx >= 0)
 	{
 	  while (!ISXDIGIT (*startp))