Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | From 0562b040fa17f1722ba2b3096067b45d0582ca53 Mon Sep 17 00:00:00 2001 |
| 2 | From: Paul Eggert <eggert@cs.ucla.edu> |
| 3 | Date: Mon, 11 Mar 2019 16:40:29 -0700 |
| 4 | Subject: [PATCH] strtod: fix clash with strtold |
| 5 | |
| 6 | Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). |
| 7 | * lib/strtod.c (compute_minus_zero, minus_zero): |
| 8 | Simplify by remving the macro / external variable, |
| 9 | and having just a function. User changed. This avoids |
| 10 | the need for an external variable that might clash. |
| 11 | |
| 12 | Upstream-Status: Backport [rhel5] |
| 13 | |
| 14 | Signed-off-by: Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com> |
| 15 | |
| 16 | --- |
| 17 | ChangeLog | 9 +++++++++ |
| 18 | lib/strtod.c | 11 +++++------ |
| 19 | 2 files changed, 14 insertions(+), 6 deletions(-) |
| 20 | |
| 21 | diff --git a/lib/strtod.c b/lib/strtod.c |
| 22 | index b9eaa51b4..69b1564e1 100644 |
| 23 | --- a/lib/strtod.c |
| 24 | +++ b/lib/strtod.c |
| 25 | @@ -294,16 +294,15 @@ parse_number (const char *nptr, |
| 26 | ICC 10.0 has a bug when optimizing the expression -zero. |
| 27 | The expression -MIN * MIN does not work when cross-compiling |
| 28 | to PowerPC on Mac OS X 10.5. */ |
| 29 | -#if defined __hpux || defined __sgi || defined __ICC |
| 30 | static DOUBLE |
| 31 | -compute_minus_zero (void) |
| 32 | +minus_zero (void) |
| 33 | { |
| 34 | +#if defined __hpux || defined __sgi || defined __ICC |
| 35 | return -MIN * MIN; |
| 36 | -} |
| 37 | -# define minus_zero compute_minus_zero () |
| 38 | #else |
| 39 | -DOUBLE minus_zero = -0.0; |
| 40 | + return -0.0; |
| 41 | #endif |
| 42 | +} |
| 43 | |
| 44 | /* Convert NPTR to a DOUBLE. If ENDPTR is not NULL, a pointer to the |
| 45 | character after the last one used in the number is put in *ENDPTR. */ |
| 46 | @@ -479,6 +478,6 @@ STRTOD (const char *nptr, char **endptr) |
| 47 | /* Special case -0.0, since at least ICC miscompiles negation. We |
| 48 | can't use copysign(), as that drags in -lm on some platforms. */ |
| 49 | if (!num && negative) |
| 50 | - return minus_zero; |
| 51 | + return minus_zero (); |
| 52 | return negative ? -num : num; |
| 53 | } |
| 54 | -- |
| 55 | 2.20.1 |
| 56 | |