diff options
author | das <das@FreeBSD.org> | 2007-12-16 21:14:33 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2007-12-16 21:14:33 +0000 |
commit | 70cdf6a57447192c3b77090ed112c732882f95f3 (patch) | |
tree | 5f9e7a4fd4b4e74b456608617e283e71285fad2f /contrib/gdtoa/strtof.c | |
parent | b2367c2d0b77fb617f31b9fafae0c52dc8ecf89e (diff) | |
download | FreeBSD-src-70cdf6a57447192c3b77090ed112c732882f95f3.zip FreeBSD-src-70cdf6a57447192c3b77090ed112c732882f95f3.tar.gz |
Fix strto{f,d,ld}() so they don't return signaling NaNs. C99
says they are never supposed to, and the fact that they did could
cause apps that run with unmasked FP exceptions to SIGFPE after a
scanf() or strtod(). The vendor stated that he will not be fixing
this, citing portability concerns.
Diffstat (limited to 'contrib/gdtoa/strtof.c')
-rw-r--r-- | contrib/gdtoa/strtof.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/gdtoa/strtof.c b/contrib/gdtoa/strtof.c index 21bc6c1..58486f2 100644 --- a/contrib/gdtoa/strtof.c +++ b/contrib/gdtoa/strtof.c @@ -29,6 +29,8 @@ THIS SOFTWARE. /* Please send bug reports to David M. Gay (dmg at acm dot org, * with " at " changed at "@" and " dot " changed to "."). */ +/* $FreeBSD$ */ + #include "gdtoaimp.h" float @@ -52,10 +54,14 @@ strtof(CONST char *s, char **sp) break; case STRTOG_Normal: - case STRTOG_NaNbits: u.L[0] = bits[0] & 0x7fffff | exp + 0x7f + 23 << 23; break; + case STRTOG_NaNbits: + /* FreeBSD local: always return a quiet NaN */ + u.L[0] = bits[0] | 0x7fc00000; + break; + case STRTOG_Denormal: u.L[0] = bits[0]; break; |