diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2010-12-07 21:26:45 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2010-12-07 21:26:45 +0000 |
commit | c317cb34b1383564fce06be5123bb7b154e7dc65 (patch) | |
tree | 921308c2e2a629b08c152369d646b083af7ade0a /newlib | |
parent | f2588cb91dc7af00b9b2f8349c2a7dc563168fe1 (diff) | |
download | newlib-c317cb34b1383564fce06be5123bb7b154e7dc65.zip newlib-c317cb34b1383564fce06be5123bb7b154e7dc65.tar.gz newlib-c317cb34b1383564fce06be5123bb7b154e7dc65.tar.bz2 |
2010-12-07 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/strtod.c(_strtod_r): Fix code to handle case whereby
_DOUBLE_IS_32BITS is set and DBL_DIGS is 6 instead of 15.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 5 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtod.c | 36 |
2 files changed, 27 insertions, 14 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 9ff7219..7d0cc88 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2010-12-07 Jeff Johnston <jjohnstn@redhat.com> + + * libc/stdlib/strtod.c(_strtod_r): Fix code to handle case whereby + _DOUBLE_IS_32BITS is set and DBL_DIGS is 6 instead of 15. + 2010-12-07 Ralf Corsépius <ralf.corsepius@rtems.org> * libc/include/strings.h: New (split-out from string.h). diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index 1f68bc7..fe6aac2 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -299,11 +299,14 @@ _DEFUN (_strtod_r, (ptr, s00, se), } s0 = s; y = z = 0; - for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) - if (nd < 9) - y = 10*y + c - '0'; - else if (nd < 16) - z = 10*z + c - '0'; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) { + if (nd < DBL_DIG + 1) { + if (nd < 9) + y = 10*y + c - '0'; + else + z = 10*z + c - '0'; + } + } nd0 = nd; if (strncmp (s, _localeconv_r (ptr)->decimal_point, strlen (_localeconv_r (ptr)->decimal_point)) == 0) @@ -326,15 +329,20 @@ _DEFUN (_strtod_r, (ptr, s00, se), nz++; if (c -= '0') { nf += nz; - for(i = 1; i < nz; i++) - if (nd++ < 9) - y *= 10; - else if (nd <= DBL_DIG + 1) - z *= 10; - if (nd++ < 9) - y = 10*y + c; - else if (nd <= DBL_DIG + 1) - z = 10*z + c; + for(i = 1; i < nz; i++) { + if (nd++ <= DBL_DIG + 1) { + if (nd < 10) + y *= 10; + else + z *= 10; + } + } + if (nd++ <= DBL_DIG + 1) { + if (nd < 10) + y = 10*y + c; + else + z = 10*z + c; + } nz = 0; } } |