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, Mar 03, 2009 at 11:07:54AM -0500, Christos Zoulas wrote:
> On Mar 3,  3:13pm, njoly%pasteur.fr@localhost (Nicolas Joly) wrote:
> -- Subject: Re: build failure (alpha-current): floating point exception 8
[...]
> | Are they portable enough for host tool ? My Tru64 do miss isinf().
> 
> 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.

I've been thinking a little more about this, and the attached patch
should do the trick, at least, for the host tool part. If this ok, we
can handle INF the same way ...

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.
Index: dist/nawk/lib.c
===================================================================
RCS file: /pub/NetBSD-CVS/src/dist/nawk/lib.c,v
retrieving revision 1.15
diff -u -p -r1.15 lib.c
--- dist/nawk/lib.c     1 Mar 2009 23:30:52 -0000       1.15
+++ dist/nawk/lib.c     10 Mar 2009 13:10:23 -0000
@@ -710,7 +710,9 @@ int is_number(const char *s)
        char *ep;
        errno = 0;
        r = strtod(s, &ep);
-       if (ep == s || r == HUGE_VAL || errno == ERANGE)
+       if (ep == s || errno == ERANGE)
+               return 0;
+       if (ep - s >= 3 && strncasecmp(ep - 3, "nan", 3) == 0)
                return 0;
        while (*ep == ' ' || *ep == '\t' || *ep == '\n')
                ep++;


Home | Main Index | Thread Index | Old Index