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
This commit is contained in:
parent
fa197dbf76
commit
8871000030
|
@ -404,9 +404,12 @@ Awkfloat getfval(Cell *vp) /* get float val of a Cell */
|
|||
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) );
|
||||
|
|
Loading…
Reference in New Issue