Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!hplabs!sri-unix!rbbb@RICE.ARPA From: rbbb@RICE.ARPA Newsgroups: net.unix-wizards Subject: Awk and VAX 4.2 BSD Message-ID: <1253@sri-arpa.UUCP> Date: Sun, 24-Jun-84 23:17:47 EDT Article-I.D.: sri-arpa.1253 Posted: Sun Jun 24 23:17:47 1984 Date-Received: Sat, 30-Jun-84 01:26:55 EDT Lines: 28 From: David Chase This message Copyright (C) 1984 by David R. Chase. May not be distributed for profit. Problem: awk is broken. Proof: The following one-liner echo "This is a test" | awk '{$1 = "That"; print}' prints "This is a test" instead of "That is a test" To fix this bug (I think): in the file "tran.c", replace every occurrence (there are two) of if ((vp->tval & FLD) && vp->nval == 0) with if ((vp->tval & FLD) && (vp->nval == 0 ? 1 : *(vp->nval) == 0)) You should find these in the routines setsval and setfval. Explanation: In a vp -> nval is a character string. Someone tried to fix awk to remove all assumptions that *0 == 0; as part of this effort, the routine "stringto" returns an allocated empty string (why not a single empty string??) whenever it is passed zero as input. Furthermore, most references to NULL were changed into references to a static string EMPTY. The test for null string "vp->nval == 0" fails because the conversion was incomplete. My fix is (I hope) very conservative, and in the worst case makes awk run a little slower than it should. drc