1 --- gdtoa-strtod.c.orig 2007-10-04 15:00:21.000000000 -0700
2 +++ gdtoa-strtod.c 2007-10-04 15:02:41.000000000 -0700
4 /* Please send bug reports to David M. Gay (dmg at acm dot org,
5 * with " at " changed at "@" and " dot " changed to "."). */
7 +#include "xlocale_private.h"
19 - (s00, se) CONST char *s00; char **se;
20 + (s00, se, loc) CONST char *s00; char **se; locale_t loc;
22 - (CONST char *s00, char **se)
23 + (CONST char *s00, char **se, locale_t loc)
26 #ifdef Avoid_Underflow
28 int inexact, oldinexact;
30 #ifdef Honor_FLT_ROUNDS
32 + int rounding = Flt_Rounds;
35 + char *decimal_point;
36 + int decimal_point_len;
37 +#endif /* USE_LOCALE */
39 sign = nz0 = nz = decpt = 0;
45 - switch((i = gethex(&s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) {
46 + switch((i = gethex(&s, &fpi1, &exp, &bb, sign, loc)) & STRTOG_Retmask) {
54 + NORMALIZE_LOCALE(loc);
56 - if (c == *localeconv()->decimal_point)
57 + decimal_point = localeconv_l(loc)->decimal_point;
58 + decimal_point_len = strlen(decimal_point);
59 + if (strncmp(s, decimal_point, decimal_point_len) == 0)
66 + s += decimal_point_len;
72 for(; c == '0'; c = *++s)
77 #ifdef Honor_FLT_ROUNDS
78 - if ((rounding = Flt_Rounds) >= 2) {
79 + if (rounding >= 2) {
81 rounding = rounding == 2 ? 0 : 2;
85 /* Put digits into bd: true value = bd * 10^e */
87 - bd0 = s2b(s0, nd0, nd, y);
89 + bd0 = s2b(s0, nd0, nd, y, decimal_point_len);
91 + bd0 = s2b(s0, nd0, nd, y, 1);
97 dval(rv) *= dval(rv0);
99 /* try to avoid the bug of testing an 8087 register value */
101 + if (word0(rv) == 0 && word1(rv) == 0 || dval(rv) < DBL_MIN)
102 +#else /* !__DARWIN_UNIX03 */
103 if (word0(rv) == 0 && word1(rv) == 0)
104 +#endif /* __DARWIN_UNIX03 */
108 @@ -980,3 +1002,13 @@
109 return sign ? -dval(rv) : dval(rv);
115 + (s00, se) CONST char *s00; char **se;
117 + (CONST char *s00, char **se)
120 + return strtod_l(s00, se, __current_locale());