gdtoa_strtopx.c.patch [plain text]
--- gdtoa_strtopx.c.orig 2007-04-03 12:19:28.000000000 -0700
+++ gdtoa_strtopx.c 2007-04-06 12:52:09.000000000 -0700
@@ -29,6 +29,8 @@
/* Please send bug reports to David M. Gay (dmg at acm dot org,
* with " at " changed at "@" and " dot " changed to "."). */
+#include "xlocale_private.h"
+
#include "gdtoaimp.h"
#undef _0
@@ -53,20 +55,34 @@
int
#ifdef KR_headers
-strtopx(s, sp, V) CONST char *s; char **sp; void *V;
+strtopx(s, sp, V, loc) CONST char *s; char **sp; void *V; locale_t loc;
#else
-strtopx(CONST char *s, char **sp, void *V)
+strtopx(CONST char *s, char **sp, void *V, locale_t loc)
#endif
{
- static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+ static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
ULong bits[2];
Long exp;
int k;
UShort *L = (UShort*)V;
+ FPI *fpi = &fpi0, fpi1;
+#ifdef Honor_FLT_ROUNDS
+ int rounding = Flt_Rounds;
+#endif
- k = strtodg(s, sp, &fpi, &exp, bits);
+#ifdef Honor_FLT_ROUNDS
+ if (rounding != fpi0.rounding) {
+ fpi1 = fpi0; /* for thread safety */
+ fpi1.rounding = rounding;
+ fpi = &fpi1;
+ }
+#endif /* Honor_FLT_ROUNDS */
+ k = strtodg(s, sp, fpi, &exp, bits, loc);
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
+ L[0] = L[1] = L[2] = L[3] = L[4] = 0;
+ return k; // avoid setting sign
+
case STRTOG_Zero:
L[0] = L[1] = L[2] = L[3] = L[4] = 0;
break;
@@ -87,7 +103,8 @@
case STRTOG_Infinite:
L[_0] = 0x7fff;
- L[_1] = L[_2] = L[_3] = L[_4] = 0;
+ L[_1] = 0x8000; /* 4306392: to match gcc */
+ L[_2] = L[_3] = L[_4] = 0;
break;
case STRTOG_NaN: