]> git.saurik.com Git - apple/libc.git/blob - gdtoa/FreeBSD/gdtoa-strtof.c.patch
Libc-498.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / gdtoa-strtof.c.patch
1 --- gdtoa-strtof.c.orig 2007-04-03 12:19:28.000000000 -0700
2 +++ gdtoa-strtof.c 2007-04-06 12:52:45.000000000 -0700
3 @@ -29,24 +29,41 @@
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 float
12 #ifdef KR_headers
13 -strtof(s, sp) CONST char *s; char **sp;
14 +strtof_l(s, sp, loc) CONST char *s; char **sp; locale_t loc;
15 #else
16 -strtof(CONST char *s, char **sp)
17 +strtof_l(CONST char *s, char **sp, locale_t loc)
18 #endif
19 {
20 - static FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
21 + static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
22 ULong bits[1];
23 Long exp;
24 int k;
25 union { ULong L[1]; float f; } u;
26 + FPI *fpi = &fpi0, fpi1;
27 +#ifdef Honor_FLT_ROUNDS
28 + int rounding = Flt_Rounds;
29 +#endif
30
31 - k = strtodg(s, sp, &fpi, &exp, bits);
32 + NORMALIZE_LOCALE(loc);
33 +#ifdef Honor_FLT_ROUNDS
34 + if (rounding != fpi0.rounding) {
35 + fpi1 = fpi0; /* for thread safety */
36 + fpi1.rounding = rounding;
37 + fpi = &fpi1;
38 + }
39 +#endif /* Honor_FLT_ROUNDS */
40 + k = strtodg(s, sp, fpi, &exp, bits, loc);
41 switch(k & STRTOG_Retmask) {
42 case STRTOG_NoNumber:
43 + u.L[0] = 0;
44 + return u.f; // avoid setting sign
45 +
46 case STRTOG_Zero:
47 u.L[0] = 0;
48 break;
49 @@ -71,3 +88,13 @@
50 u.L[0] |= 0x80000000L;
51 return u.f;
52 }
53 +
54 + float
55 +#ifdef KR_headers
56 +strtof(s, sp) CONST char *s; char **sp;
57 +#else
58 +strtof(CONST char *s, char **sp)
59 +#endif
60 +{
61 + return strtof_l(s, sp, __current_locale());
62 +}