1 --- gdtoa-hexnan.c.orig 2008-03-15 10:08:33.000000000 -0700
2 +++ gdtoa-hexnan.c 2008-08-30 17:55:23.000000000 -0700
3 @@ -30,6 +30,7 @@ THIS SOFTWARE.
4 * with " at " changed at "@" and " dot " changed to "."). */
11 @@ -57,94 +58,53 @@ hexnan(sp, fpi, x0)
12 hexnan( CONST char **sp, FPI *fpi, ULong *x0)
15 - ULong c, h, *x, *x1, *xe;
19 - int havedig, hd0, i, nbits;
24 - x = x0 + (nbits >> kshift);
29 - havedig = hd0 = i = 0;
30 + if (sp == NULL || *sp == NULL || **sp != '(')
33 - /* allow optional initial 0x or 0X */
34 - while((c = *(CONST unsigned char*)(s+1)) && c <= ' ')
36 - if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')
37 - && *(CONST unsigned char*)(s+3) > ' ')
39 - while(c = *(CONST unsigned char*)++s) {
40 - if (!(h = hexdig[c])) {
42 - if (hd0 < havedig) {
43 - if (x < x1 && i < 8)
54 - while(*(CONST unsigned char*)(s+1) <= ' ')
56 - if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')
57 - && *(CONST unsigned char*)(s+3) > ' ')
61 - if (/*(*/ c == ')' && havedig) {
65 -#ifndef GDTOA_NON_PEDANTIC_NANCHECK
67 - if (/*(*/ c == ')') {
73 + if ((cp = strchr(s + 1, ')')) == NULL) {
79 + cp = alloca(len + 1);
90 - *x = (*x << 4) | h & 0xf;
91 + strlcpy(cp, s + 1, len + 1);
96 - if (x < x1 && i < 8)
104 + nbits = fpi->nbits;
106 + if (nbits == 52) { /* double */
107 + union IEEEd2bits u;
109 + x0[1] = u.bits.manh;
110 + x0[0] = u.bits.manl;
113 - /* truncate high-order word if necessary */
114 - if ( (i = nbits & (ULbits-1)) !=0)
115 - *xe &= ((ULong)0xffffffff) >> (ULbits - i);
116 + else if (nbits < 52) { /* float */
117 + union IEEEf2bits u;
119 + x0[0] = u.bits.man;
121 - for(x1 = xe;; --x1) {
128 + else { /* long double */
129 + union IEEEl2bits u;
131 +#if defined(__ppc__) || defined(__ppc64__)
132 + x0[3] = (ULong)(u.bits.manh >> 44);
133 + x0[2] = (ULong)(u.bits.manh >> 12);
134 + x0[1] = ((ULong)u.bits.manh & 0xfff) << 20 | (ULong)(u.bits.manl >> 32);
135 + x0[0] = (ULong)u.bits.manl;
136 +#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__)
137 + x0[1] = (ULong)u.bits.manh;
138 + x0[0] = (ULong)u.bits.manl;
140 +#error unsupported architecture
144 return STRTOG_NaNbits;