Author: rblasch
Date: Sat Dec 20 10:48:30 2008
New Revision: 34150
Modified:
branches/vc9/src/string.c
Log:
Handle NaN in string_to_num.
Modified: branches/vc9/src/string.c
==============================================================================
--- branches/vc9/src/string.c (original)
+++ branches/vc9/src/string.c Sat Dec 20 10:48:30 2008
@@ -2053,7 +2053,20 @@
while (isspace((unsigned char)*p))
p++;
- f = atof(p);
+ /* Handle NaN strings. Expand this test to handle all defined NaN
+ * values, if necessary. */
+ if (strcmp(p, "NaN") == 0)
+ {
+ /* There seems to be no NaN constant, and compilers detect
+ * constant '0.0/0.0'. */
+ FLOATVAL nan = 0.0;
+ nan /= 0.0;
+ f = nan;
+ }
+ else
+ {
+ f = atof(p);
+ }
/* Not all atof()s return -0 from "-0" */
if (*p == '-' && FLOAT_IS_ZERO(f))