Module Name: src Committed By: christos Date: Mon Aug 31 23:36:58 UTC 2020
Modified Files: src/external/historical/nawk/dist: tran.c Log Message: 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 }' inf To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/historical/nawk/dist/tran.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/historical/nawk/dist/tran.c diff -u src/external/historical/nawk/dist/tran.c:1.11 src/external/historical/nawk/dist/tran.c:1.12 --- src/external/historical/nawk/dist/tran.c:1.11 Tue Feb 18 16:12:21 2020 +++ src/external/historical/nawk/dist/tran.c Mon Aug 31 19:36:58 2020 @@ -404,9 +404,12 @@ Awkfloat getfval(Cell *vp) /* get float 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) );