Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2010-12-08 00:26:45 +0300
committerJeff Johnston <jjohnstn@redhat.com>2010-12-08 00:26:45 +0300
commitc317cb34b1383564fce06be5123bb7b154e7dc65 (patch)
tree921308c2e2a629b08c152369d646b083af7ade0a /newlib/libc/stdlib
parentf2588cb91dc7af00b9b2f8349c2a7dc563168fe1 (diff)
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/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/strtod.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c
index 1f68bc7b9..fe6aac206 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;
}
}