Fix a bug converting a variable from the numeric type to a string.

PR:		bin/104795
MFC after:	3 days
This commit is contained in:
Ruslan Ermilov 2006-10-25 21:23:20 +00:00
parent 4e52d86822
commit 324ef9892d
2 changed files with 23 additions and 1 deletions

View File

@ -29,7 +29,7 @@ CLEANFILES+= nawk.1
nawk.1: awk.1
cat ${.ALLSRC} > ${.TARGET}
.for f in b.c lib.c main.c run.c
.for f in b.c lib.c main.c run.c tran.c
${f}: ${AWKSRC}/${f} ${.CURDIR}/${f}.diff
patch -s -b .orig -o ${.TARGET} < ${.CURDIR}/${f}.diff ${AWKSRC}/${f}
CLEANFILES+= ${f}

22
usr.bin/awk/tran.c.diff Normal file
View File

@ -0,0 +1,22 @@
$FreeBSD$
Index: tran.c
===================================================================
RCS file: /home/ncvs/src/contrib/one-true-awk/tran.c,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 tran.c
--- tran.c 16 May 2005 19:11:35 -0000 1.1.1.4
+++ tran.c 25 Oct 2006 20:56:18 -0000
@@ -332,10 +332,10 @@ char *setsval(Cell *vp, const char *s) /
donerec = 1;
}
t = tostring(s); /* in case it's self-assign */
- vp->tval &= ~NUM;
- vp->tval |= STR;
if (freeable(vp))
xfree(vp->sval);
+ vp->tval &= ~NUM;
+ vp->tval |= STR;
vp->tval &= ~DONTFREE;
dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );