Rev 4874 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | #include "mprec.h" |
35 | #include "mprec.h" |
36 | #include "gdtoa.h" |
36 | #include "gdtoa.h" |
37 | #include "gd_qnan.h" |
37 | #include "gd_qnan.h" |
38 | #include "locale.h" |
38 | #include "locale.h" |
Line -... | Line 39... | ||
- | 39 | ||
39 | 40 | #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(_SMALL_HEXDIG) |
|
40 | unsigned char hexdig[256]; |
41 | _CONST unsigned char __hexdig[256]= |
- | 42 | { |
|
- | 43 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
- | 44 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
- | 45 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
- | 46 | 16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0, |
|
- | 47 | 0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0, |
|
- | 48 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
41 | 49 | 0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0, |
|
42 | static void |
50 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
43 | _DEFUN (htinit, (h, s, inc), |
51 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
44 | unsigned char *h _AND |
52 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
45 | unsigned char *s _AND |
53 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
46 | int inc) |
- | |
- | 54 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
47 | { |
55 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
48 | int i, j; |
56 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
49 | for(i = 0; (j = s[i]) !=0; i++) |
57 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
50 | h[j] = i + inc; |
58 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
51 | } |
- | |
- | 59 | }; |
|
52 | 60 | #else /* !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(_SMALL_HEXDIG) */ |
|
53 | void |
61 | unsigned char |
- | 62 | _DEFUN (__hexdig_fun, (c), |
|
54 | _DEFUN_VOID (hexdig_init) |
63 | unsigned char c) |
55 | { |
64 | { |
56 | #define USC (unsigned char *) |
65 | if(c>='0' && c<='9') return c-'0'+0x10; |
57 | htinit(hexdig, USC "0123456789", 0x10); |
66 | else if(c>='a' && c<='f') return c-'a'+0x10+10; |
58 | htinit(hexdig, USC "abcdef", 0x10 + 10); |
67 | else if(c>='A' && c<='F') return c-'A'+0x10+10; |
59 | htinit(hexdig, USC "ABCDEF", 0x10 + 10); |
68 | else return 0; |
- | 69 | } |
|
Line 60... | Line 70... | ||
60 | } |
70 | #endif /* !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(_SMALL_HEXDIG) */ |
61 | 71 | ||
62 | static void |
72 | static void |
63 | _DEFUN(rshift, (b, k), |
73 | _DEFUN(rshift, (b, k), |
Line 136... | Line 146... | ||
136 | 146 | ||
137 | int |
147 | int |
138 | _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), |
148 | _DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), |
139 | struct _reent *ptr _AND |
149 | struct _reent *ptr _AND |
140 | _CONST char **sp _AND |
150 | _CONST char **sp _AND |
141 | FPI *fpi _AND |
151 | _CONST FPI *fpi _AND |
142 | Long *exp _AND |
152 | Long *exp _AND |
143 | _Bigint **bp _AND |
153 | _Bigint **bp _AND |
144 | int sign) |
154 | int sign) |
145 | { |
155 | { |
Line 151... | Line 161... | ||
151 | unsigned char *decimalpoint = (unsigned char *) |
161 | unsigned char *decimalpoint = (unsigned char *) |
152 | _localeconv_r (ptr)->decimal_point; |
162 | _localeconv_r (ptr)->decimal_point; |
153 | size_t decp_len = strlen ((const char *) decimalpoint); |
163 | size_t decp_len = strlen ((const char *) decimalpoint); |
154 | unsigned char decp_end = decimalpoint[decp_len - 1]; |
164 | unsigned char decp_end = decimalpoint[decp_len - 1]; |
Line 155... | Line -... | ||
155 | - | ||
156 | if (!hexdig['0']) |
- | |
157 | hexdig_init(); |
165 | |
158 | havedig = 0; |
166 | havedig = 0; |
159 | s0 = *(_CONST unsigned char **)sp + 2; |
167 | s0 = *(_CONST unsigned char **)sp + 2; |
160 | while(s0[havedig] == '0') |
168 | while(s0[havedig] == '0') |
161 | havedig++; |
169 | havedig++; |
162 | s0 += havedig; |
170 | s0 += havedig; |
163 | s = s0; |
171 | s = s0; |
164 | decpt = 0; |
172 | decpt = 0; |
165 | zret = 0; |
173 | zret = 0; |
166 | e = 0; |
174 | e = 0; |
167 | if (!hexdig[*s]) { |
175 | if (!__get_hexdig(*s)) { |
168 | zret = 1; |
176 | zret = 1; |
169 | if (strncmp ((const char *) s, (const char *) decimalpoint, |
177 | if (strncmp ((const char *) s, (const char *) decimalpoint, |
170 | decp_len) != 0) |
178 | decp_len) != 0) |
171 | goto pcheck; |
179 | goto pcheck; |
172 | decpt = (s += decp_len); |
180 | decpt = (s += decp_len); |
173 | if (!hexdig[*s]) |
181 | if (!__get_hexdig(*s)) |
174 | goto pcheck; |
182 | goto pcheck; |
175 | while(*s == '0') |
183 | while(*s == '0') |
176 | s++; |
184 | s++; |
177 | if (hexdig[*s]) |
185 | if (__get_hexdig(*s)) |
178 | zret = 0; |
186 | zret = 0; |
179 | havedig = 1; |
187 | havedig = 1; |
180 | s0 = s; |
188 | s0 = s; |
181 | } |
189 | } |
182 | while(hexdig[*s]) |
190 | while(__get_hexdig(*s)) |
183 | s++; |
191 | s++; |
184 | if (strncmp ((const char *) s, (const char *) decimalpoint, |
192 | if (strncmp ((const char *) s, (const char *) decimalpoint, |
185 | decp_len) == 0 |
193 | decp_len) == 0 |
186 | && !decpt) { |
194 | && !decpt) { |
187 | decpt = (s += decp_len); |
195 | decpt = (s += decp_len); |
188 | while(hexdig[*s]) |
196 | while(__get_hexdig(*s)) |
189 | s++; |
197 | s++; |
190 | } |
198 | } |
191 | if (decpt) |
199 | if (decpt) |
192 | e = -(((Long)(s-decpt)) << 2); |
200 | e = -(((Long)(s-decpt)) << 2); |
Line 201... | Line 209... | ||
201 | esign = 1; |
209 | esign = 1; |
202 | /* no break */ |
210 | /* no break */ |
203 | case '+': |
211 | case '+': |
204 | s++; |
212 | s++; |
205 | } |
213 | } |
206 | if ((n = hexdig[*s]) == 0 || n > 0x19) { |
214 | if ((n = __get_hexdig(*s)) == 0 || n > 0x19) { |
207 | s = s1; |
215 | s = s1; |
208 | break; |
216 | break; |
209 | } |
217 | } |
210 | e1 = n - 0x10; |
218 | e1 = n - 0x10; |
211 | while((n = hexdig[*++s]) !=0 && n <= 0x19) |
219 | while((n = __get_hexdig(*++s)) !=0 && n <= 0x19) |
212 | e1 = 10*e1 + n - 0x10; |
220 | e1 = 10*e1 + n - 0x10; |
213 | if (esign) |
221 | if (esign) |
214 | e1 = -e1; |
222 | e1 = -e1; |
215 | e += e1; |
223 | e += e1; |
216 | } |
224 | } |
Line 234... | Line 242... | ||
234 | if (n == 32) { |
242 | if (n == 32) { |
235 | *x++ = L; |
243 | *x++ = L; |
236 | L = 0; |
244 | L = 0; |
237 | n = 0; |
245 | n = 0; |
238 | } |
246 | } |
239 | L |= (hexdig[*s1] & 0x0f) << n; |
247 | L |= (__get_hexdig(*s1) & 0x0f) << n; |
240 | n += 4; |
248 | n += 4; |
241 | } |
249 | } |
242 | *x++ = L; |
250 | *x++ = L; |
243 | b->_wds = n = x - b->_x; |
251 | b->_wds = n = x - b->_x; |
244 | n = 32*n - hi0bits(L); |
252 | n = 32*n - hi0bits(L); |