[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: traditional awk: lazy splitting of $0?

From: Ralf Wildenhues
Subject: Re: traditional awk: lazy splitting of $0?
Date: Sat, 17 Nov 2007 09:38:26 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Paul,

oldish thread:

* Paul Eggert wrote on Mon, Oct 22, 2007 at 09:03:35AM CEST:
> Ralf Wildenhues <address@hidden> writes:
> > Can I rely on the fact that splitting of $0 is done lazily?
> I vaguely recall that traditional Awk worked that way, yes.  Sort of
> lazily, anyway: it split all of $0 if you accessed any $i where i>0.
> > works with Solaris 2.6 awk
> If it works with an awk that old, that's probably good enough.

Oh well.  Tru64 4.0D awk doesn't work that way:

$ perl -e 'print "x "x200;' | awk '{print $0}'
awk: Line x x x x x x x x x x  cannot have more than 199 fields.

 The input line number is 1.
 The source line number is 1.

Yuck.  Sorry for not testing this system earlier.  I applied this patch
to work around it similar to how it is done in status.m4.


    Avoid error with Tru64 awk and testsuite lines with many words.
    * lib/autotest/general.m4 (AT_INIT): In the awk script that
    reads the testsuite, set the field separator to an unusual value,
    in order to not run over the limit of 199 fields.  Tru64 4.0D awk
    even splits the input if $i, i>0, was never accessed in the script.

diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index e50f0f8..7a6ccfe 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -870,7 +870,9 @@ fi
     echo "  outfile[[\"$at_group\"]] = 
-  AS_ECHO(['}
+  AS_ECHO(['
+  FS = ""
 emit == 0 && /address@hidden:@AT_START_/ {
   test = substr($ 0, 11);
   if (outfile[[test]]) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]