]> git.saurik.com Git - apple/libc.git/blob - gdtoa/FreeBSD/gdtoa-gethex.c.patch
Libc-498.1.5.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / gdtoa-gethex.c.patch
1 --- gdtoa-gethex.c.orig 2005-01-20 20:12:36.000000000 -0800
2 +++ gdtoa-gethex.c 2005-03-23 15:45:22.000000000 -0800
3 @@ -29,6 +29,8 @@
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
12 @@ -37,10 +39,10 @@
13
14 int
15 #ifdef KR_headers
16 -gethex(sp, fpi, exp, bp, sign)
17 - CONST char **sp; FPI *fpi; Long *exp; Bigint **bp; int sign;
18 +gethex(sp, fpi, exp, bp, sign, loc)
19 + CONST char **sp; FPI *fpi; Long *exp; Bigint **bp; int sign; locale_t loc;
20 #else
21 -gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
22 +gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign, locale_t loc)
23 #endif
24 {
25 Bigint *b;
26 @@ -49,7 +51,13 @@
27 ULong L, lostbits, *x;
28 Long e, e1;
29 #ifdef USE_LOCALE
30 - unsigned char decimalpoint = *localeconv()->decimal_point;
31 + char *decimalpoint;
32 + unsigned char *decimalpointend = NULL;
33 + int decimalpointlen;
34 +
35 + NORMALIZE_LOCALE(loc);
36 + decimalpoint = localeconv_l(loc)->decimal_point;
37 + decimalpointlen = strlen(decimalpoint);
38 #else
39 #define decimalpoint '.'
40 #endif
41 @@ -67,9 +75,18 @@
42 e = 0;
43 if (!hexdig[*s]) {
44 zret = 1;
45 +#ifdef USE_LOCALE
46 + if (strncmp((char *)s, decimalpoint, decimalpointlen) != 0)
47 +#else /* USE_LOCALE */
48 if (*s != decimalpoint)
49 +#endif /* USE_LOCALE */
50 goto pcheck;
51 +#ifdef USE_LOCALE
52 + decpt = (s += decimalpointlen);
53 + decimalpointend = s - 1;
54 +#else /* USE_LOCALE */
55 decpt = ++s;
56 +#endif /* USE_LOCALE */
57 if (!hexdig[*s])
58 goto pcheck;
59 while(*s == '0')
60 @@ -81,8 +98,18 @@
61 }
62 while(hexdig[*s])
63 s++;
64 - if (*s == decimalpoint && !decpt) {
65 +#ifdef USE_LOCALE
66 + if (strncmp((char *)s, decimalpoint, decimalpointlen) == 0 && !decpt)
67 +#else /* USE_LOCALE */
68 + if (*s == decimalpoint && !decpt)
69 +#endif /* USE_LOCALE */
70 + {
71 +#ifdef USE_LOCALE
72 + decpt = (s += decimalpointlen);
73 + decimalpointend = s - 1;
74 +#else /* USE_LOCALE */
75 decpt = ++s;
76 +#endif /* USE_LOCALE */
77 while(hexdig[*s])
78 s++;
79 }
80 @@ -123,8 +150,15 @@
81 n = 0;
82 L = 0;
83 while(s1 > s0) {
84 +#ifdef USE_LOCALE
85 + if (--s1 == decimalpointend) {
86 + s1 -= decimalpointlen - 1;
87 + continue;
88 + }
89 +#else /* USE_LOCALE */
90 if (*--s1 == decimalpoint)
91 continue;
92 +#endif /* USE_LOCALE */
93 if (n == 32) {
94 *x++ = L;
95 L = 0;