bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: config files substitution with awk


From: Paolo Bonzini
Subject: Re: config files substitution with awk
Date: Wed, 06 Dec 2006 09:22:25 +0100
User-agent: Thunderbird 1.5.0.8 (Macintosh/20061025)


Note that it must be done carefully, since we could have:

s/@var1@/@var2@/g
s/@var2@/text2/g

and @var1@ in the input would sustitute to text2.

Right. sed, however, does not collapse the DFAs in such a way and there's no intention of the maintainer (me :-) to add this optimization.

So we must still have as many DFAs as s commands, but with some luck,
we can skip directly to the right action. (For this reason, I'd
suggest to use a more specific tool rather than sed which is too
general for this job).

In fact, awk can be the appropriate tool.

Given the regexps r1, r2, ... rn in the n 's' commands, we can build
the first DFA as:

  r1|r2|r3|....|rn

This can be implemented using a single regular expression /@address@hidden@/ plus an associative array lookup.

The second DFA would be:  r2|r3|...|rn

I think you would have to loop the full r1|r2|r3|....|rn DFA in order to mimic the previous behavior of autoconf (though I don't have the source code handy).

Paolo




reply via email to

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