diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/stdlib.h | 1 | ||||
-rw-r--r-- | stdlib/strtod.c | 5 | ||||
-rw-r--r-- | stdlib/strtof.c | 2 | ||||
-rw-r--r-- | stdlib/strtold.c | 4 |
4 files changed, 10 insertions, 2 deletions
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 6fad54eaf6..cc86d38361 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -437,6 +437,7 @@ extern void unsetenv __P ((__const char *__name)); /* The `clearenv' was planned to be added to POSIX.1 but probably never made it. Nevertheless the POSIX.9 standard (POSIX bindings for Fortran 77) requires this function. */ +extern int __clearenv __P ((void)); extern int clearenv __P ((void)); #endif diff --git a/stdlib/strtod.c b/stdlib/strtod.c index 760ecd26a7..e0c9b08031 100644 --- a/stdlib/strtod.c +++ b/stdlib/strtod.c @@ -34,6 +34,8 @@ # define SET_MANTISSA(flt, mant) \ do { union ieee754_double u; \ u.d = (flt); \ + if ((mant & 0xfffffffffffffULL) == 0) \ + mant = 0x8000000000000ULL; \ u.ieee.mantissa0 = ((mant) >> 32) & 0xfffff; \ u.ieee.mantissa1 = (mant) & 0xffffffff; \ } while (0) @@ -627,7 +629,8 @@ INTERNAL (STRTOF) (nptr, endptr, group) expp = cp; /* Read exponent. */ - if (TOLOWER (c) == (base == 16 ? L_('p') : L_('e'))) + if ((base == 16 && TOLOWER (c) == L_('p')) + || (base != 16 && TOLOWER (c) == L_('e'))) { int exp_negative = 0; diff --git a/stdlib/strtof.c b/stdlib/strtof.c index 0a0046daf9..026b5eead3 100644 --- a/stdlib/strtof.c +++ b/stdlib/strtof.c @@ -9,6 +9,8 @@ #define SET_MANTISSA(flt, mant) \ do { union ieee754_float u; \ u.f = (flt); \ + if ((mant & 0x7fffff) == 0) \ + mant = 0x400000; \ u.ieee.mantissa = (mant) & 0x7fffff; \ (flt) = u.f; \ } while (0) diff --git a/stdlib/strtold.c b/stdlib/strtold.c index 1dc0ac37c2..9747232ef2 100644 --- a/stdlib/strtold.c +++ b/stdlib/strtold.c @@ -9,7 +9,9 @@ #define SET_MANTISSA(flt, mant) \ do { union ieee854_long_double u; \ u.d = (flt); \ - u.ieee.mantissa0 = ((mant) >> 32) & 0x7fffffff; \ + if ((mant & 0x7fffffffffffffffULL) == 0) \ + mant = 0x4000000000000000ULL; \ + u.ieee.mantissa0 = (((mant) >> 32) & 0x7fffffff) | 0x80000000; \ u.ieee.mantissa1 = (mant) & 0xffffffff; \ (flt) = u.d; \ } while (0) |