Hello Paolo,

* Paolo Bonzini wrote on Tue, Nov 21, 2006 at 09:49:56AM CET:
> 
> >+/@[a-zA-Z_][a-zA-Z_0-9]*@/ {
> >+  nfields = split($ 0, field, "@")
> >+  for (i = 1; i <= nfields; i++) {
> > +    key = field[i]
> 
> The space after $ is useless.

It helps to keep m4 from expanding $0, without needing to think about
level of m4 quotation currently in place.  AFAIK it's portable.

> Furthermore, this is wrong in cases like 
> [EMAIL PROTECTED]@[EMAIL PROTECTED]@.

No, it isn't.  It's merely suboptimal in that a sub may be invoked which
does not match anything.  It is possible to iterate only from 2 to less
than nfields though, as another optimization.

Note that the sub replaces the key including the surrounding @, and that
all @ that come in from the replacement are followed by |#_!!_#| so they
are not mistakenly used for substitution again.

I am still pondering abandoning sub completely though, and using substr
and length to do the replacement manually, due to the \& escaping
issues.

Also I wonder how to get around this limitation (autoconf.texi):
|      Traditional Awk `split' supports only two arguments.

Is seems not portable to set FS before each split and reset it
afterwards, to not fall into the 99 field limit when scanning the next
record, unless split allows three arguments:

$ perl -e 'print "[EMAIL PROTECTED]@" . "x"x199 . "\n"' |
  awk 'BEGIN{FS="@"} {print $ 2; FS="x"; split($ 0, f); print f[2]; FS="@"}'
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
awk: Line [EMAIL PROTECTED] cannot have more than 199 fields.
 The input line number is 1.
 The source line number is 1.

$ perl -e 'print "[EMAIL PROTECTED]@" . "x"x199 . "\n"' |
  awk 'BEGIN{FS="@"} {print $ 2; split($ 0, f, "x"); print f[2]}'
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@
$ config.guess
hppa2.0-hp-hpux10.20

Cheers,
Ralf


Reply via email to