Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!watmath!clyde!burl!hou3c!hocda!houxm!houxz!vax135!floyd!cmcl2!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.bugs.4bsd Subject: Re: 4.2 awk difference Message-ID: <2004@rlgvax.UUCP> Date: Sat, 9-Jun-84 04:07:29 EDT Article-I.D.: rlgvax.2004 Posted: Sat Jun 9 04:07:29 1984 Date-Received: Sun, 10-Jun-84 01:06:06 EDT References: <502@rocksvax.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 76 > DESCRIPTION: > 4.2 awk fails to modify $0 when one of $1, $2, ... is modified. The awk > distributed with 4.1 handles the case below as documented. > POSSIBLE SOLUTION: > The action of 'print $0' can be performed by 'for (i=1;i<=NF;i++) > printf "%s " $i;'. Thus one still has the full capability of the old awk. > Since the documentation is slightly unclear about $0 when changed as a > side-effect it might be better to just delete this feature from awk. In other > words simply change the documentation. If I remember correctly, this was not a feature, but a bug. It was introduced when "awk" was changed not to try dereferencing NULL pointers. Bill Shannon posted a fix; here's the changes to "awk.def" and "tran.c": *** /tmp/,RCSt1018196 Sat Jun 9 04:03:41 1984 --- awk.def Tue May 22 21:07:58 1984 *************** *** 5,10 #define xfree(a) { if(a!=NULL) { yfree(a); a=NULL;} } #define strfree(a) { if(a!=NULL && a!=EMPTY) { yfree(a);} a=EMPTY; } #define yfree free #ifdef DEBUG # define dprintf if(dbg)printf #else --- 5,11 ----- #define xfree(a) { if(a!=NULL) { yfree(a); a=NULL;} } #define strfree(a) { if(a!=NULL && a!=EMPTY) { yfree(a);} a=EMPTY; } #define yfree free + #define isnull(x) ((x) == EMPTY || (x) == NULL) #ifdef DEBUG # define dprintf if(dbg)printf #else *** /tmp/,RCSt1018201 Sat Jun 9 04:03:54 1984 --- tran.c Tue May 22 21:11:06 1984 *************** *** 136,142 error(FATAL, "can't set $0"); vp->tval &= ~STR; /* mark string invalid */ vp->tval |= NUM; /* mark number ok */ ! if ((vp->tval & FLD) && vp->nval == 0) donerec = 0; return(vp->fval = f); } --- 136,142 ----- error(FATAL, "can't set $0"); vp->tval &= ~STR; /* mark string invalid */ vp->tval |= NUM; /* mark number ok */ ! if ((vp->tval & FLD) && isnull(vp->nval)) donerec = 0; return(vp->fval = f); } *************** *** 151,157 error(FATAL, "can't set $0"); vp->tval &= ~NUM; vp->tval |= STR; ! if ((vp->tval & FLD) && vp->nval == 0) donerec = 0; if (!(vp->tval&FLD)) strfree(vp->sval); --- 151,157 ----- error(FATAL, "can't set $0"); vp->tval &= ~NUM; vp->tval |= STR; ! if ((vp->tval & FLD) && isnull(vp->nval)) donerec = 0; if (!(vp->tval&FLD)) strfree(vp->sval); Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy