2011-05-12 Christian Bruel * libc/stdlib/strtod.c (_strtod_r): Fix nf/nd counts to not pass DBL_DIG. Index: libc/stdlib/strtod.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/strtod.c,v retrieving revision 1.17 diff -u -r1.17 strtod.c --- libc/stdlib/strtod.c 7 Dec 2010 21:26:45 -0000 1.17 +++ libc/stdlib/strtod.c 12 May 2011 11:54:27 -0000 @@ -328,24 +328,29 @@ 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 + 1 < 10) y = 10*y + c; else z = 10*z + c; } + + if (nd <= DBL_DIG + 1) + { + nf += nz; + nd += nz; + } nz = 0; } - } + } } dig_done: e = 0;