1 --- gdtoa-strtodg.c.orig 2010-01-29 16:43:20.000000000 -0800
2 +++ gdtoa-strtodg.c 2010-01-29 18:13:37.000000000 -0800
3 @@ -29,13 +29,29 @@ 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 "."). */
7 +#include "xlocale_private.h"
16 +#define fivesbits __fivesbits_D2A
17 +#define all_on __all_on_D2A
18 +#define set_ones __set_ones_D2A
19 +#define rvOK __rvOK_D2A
20 +#define mantbits __mantbits_D2A
22 +#ifdef BUILDING_VARIANT
23 +extern CONST int fivesbits[];
24 +int all_on(Bigint *b, int n);
25 +Bigint *set_ones(Bigint *b, int n);
26 +int rvOK(U *d, FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv);
28 +#else /* !BUILDING_VARIANT */
30 + __private_extern__ CONST int
31 fivesbits[] = { 0, 3, 5, 7, 10, 12, 14, 17, 19, 21,
32 24, 26, 28, 31, 33, 35, 38, 40, 42, 45,
34 @@ -121,7 +137,7 @@ decrement(Bigint *b)
39 + __private_extern__ int
41 all_on(b, n) Bigint *b; int n;
43 @@ -168,7 +184,7 @@ set_ones(Bigint *b, int n)
48 + __private_extern__ int
51 (d, fpi, exp, bits, exact, rd, irv)
52 @@ -289,7 +305,7 @@ rvOK
57 + __private_extern__ int
61 @@ -312,13 +328,15 @@ mantbits(U *d)
62 return P - 32 - lo0bits(&L);
65 +#endif /* BUILDING_VARIANT */
70 - (s00, se, fpi, exp, bits)
71 - CONST char *s00; char **se; FPI *fpi; Long *exp; ULong *bits;
72 + (s00, se, fpi, exp, bits, loc)
73 + CONST char *s00; char **se; FPI *fpi; Long *exp; ULong *bits; locale_t loc;
75 - (CONST char *s00, char **se, FPI *fpi, Long *exp, ULong *bits)
76 + (CONST char *s00, char **se, FPI *fpi, Long *exp, ULong *bits, locale_t loc)
80 @@ -327,21 +345,23 @@ strtodg
81 int j, k, nbits, nd, nd0, nf, nz, nz0, rd, rvbits, rve, rve1, sign;
83 CONST char *s, *s0, *s1;
84 + char *strunc = NULL;
89 Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0;
90 #ifdef USE_LOCALE /*{{*/
91 + NORMALIZE_LOCALE(loc);
92 #ifdef NO_LOCALE_CACHE
93 - char *decimalpoint = localeconv()->decimal_point;
94 + char *decimalpoint = localeconv_l(loc)->decimal_point;
95 int dplen = strlen(decimalpoint);
98 static char *decimalpoint_cache;
100 if (!(s0 = decimalpoint_cache)) {
101 - s0 = localeconv()->decimal_point;
102 + s0 = localeconv_l(loc)->decimal_point;
103 if ((decimalpoint_cache = (char*)MALLOC(strlen(s0) + 1))) {
104 strcpy(decimalpoint_cache, s0);
105 s0 = decimalpoint_cache;
106 @@ -388,7 +408,7 @@ strtodg
110 - irv = gethex(&s, fpi, exp, &rvb, sign);
111 + irv = gethex(&s, fpi, exp, &rvb, sign, loc);
112 if (irv == STRTOG_NoNumber) {
115 @@ -525,6 +545,7 @@ strtodg
119 + TRUNCATE_DIGITS(s0, strunc, nd, nd0, nf, fpi->nbits, fpi->emin, dplen);
123 @@ -693,6 +714,10 @@ strtodg
126 irv = STRTOG_Underflow | STRTOG_Inexlo;
127 +/* When __DARWIN_UNIX03 is set, we don't need this (errno is set later) */
128 +#if !defined(NO_ERRNO) && !__DARWIN_UNIX03
133 rvb->x[0] = rvb->wds = rvbits = 1;
134 @@ -1038,7 +1063,7 @@ strtodg
135 if (sudden_underflow) {
137 irv = STRTOG_Underflow | STRTOG_Inexlo;
139 +#if !defined(NO_ERRNO) && __DARWIN_UNIX03
143 @@ -1047,7 +1072,7 @@ strtodg
144 (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero);
145 if (irv & STRTOG_Inexact) {
146 irv |= STRTOG_Underflow;
148 +#if !defined(NO_ERRNO) && __DARWIN_UNIX03
152 @@ -1061,5 +1086,11 @@ strtodg
153 copybits(bits, nbits, rvb);