autoconf-patches
[Top][All Lists]
Advanced

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

Re: config files substitution with awk


From: Paul Eggert
Subject: Re: config files substitution with awk
Date: Mon, 20 Nov 2006 10:03:18 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> The assumption underlying the patch is that AC_PROG_AWK finds an awk
> that can handle the resulting script.  I did not see an easy way to
> write it portably to ancient awk, but I tested several systems fine.

What difficulties do you see with ancient awk?

For example, this non-ancient loop

  while (match($ 0, skip "@[a-zA-Z_][a-zA-Z_0-9]*@") > 0) {
    l = length(skip "")
    key = substr($ 0, RSTART + 1 + l, RLENGTH - 2 - l)
    if (key in S)
      ...
  }

can easily be written in ancient awk using something like this:

  nfields = split($ 0, field, "@")
  for (i = 1; i <= nfields; i++) {
    key = field[i]
    if (key in S)
      ...
  }

This is arguably even more readable when written in the ancient style
(though I admit I don't know what that 'skip' is doing there in the
original :-).

> One drawback for AC_SUBST_FILE currently present causes a noticeable
> regression due to the fact that awk's system function is used for each
> such substitution.

Why can't we use a repeated getline/print loop here?

> The autoconf.texi note leaves me uncertain what we
> can portably expect from awk's getline.  But my experience is that few
> packages use many AC_SUBST_FILE, rendering this irrelevant in practice.

Another possibility is to go back to using sed for AC_SUBST_FILE.  But
I'd rather do it within awk.  (Maybe we should deprecate
AC_SUBST_FILE?....)

> Is it necessary to 'chmod +x' a file before sourcing it ('. ./file')?

No.  At least, I've never run into any contrary examples.  And POSIX
requires that it work without "chmod +x"; see
<http://www.opengroup.org/onlinepubs/009695399/utilities/dot.html>.




reply via email to

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