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
On Tue, 3 Mar 2009, Christos Zoulas wrote:
> 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;
it looks to me as if this was doing the wrong thing in the first place,
since HUGE_VAL is a valid number but not the only potentially invalid
result? The actual test should be
(errno == ERANGE && (r == HUGE_VAL || r == -HUGE_VAL || r == 0))
but since the original code was failing whenever (errno == ERANGE),
perhaps you could forget the HUGE_VAL stuff altogether and hope the
implementation never sets that unless it found an error?
iain
Home |
Main Index |
Thread Index |
Old Index