X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/eb1cde05bb040f65c511ae4fa854abf1628afdf2..51282358e8fdbfc483c0c34e7eae9b89b51f2570:/gdtoa/FreeBSD/gdtoa-strtodg.c.patch diff --git a/gdtoa/FreeBSD/gdtoa-strtodg.c.patch b/gdtoa/FreeBSD/gdtoa-strtodg.c.patch index d60d887..263b91c 100644 --- a/gdtoa/FreeBSD/gdtoa-strtodg.c.patch +++ b/gdtoa/FreeBSD/gdtoa-strtodg.c.patch @@ -1,6 +1,6 @@ ---- gdtoa-strtodg.c.orig 2005-10-08 11:33:23.000000000 -0700 -+++ gdtoa-strtodg.c 2005-10-08 11:40:57.000000000 -0700 -@@ -29,6 +29,8 @@ +--- gdtoa-strtodg.c.orig 2008-10-28 12:23:36.000000000 -0700 ++++ gdtoa-strtodg.c 2008-10-28 12:34:18.000000000 -0700 +@@ -29,13 +29,29 @@ THIS SOFTWARE. /* Please send bug reports to David M. Gay (dmg at acm dot org, * with " at " changed at "@" and " dot " changed to "."). */ @@ -9,7 +9,61 @@ #include "gdtoaimp.h" #ifdef USE_LOCALE -@@ -316,10 +318,10 @@ + #include "locale.h" + #endif + +- static CONST int ++#define fivesbits __fivesbits_D2A ++#define all_on __all_on_D2A ++#define set_ones __set_ones_D2A ++#define rvOK __rvOK_D2A ++#define mantbits __mantbits_D2A ++ ++#ifdef BUILDING_VARIANT ++extern CONST int fivesbits[]; ++int all_on(Bigint *b, int n); ++Bigint *set_ones(Bigint *b, int n); ++int rvOK(double d, FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv); ++int mantbits(double d); ++#else /* !BUILDING_VARIANT */ ++ ++ __private_extern__ CONST int + fivesbits[] = { 0, 3, 5, 7, 10, 12, 14, 17, 19, 21, + 24, 26, 28, 31, 33, 35, 38, 40, 42, 45, + 47, 49, 52 +@@ -121,7 +137,7 @@ decrement(Bigint *b) + #endif + } + +- static int ++ __private_extern__ int + #ifdef KR_headers + all_on(b, n) Bigint *b; int n; + #else +@@ -168,7 +184,7 @@ set_ones(Bigint *b, int n) + return b; + } + +- static int ++ __private_extern__ int + rvOK + #ifdef KR_headers + (d, fpi, exp, bits, exact, rd, irv) +@@ -289,7 +305,7 @@ rvOK + return rv; + } + +- static int ++ __private_extern__ int + #ifdef KR_headers + mantbits(d) double d; + #else +@@ -312,13 +328,15 @@ mantbits(double d) + return P - 32 - lo0bits(&L); + } + ++#endif /* BUILDING_VARIANT */ ++ int strtodg #ifdef KR_headers @@ -23,7 +77,24 @@ #endif { int abe, abits, asub; -@@ -367,7 +369,7 @@ +@@ -332,13 +350,14 @@ strtodg + ULong *b, *be, y, z; + Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0; + #ifdef USE_LOCALE ++ NORMALIZE_LOCALE(loc) + #ifdef NO_LOCALE_CACHE +- char *decimalpoint = localeconv()->decimal_point; ++ char *decimalpoint = localeconv_l(loc)->decimal_point; + #else + char *decimalpoint; + static char *decimalpoint_cache; + if (!(s0 = decimalpoint_cache)) { +- s0 = localeconv()->decimal_point; ++ s0 = localeconv_l(loc)->decimal_point; + if ((decimalpoint_cache = (char*)malloc(strlen(s0) + 1))) { + strcpy(decimalpoint_cache, s0); + s0 = decimalpoint_cache; +@@ -382,7 +401,7 @@ strtodg switch(s[1]) { case 'x': case 'X': @@ -32,24 +103,45 @@ if (irv == STRTOG_NoNumber) { s = s00; sign = 0; -@@ -389,8 +391,9 @@ - else if (nd < 16) - z = 10*z + c - '0'; - nd0 = nd; -+ NORMALIZE_LOCALE(loc); - #ifdef USE_LOCALE -- if (c == *localeconv()->decimal_point) -+ if (c == *localeconv_l(loc)->decimal_point) - #else - if (c == '.') - #endif -@@ -668,6 +671,9 @@ +@@ -687,6 +706,10 @@ strtodg rvb->x[0] = 0; *exp = emin; irv = STRTOG_Underflow | STRTOG_Inexlo; -+#ifndef NO_ERRNO ++/* When __DARWIN_UNIX03 is set, we don't need this (errno is set later) */ ++#if !defined(NO_ERRNO) && !__DARWIN_UNIX03 + errno = ERANGE; +#endif goto ret; } rvb->x[0] = rvb->wds = rvbits = 1; +@@ -703,7 +726,11 @@ strtodg + + /* Put digits into bd: true value = bd * 10^e */ + +- bd0 = s2b(s0, nd0, nd, y); ++#ifdef USE_LOCALE ++ bd0 = s2b(s0, nd0, nd, y, strlen(decimalpoint)); ++#else ++ bd0 = s2b(s0, nd0, nd, y, 1); ++#endif + + for(;;) { + bd = Balloc(bd0->k); +@@ -1032,7 +1059,7 @@ strtodg + if (sudden_underflow) { + rvb->wds = 0; + irv = STRTOG_Underflow | STRTOG_Inexlo; +-#ifndef NO_ERRNO ++#if !defined(NO_ERRNO) && __DARWIN_UNIX03 + errno = ERANGE; + #endif + } +@@ -1041,7 +1068,7 @@ strtodg + (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero); + if (irv & STRTOG_Inexact) { + irv |= STRTOG_Underflow; +-#ifndef NO_ERRNO ++#if !defined(NO_ERRNO) && __DARWIN_UNIX03 + errno = ERANGE; + #endif + }