aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--node.c15
2 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a6d7b6e4..c37adc71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-16 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * node.c (r_force_number): If strtod sets errno, then force the
+ numeric value in node->numbr to zero. For subnormal values, strtod
+ sets errno but does not return zero, and we don't want to retain
+ those subnormal values.
+
2015-04-16 Arnold D. Robbins <arnold@skeeve.com>
* configure.ac: Updated by autoupdate.
diff --git a/node.c b/node.c
index a5e06cd3..b9c751dd 100644
--- a/node.c
+++ b/node.c
@@ -138,11 +138,20 @@ r_force_number(NODE *n)
ptr++;
*cpend = save;
finish:
- if (errno == 0 && ptr == cpend) {
- n->flags |= newflags;
- n->flags |= NUMCUR;
+ if (errno == 0) {
+ if (ptr == cpend) {
+ n->flags |= newflags;
+ n->flags |= NUMCUR;
+ }
+ /* else keep the leading numeric value without updating flags */
} else {
errno = 0;
+ /*
+ * N.B. For subnormal values, strtod may return the
+ * floating-point representation while setting errno to ERANGE.
+ * We force the numeric value to 0 in such cases.
+ */
+ n->numbr = 0;
}
return n;