Don't try so hard to convert strings into numbers. Results in bogus conversions like: % awk 'BEGIN { print "nanotime" + 123 }' nan % awk 'BEGIN { print "microtime" + 123 }' 123 % awk 'BEGIN { print "inftime" + 123 }' infdiff -r1.11 -r1.12 src/external/historical/nawk/dist/tran.c
(christos)
--- src/external/historical/nawk/dist/tran.c 2020/02/18 21:12:21 1.11
+++ src/external/historical/nawk/dist/tran.c 2020/08/31 23:36:58 1.12
@@ -404,9 +404,12 @@
else if (isrec(vp) && !donerec)
recbld();
if (!isnum(vp)) { /* not a number */
- vp->fval = atof(vp->sval); /* best guess */
- if (is_number(vp->sval) && !(vp->tval&CON))
+ if (is_number(vp->sval) && !(vp->tval&CON)) {
+ vp->fval = atof(vp->sval); /* best guess */
vp->tval |= NUM; /* make NUM only sparingly */
+ } else {
+ vp->fval = 0;
+ }
}
dprintf( ("getfval %p: %s = %g, t=%o\n",
(void*)vp, NN(vp->nval), vp->fval, vp->tval) );