]>
Commit | Line | Data |
---|---|---|
1 | --- gdtoa-strtod.c.orig 2008-10-28 12:07:31.000000000 -0700 | |
2 | +++ gdtoa-strtod.c 2008-10-28 12:22:37.000000000 -0700 | |
3 | @@ -29,6 +29,8 @@ THIS SOFTWARE. | |
4 | /* Please send bug reports to David M. Gay (dmg at acm dot org, | |
5 | * with " at " changed at "@" and " dot " changed to "."). */ | |
6 | ||
7 | +#include "xlocale_private.h" | |
8 | + | |
9 | #include "gdtoaimp.h" | |
10 | #ifndef NO_FENV_H | |
11 | #include <fenv.h> | |
12 | @@ -58,11 +60,11 @@ static CONST double tinytens[] = { 1e-16 | |
13 | #endif | |
14 | ||
15 | double | |
16 | -strtod | |
17 | +strtod_l | |
18 | #ifdef KR_headers | |
19 | - (s00, se) CONST char *s00; char **se; | |
20 | + (s00, se, loc) CONST char *s00; char **se; locale_t loc; | |
21 | #else | |
22 | - (CONST char *s00, char **se) | |
23 | + (CONST char *s00, char **se, locale_t loc) | |
24 | #endif | |
25 | { | |
26 | #ifdef Avoid_Underflow | |
27 | @@ -79,13 +81,14 @@ strtod | |
28 | int inexact, oldinexact; | |
29 | #endif | |
30 | #ifdef USE_LOCALE | |
31 | + NORMALIZE_LOCALE(loc); | |
32 | #ifdef NO_LOCALE_CACHE | |
33 | - char *decimalpoint = localeconv()->decimal_point; | |
34 | + char *decimalpoint = localeconv_l(loc)->decimal_point; | |
35 | #else | |
36 | char *decimalpoint; | |
37 | static char *decimalpoint_cache; | |
38 | if (!(s0 = decimalpoint_cache)) { | |
39 | - s0 = localeconv()->decimal_point; | |
40 | + s0 = localeconv_l(loc)->decimal_point; | |
41 | if ((decimalpoint_cache = (char*)malloc(strlen(s0) + 1))) { | |
42 | strcpy(decimalpoint_cache, s0); | |
43 | s0 = decimalpoint_cache; | |
44 | @@ -155,7 +158,7 @@ strtod | |
45 | #else /*}{*/ | |
46 | #define fpi1 fpi | |
47 | #endif /*}}*/ | |
48 | - switch((i = gethex(&s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) { | |
49 | + switch((i = gethex(&s, &fpi1, &exp, &bb, sign, loc)) & STRTOG_Retmask) { | |
50 | case STRTOG_NoNumber: | |
51 | s = s00; | |
52 | sign = 0; | |
53 | @@ -545,7 +548,11 @@ strtod | |
54 | ||
55 | /* Put digits into bd: true value = bd * 10^e */ | |
56 | ||
57 | - bd0 = s2b(s0, nd0, nd, y); | |
58 | +#ifdef USE_LOCALE | |
59 | + bd0 = s2b(s0, nd0, nd, y, strlen(decimalpoint)); | |
60 | +#else | |
61 | + bd0 = s2b(s0, nd0, nd, y, 1); | |
62 | +#endif | |
63 | ||
64 | for(;;) { | |
65 | bd = Balloc(bd0->k); | |
66 | @@ -992,7 +999,7 @@ strtod | |
67 | dval(rv) *= dval(rv0); | |
68 | #ifndef NO_ERRNO | |
69 | /* try to avoid the bug of testing an 8087 register value */ | |
70 | -#ifdef IEEE_Arith | |
71 | +#if defined(IEEE_Arith) && __DARWIN_UNIX03 | |
72 | if (!(word0(rv) & Exp_mask)) | |
73 | #else | |
74 | if (word0(rv) == 0 && word1(rv) == 0) | |
75 | @@ -1020,3 +1027,13 @@ strtod | |
76 | return sign ? -dval(rv) : dval(rv); | |
77 | } | |
78 | ||
79 | + double | |
80 | +strtod | |
81 | +#ifdef KR_headers | |
82 | + (s00, se) CONST char *s00; char **se; | |
83 | +#else | |
84 | + (CONST char *s00, char **se) | |
85 | +#endif | |
86 | +{ | |
87 | + return strtod_l(s00, se, __current_locale()); | |
88 | +} |