Re: traditional awk: lazy splitting of $0?

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

 



Hello Paul,

oldish thread:

* Paul Eggert wrote on Mon, Oct 22, 2007 at 09:03:35AM CEST:
> Ralf Wildenhues <Ralf.Wildenhues@xxxxxx> 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.

Cheers,
Ralf

    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
     _AT_NORMALIZE_TEST_GROUP_NUMBER(at_group_normalized)
     echo "  outfile[[\"$at_group\"]] = \"$at_test_source-$at_group_normalized\""
   done
-  AS_ECHO(['}
+  AS_ECHO(['
+  FS = ""
+}
 emit == 0 && /^@%:@AT_START_/ {
   test = substr($ 0, 11);
   if (outfile[[test]]) {


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf


[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux