Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: build failure (alpha-current): floating point exception 8
In article <20090303160754.2BEC25654F%rebar.astron.com@localhost>,
Christos Zoulas <christos%zoulas.com@localhost> wrote:
>Ouch. These are IEEE Std 1003.1-2001 functions, and are extensions to the ISO C
>standard. Strtod is supposed so return HUGE_VAL if the value is going to
>overflow. HUGE_VAL in term is defined to be infinity in our implementation,
>but is that guaranteed to be that way? I am not sure. Anyway, it seems that
>inf == inf traps on non-ieee hardware, so we need to take care of it somehow.
>perhaps using memcmp()? I really don't want to longjmp out of a signal handler
>to solve this.
Does this work?
Index: lib.c
===================================================================
RCS file: /cvsroot/src/dist/nawk/lib.c,v
retrieving revision 1.15
diff -u -u -r1.15 lib.c
--- lib.c 1 Mar 2009 23:30:52 -0000 1.15
+++ lib.c 3 Mar 2009 17:06:02 -0000
@@ -706,11 +706,11 @@
#include <math.h>
int is_number(const char *s)
{
- double r;
+ double r, hv = HUGE_VAL;
char *ep;
errno = 0;
r = strtod(s, &ep);
- if (ep == s || r == HUGE_VAL || errno == ERANGE)
+ if (ep == s || memcmp(&r, &hv, sizeof(hv)) == 0 || errno == ERANGE)
return 0;
while (*ep == ' ' || *ep == '\t' || *ep == '\n')
ep++;
Home |
Main Index |
Thread Index |
Old Index