Mercurial > gnulib
comparison lib/strtod.c @ 40231:9b3c79fdfe0b
strtod: fix clash with strtold
Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817).
* lib/strtod.c (compute_minus_zero, minus_zero):
Simplify by remving the macro / external variable,
and having just a function. User changed. This avoids
the need for an external variable that might clash.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 11 Mar 2019 16:40:29 -0700 |
parents | 31ab89a208b9 |
children |
comparison
equal
deleted
inserted
replaced
40230:25f5a9e7e5fb | 40231:9b3c79fdfe0b |
---|---|
292 | 292 |
293 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. | 293 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. |
294 ICC 10.0 has a bug when optimizing the expression -zero. | 294 ICC 10.0 has a bug when optimizing the expression -zero. |
295 The expression -MIN * MIN does not work when cross-compiling | 295 The expression -MIN * MIN does not work when cross-compiling |
296 to PowerPC on Mac OS X 10.5. */ | 296 to PowerPC on Mac OS X 10.5. */ |
297 static DOUBLE | |
298 minus_zero (void) | |
299 { | |
297 #if defined __hpux || defined __sgi || defined __ICC | 300 #if defined __hpux || defined __sgi || defined __ICC |
298 static DOUBLE | |
299 compute_minus_zero (void) | |
300 { | |
301 return -MIN * MIN; | 301 return -MIN * MIN; |
302 } | |
303 # define minus_zero compute_minus_zero () | |
304 #else | 302 #else |
305 DOUBLE minus_zero = -0.0; | 303 return -0.0; |
306 #endif | 304 #endif |
305 } | |
307 | 306 |
308 /* Convert NPTR to a DOUBLE. If ENDPTR is not NULL, a pointer to the | 307 /* Convert NPTR to a DOUBLE. If ENDPTR is not NULL, a pointer to the |
309 character after the last one used in the number is put in *ENDPTR. */ | 308 character after the last one used in the number is put in *ENDPTR. */ |
310 DOUBLE | 309 DOUBLE |
311 STRTOD (const char *nptr, char **endptr) | 310 STRTOD (const char *nptr, char **endptr) |
477 if (endptr != NULL) | 476 if (endptr != NULL) |
478 *endptr = (char *) s; | 477 *endptr = (char *) s; |
479 /* Special case -0.0, since at least ICC miscompiles negation. We | 478 /* Special case -0.0, since at least ICC miscompiles negation. We |
480 can't use copysign(), as that drags in -lm on some platforms. */ | 479 can't use copysign(), as that drags in -lm on some platforms. */ |
481 if (!num && negative) | 480 if (!num && negative) |
482 return minus_zero; | 481 return minus_zero (); |
483 return negative ? -num : num; | 482 return negative ? -num : num; |
484 } | 483 } |