diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-05-16 13:34:06 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-05-16 13:34:06 +0000 |
commit | f783f223cb31e4f323293489ac2b4c1347e90b45 (patch) | |
tree | ea9399bbbc3937cab9e5f9522add54ac13e8ae39 /newlib/libc/stdlib/strtod.c | |
parent | 883ea27df0f7d9a5836feb493c35026381c55b2b (diff) | |
download | newlib-f783f223cb31e4f323293489ac2b4c1347e90b45.zip newlib-f783f223cb31e4f323293489ac2b4c1347e90b45.tar.gz newlib-f783f223cb31e4f323293489ac2b4c1347e90b45.tar.bz2 |
* libc/stdlib/strtod.c (_strtod_r): Fix nf/nd counts to not exceed
DBL_DIG.
Diffstat (limited to 'newlib/libc/stdlib/strtod.c')
-rw-r--r-- | newlib/libc/stdlib/strtod.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index fe6aac2..7e73b12 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -309,8 +309,7 @@ _DEFUN (_strtod_r, (ptr, s00, se), } nd0 = nd; if (strncmp (s, _localeconv_r (ptr)->decimal_point, - strlen (_localeconv_r (ptr)->decimal_point)) == 0) - { + strlen (_localeconv_r (ptr)->decimal_point)) == 0) { decpt = 1; c = *(s += strlen (_localeconv_r (ptr)->decimal_point)); if (!nd) { @@ -328,25 +327,28 @@ _DEFUN (_strtod_r, (ptr, s00, se), have_dig: nz++; if (c -= '0') { - nf += nz; for(i = 1; i < nz; i++) { - if (nd++ <= DBL_DIG + 1) { - if (nd < 10) + if (nd <= DBL_DIG + 1) { + if (nd + i < 10) y *= 10; else z *= 10; } } - if (nd++ <= DBL_DIG + 1) { - if (nd < 10) + if (nd <= DBL_DIG + 1) { + if (nd + i < 10) y = 10*y + c; else z = 10*z + c; } - nz = 0; + if (nd <= DBL_DIG + 1) { + nf += nz; + nd += nz; } + nz = 0; } } + } dig_done: e = 0; if (c == 'e' || c == 'E') { |