[net.bugs.4bsd] 4.2bsd awk bug

shannon@sun.uucp (Bill Shannon) (12/09/83)

Index:	bin/awk 4.2BSD [Fix]

Description:
	Awk doesn't allow you to replace fields.  This bug was
	introduced when the indirect-through-zero bugs in awk
	were fixed.
Repeat-By:
	The following command
		echo 1 2 3 | awk '{$1 = NF; print}'
	should give
		3 2 3
	if it works.
	If it's broken it will give
		1 2 3
Fix:
	Install the following fix:

	--- awk.def
	7a8
	> #define	isnull(x)	((x) == EMPTY || (x) == NULL)

	--- tran.c
	139c139
	< 	if ((vp->tval & FLD) && vp->nval == 0)
	---
	> 	if ((vp->tval & FLD) && isnull(vp->nval))
	154c154
	< 	if ((vp->tval & FLD) && vp->nval == 0)
	---
	> 	if ((vp->tval & FLD) && isnull(vp->nval))