diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2015-04-16 12:43:07 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2015-04-16 12:43:07 -0400 |
commit | e934ad609d3639152324a4211857d87f228cf938 (patch) | |
tree | 0056c5823269810f85bf5ef547f3be5fca4c5c3b /node.c | |
parent | 09ca6ca91db4fd691c4107419c5a4d3f99ae569e (diff) | |
download | egawk-e934ad609d3639152324a4211857d87f228cf938.tar.gz egawk-e934ad609d3639152324a4211857d87f228cf938.tar.bz2 egawk-e934ad609d3639152324a4211857d87f228cf938.zip |
When strtod sets errno, force the numeric value to zero.
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; |