1 --- gdtoa-strtodg.c.orig 2007-10-04 15:00:21.000000000 -0700
2 +++ gdtoa-strtodg.c 2007-10-04 17:49:06.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"
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(double d, FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv);
27 +int mantbits(double d);
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,
39 + __private_extern__ int
41 all_on(b, n) Bigint *b; int n;
48 + __private_extern__ int
51 (d, fpi, exp, bits, exact, rd, irv)
57 + __private_extern__ int
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)
83 Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0;
85 + char *decimal_point;
86 + int decimal_point_len;
87 +#endif /* USE_LOCALE */
90 denorm = sign = nz0 = nz = 0;
95 - irv = gethex(&s, fpi, exp, &rvb, sign);
96 + irv = gethex(&s, fpi, exp, &rvb, sign, loc);
97 if (irv == STRTOG_NoNumber) {
100 @@ -389,14 +411,22 @@
104 + NORMALIZE_LOCALE(loc);
106 - if (c == *localeconv()->decimal_point)
107 + decimal_point = localeconv_l(loc)->decimal_point;
108 + decimal_point_len = strlen(decimal_point);
109 + if (strncmp(s, decimal_point, decimal_point_len) == 0)
116 + s += decimal_point_len;
122 for(; c == '0'; c = *++s)
127 irv = STRTOG_Underflow | STRTOG_Inexlo;
133 rvb->x[0] = rvb->wds = rvbits = 1;
136 /* Put digits into bd: true value = bd * 10^e */
138 - bd0 = s2b(s0, nd0, nd, y);
140 + bd0 = s2b(s0, nd0, nd, y, decimal_point_len);
142 + bd0 = s2b(s0, nd0, nd, y, 1);
148 rvb = increment(rvb);
149 if ( (j = rvbits & kmask) !=0)
151 - if (hi0bits(rvb->x[(rvb->wds - 1) >> kshift])
152 + if (hi0bits(rvb->x[rvb->wds - 1])
155 irv = STRTOG_Normal | STRTOG_Inexhi;
156 @@ -1008,5 +1045,9 @@
157 copybits(bits, nbits, rvb);
160 +#if !defined(NO_ERRNO) && __DARWIN_UNIX03
161 + if (irv & STRTOG_Underflow)