]>
Commit | Line | Data |
---|---|---|
34e8f829 A |
1 | --- gdtoa-strtodg.c.orig 2008-10-28 12:23:36.000000000 -0700 |
2 | +++ gdtoa-strtodg.c 2008-10-28 12:34:18.000000000 -0700 | |
3 | @@ -29,13 +29,29 @@ THIS SOFTWARE. | |
3d9156a7 A |
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 | ||
11 | #ifdef USE_LOCALE | |
224c7076 A |
12 | #include "locale.h" |
13 | #endif | |
14 | ||
15 | - static CONST int | |
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 | |
21 | + | |
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 */ | |
29 | + | |
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, | |
33 | 47, 49, 52 | |
34e8f829 A |
34 | @@ -121,7 +137,7 @@ decrement(Bigint *b) |
35 | #endif | |
224c7076 A |
36 | } |
37 | ||
38 | - static int | |
39 | + __private_extern__ int | |
40 | #ifdef KR_headers | |
41 | all_on(b, n) Bigint *b; int n; | |
42 | #else | |
34e8f829 | 43 | @@ -168,7 +184,7 @@ set_ones(Bigint *b, int n) |
224c7076 A |
44 | return b; |
45 | } | |
46 | ||
47 | - static int | |
48 | + __private_extern__ int | |
49 | rvOK | |
50 | #ifdef KR_headers | |
51 | (d, fpi, exp, bits, exact, rd, irv) | |
34e8f829 | 52 | @@ -289,7 +305,7 @@ rvOK |
224c7076 A |
53 | return rv; |
54 | } | |
55 | ||
56 | - static int | |
57 | + __private_extern__ int | |
58 | #ifdef KR_headers | |
59 | mantbits(d) double d; | |
60 | #else | |
34e8f829 | 61 | @@ -312,13 +328,15 @@ mantbits(double d) |
224c7076 A |
62 | return P - 32 - lo0bits(&L); |
63 | } | |
64 | ||
65 | +#endif /* BUILDING_VARIANT */ | |
66 | + | |
3d9156a7 A |
67 | int |
68 | strtodg | |
69 | #ifdef KR_headers | |
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; | |
74 | #else | |
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) | |
77 | #endif | |
78 | { | |
79 | int abe, abits, asub; | |
34e8f829 A |
80 | @@ -332,13 +350,14 @@ strtodg |
81 | ULong *b, *be, y, z; | |
224c7076 | 82 | Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0; |
34e8f829 A |
83 | #ifdef USE_LOCALE |
84 | + NORMALIZE_LOCALE(loc) | |
85 | #ifdef NO_LOCALE_CACHE | |
86 | - char *decimalpoint = localeconv()->decimal_point; | |
87 | + char *decimalpoint = localeconv_l(loc)->decimal_point; | |
88 | #else | |
89 | char *decimalpoint; | |
90 | static char *decimalpoint_cache; | |
91 | if (!(s0 = decimalpoint_cache)) { | |
92 | - s0 = localeconv()->decimal_point; | |
93 | + s0 = localeconv_l(loc)->decimal_point; | |
94 | if ((decimalpoint_cache = (char*)malloc(strlen(s0) + 1))) { | |
95 | strcpy(decimalpoint_cache, s0); | |
96 | s0 = decimalpoint_cache; | |
97 | @@ -382,7 +401,7 @@ strtodg | |
3d9156a7 A |
98 | switch(s[1]) { |
99 | case 'x': | |
100 | case 'X': | |
101 | - irv = gethex(&s, fpi, exp, &rvb, sign); | |
102 | + irv = gethex(&s, fpi, exp, &rvb, sign, loc); | |
103 | if (irv == STRTOG_NoNumber) { | |
104 | s = s00; | |
105 | sign = 0; | |
34e8f829 | 106 | @@ -687,6 +706,10 @@ strtodg |
3d9156a7 A |
107 | rvb->x[0] = 0; |
108 | *exp = emin; | |
109 | irv = STRTOG_Underflow | STRTOG_Inexlo; | |
34e8f829 A |
110 | +/* When __DARWIN_UNIX03 is set, we don't need this (errno is set later) */ |
111 | +#if !defined(NO_ERRNO) && !__DARWIN_UNIX03 | |
3d9156a7 A |
112 | + errno = ERANGE; |
113 | +#endif | |
114 | goto ret; | |
115 | } | |
116 | rvb->x[0] = rvb->wds = rvbits = 1; | |
34e8f829 | 117 | @@ -703,7 +726,11 @@ strtodg |
224c7076 A |
118 | |
119 | /* Put digits into bd: true value = bd * 10^e */ | |
120 | ||
121 | - bd0 = s2b(s0, nd0, nd, y); | |
122 | +#ifdef USE_LOCALE | |
34e8f829 | 123 | + bd0 = s2b(s0, nd0, nd, y, strlen(decimalpoint)); |
224c7076 A |
124 | +#else |
125 | + bd0 = s2b(s0, nd0, nd, y, 1); | |
126 | +#endif | |
127 | ||
128 | for(;;) { | |
129 | bd = Balloc(bd0->k); | |
34e8f829 A |
130 | @@ -1032,7 +1059,7 @@ strtodg |
131 | if (sudden_underflow) { | |
132 | rvb->wds = 0; | |
133 | irv = STRTOG_Underflow | STRTOG_Inexlo; | |
134 | -#ifndef NO_ERRNO | |
224c7076 | 135 | +#if !defined(NO_ERRNO) && __DARWIN_UNIX03 |
34e8f829 A |
136 | errno = ERANGE; |
137 | #endif | |
138 | } | |
139 | @@ -1041,7 +1068,7 @@ strtodg | |
140 | (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero); | |
141 | if (irv & STRTOG_Inexact) { | |
142 | irv |= STRTOG_Underflow; | |
143 | -#ifndef NO_ERRNO | |
144 | +#if !defined(NO_ERRNO) && __DARWIN_UNIX03 | |
145 | errno = ERANGE; | |
146 | #endif | |
147 | } |