fix bug introduced in rev. 1.3: need to set the string before

converting it into a numerical value, otherwise we might get junk or crash
This commit is contained in:
drochner 2011-01-20 21:26:20 +00:00
parent 7264233c30
commit 5a190aa53b
1 changed files with 2 additions and 1 deletions

View File

@ -353,6 +353,7 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
vp->sval = t;
if (&vp->fval == NF) {
donerec = 0; /* mark $0 invalid */
f = getfval(vp);
@ -360,7 +361,7 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
dprintf( ("setting NF to %g\n", f) );
}
return(vp->sval = t);
return(vp->sval);
}
Awkfloat getfval(Cell *vp) /* get float val of a Cell */