[comp.bugs.4bsd] awk bug, fix wanted

tvdl@bsiao.UUCP (Timo van der Laan) (03/18/87)

Problem
	The following call to awk (to be used in a shell script) gives the
	error message 'funny variable' when called with a parameter >49.

	awk -F~ '{printf "%s %s\n",  $'$1', $82;print $'$1', $82 }' Input

Repeat-by
	Create a file Input with 82 fields separated by ~ (on 1 line).
	Save the awk-call in a file Call.
	sh -x Call nn
	will give the error message if nn>49.

Question
	Does somebody has a fix for this problem? I looked at the sources
	of awk and I found only 1 constant that was 50. Increasing this
	constant to 100 and recompiling awk didn't work.
	We have a VAX-750 with 4.2bsd running.

----------------------------------------------------------------------------
 Timo van der Laan, Postbank N.V., room 4.97             ...mcvax!bsiao!tvdl
 Pb 21009
 1000 EX  AMSTERDAM                                   Phone: + 31 20 5843175

ado@elsie.UUCP (03/26/87)

> [A] call to awk (to be used in a shell script) gives the
> error message 'funny variable' when called with a parameter >49.

The fix is to the file lib.c in the awk source directory.
As usual, the trade secret status of the code involved precludes a clearer
posting.

*** OLD/lib.c	Wed Mar 25 22:54:04 1987
--- NEW/lib.c	Wed Mar 25 22:53:54 1987
***************
*** 1,4 ****
--- 1,11 ----
+ #ifndef ASWAS
  #ifndef lint
+ #ifndef NOID
+ static char	elsieid[] = "@(#)lib.c	3.4";
+ #endif /* !NOID */
+ #endif /* !lint */
+ #endif /* !ASWAS */
+ #ifndef lint
  static char sccsid[] = "@(#)lib.c	4.4 9/17/84";
  #endif
  
***************
*** 40,45 ****
--- 47,59 ----
  	extern char **svargv;
  	register c, sep;
  
+ #ifndef ASWAS
+ 	static int	did;
+ 
+ 	if (did == 0)
+ 		for (did = 2; did < sizeof fldtab / sizeof fldtab[0]; ++did)
+ 			fldtab[did] = fldtab[1];
+ #endif /* !ASWAS */
  	dprintf("**RS=%o, **FS=%o\n", **RS, **FS, NULL);
  	donefld = 0;
  	donerec = 1;

-- 
	"We must choose:  the stars or the starving.  Which shall it be?"
	UUCP: ..seismo!elsie!ado	      ARPA: elsie!ado@seismo.ARPA
	     Elsie and Ado are trademarks of Borden, Inc. and Ampex.