In setfval(), ensure that arithmetic never yields a negative zero

result.  Now {echo | awk '{print -1 * 0}'} prints "0" instead of "-0".

Fixes PR 36831.  Discussed in tech-userlevel.
This commit is contained in:
apb 2007-08-28 15:23:13 +00:00
parent 2b4f2c9caf
commit 22d0439909
1 changed files with 1 additions and 0 deletions

1
dist/nawk/tran.c vendored
View File

@ -285,6 +285,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f) /* set float val of a Cell */
{
int fldno;
f += 0.0; /* normalise negative zero to positive zero */
if ((vp->tval & (NUM | STR)) == 0)
funnyvar(vp, "assign to");
if (isfld(vp)) {