]> git.saurik.com Git - apple/libc.git/blame - gdtoa/FreeBSD/gdtoa-strtod.c.patch
Libc-594.1.4.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / gdtoa-strtod.c.patch
CommitLineData
34e8f829
A
1--- gdtoa-strtod.c.orig 2008-10-28 12:07:31.000000000 -0700
2+++ gdtoa-strtod.c 2008-10-28 12:22:37.000000000 -0700
3@@ -29,6 +29,8 @@ 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"
eb1cde05
A
10 #ifndef NO_FENV_H
11 #include <fenv.h>
34e8f829 12@@ -58,11 +60,11 @@ static CONST double tinytens[] = { 1e-16
3d9156a7
A
13 #endif
14
15 double
16-strtod
17+strtod_l
18 #ifdef KR_headers
19- (s00, se) CONST char *s00; char **se;
20+ (s00, se, loc) CONST char *s00; char **se; locale_t loc;
21 #else
22- (CONST char *s00, char **se)
23+ (CONST char *s00, char **se, locale_t loc)
24 #endif
25 {
26 #ifdef Avoid_Underflow
34e8f829 27@@ -79,13 +81,14 @@ strtod
224c7076
A
28 int inexact, oldinexact;
29 #endif
34e8f829
A
30 #ifdef USE_LOCALE
31+ NORMALIZE_LOCALE(loc);
32 #ifdef NO_LOCALE_CACHE
33- char *decimalpoint = localeconv()->decimal_point;
34+ char *decimalpoint = localeconv_l(loc)->decimal_point;
eb1cde05 35 #else
34e8f829
A
36 char *decimalpoint;
37 static char *decimalpoint_cache;
38 if (!(s0 = decimalpoint_cache)) {
39- s0 = localeconv()->decimal_point;
40+ s0 = localeconv_l(loc)->decimal_point;
41 if ((decimalpoint_cache = (char*)malloc(strlen(s0) + 1))) {
42 strcpy(decimalpoint_cache, s0);
43 s0 = decimalpoint_cache;
44@@ -155,7 +158,7 @@ strtod
45 #else /*}{*/
eb1cde05 46 #define fpi1 fpi
34e8f829 47 #endif /*}}*/
eb1cde05
A
48- switch((i = gethex(&s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) {
49+ switch((i = gethex(&s, &fpi1, &exp, &bb, sign, loc)) & STRTOG_Retmask) {
3d9156a7
A
50 case STRTOG_NoNumber:
51 s = s00;
52 sign = 0;
34e8f829 53@@ -545,7 +548,11 @@ strtod
224c7076
A
54
55 /* Put digits into bd: true value = bd * 10^e */
56
57- bd0 = s2b(s0, nd0, nd, y);
58+#ifdef USE_LOCALE
34e8f829 59+ bd0 = s2b(s0, nd0, nd, y, strlen(decimalpoint));
224c7076
A
60+#else
61+ bd0 = s2b(s0, nd0, nd, y, 1);
62+#endif
63
64 for(;;) {
65 bd = Balloc(bd0->k);
34e8f829 66@@ -992,7 +999,7 @@ strtod
224c7076
A
67 dval(rv) *= dval(rv0);
68 #ifndef NO_ERRNO
69 /* try to avoid the bug of testing an 8087 register value */
34e8f829
A
70-#ifdef IEEE_Arith
71+#if defined(IEEE_Arith) && __DARWIN_UNIX03
72 if (!(word0(rv) & Exp_mask))
73 #else
224c7076 74 if (word0(rv) == 0 && word1(rv) == 0)
34e8f829 75@@ -1020,3 +1027,13 @@ strtod
3d9156a7
A
76 return sign ? -dval(rv) : dval(rv);
77 }
78
79+ double
80+strtod
81+#ifdef KR_headers
82+ (s00, se) CONST char *s00; char **se;
83+#else
84+ (CONST char *s00, char **se)
85+#endif
86+{
87+ return strtod_l(s00, se, __current_locale());
88+}