autoconf
[Top][All Lists]
Advanced

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

Re: multiline output variables.


From: Stepan Kasal
Subject: Re: multiline output variables.
Date: Thu, 27 Jan 2005 15:49:48 +0100
User-agent: Mutt/1.4.1i

Hello Dan,

On Tue, Jan 25, 2005 at 01:15:22PM -0500, Dan Manthey wrote:
> On Tue, 25 Jan 2005, Stepan Kasal wrote:
> No single delimiter is guaranteed to be in none of the output variable
> values.  However, since they are all finite, there is guaranteed to exist
> some string that is in none of them.  I try an unlikely delimiter
> (suggested by Noah, I believe), check if it conflicts, and if it does,
> choose a new one until there is no conflict. [...]

oh, I see it now.

When you have to re-iterate, I'd use something like
        ac_delim="$ac_delim$ac_delim !_$ac_delim"
instead of your  ac_delim=$ac_delim'_'  to speed up the convergence.

I noticed several bugs with the patch you posted on Tue, 25 Jan 2005:

1) ac_delim contains a regex meta-character ^
2) your postprocessing script doesn't seem to work
3) your postprocessing script can get confused by certain substitutions
4) you use something like s/x\{23\}/yes/ which is not portable
5) AC_SUBST(ac_delim) can cause an endless loop

Ad 1):
The sed command  s/%^!_!#_/ ... /  will sureley cause problems, at least
with some implementations of sed.  My original proposal was
        ac_delim='@!_!#_ '

Ad 2):
Your script contains this:
        s/$/\\/
        ...
        s/'"$ac_delim"'$/,g/
It seems that this cannot work; you'd have to change the second line to
        s/'"$ac_delim"'\\$/,g/

Ad 3):
If you use
        AC_SUBST(ABC, ["<x
        x>"])
you have something like
        $ac_delim<ABC>$ac_delim<x
        x>$ac_delim
And when the postprocessing script will process the second of these lines,
it'll do
        s/>'"$ac_delim"'/@,|address@hidden@#|/
instead of
        s/'"$ac_delim"'$/,g/
and the resulting sed script is screwed.

A fix for 2)--5):
It can be hard to get all of these right.  There surely are several ways,
let me suggest one of them.  Instead of

        $ac_delim<_AC_Var>$ac_delim$_AC_Var$ac_delim

the file conf$$subs.sed would simply get

        _AC_Var!$_AC_Var$ac_delim

Then the actual delimiter wouldn't be $ac_delim, but $ac_delim"\n",
so you can indeed use
        grep -c "$ac_delim\$"
to verify that the postprocessing script wouldn't get confused.

To prevent problems like 3), the postprocessing script would acumulate
lines, until it reaches the delimiter.  It could look like this:

sed  ':s
/'"$ac_delim"'$/b ok
N
b s
:ok
s/@/|address@hidden@#|/g
s/[\\&,]/\\&/g
s/\n/\\&/g
s/^/s,@/
s/!/@,|address@hidden@#|/
s/'"$ac_delim"'$/,g/'


I like your solution to prevent recursion.  Yet I can pick some nits
about it, too.  ;-)

I suggest to modify the above script this way:
...
s/@/|address@hidden@#|@|address@hidden@#|/g
...
s/!/@,|address@hidden@#|/

This would mean that at the end, one command would remove all these markers
        s/|address@hidden@#|//g

I hope you'll like my suggestions.

> Ah shoot.  I have to check with my work as to giving this stuff out.
> *grin* Perhaps it'll end up that you're just helping me and not vice
> versa.  I'll get back to you on that.

If your patch doesn't get to autoconf, both sides loose.  Actually your
ability to make use of your work will be quite limited, as maintaining the
patch separately from autoconf can be a tedious work.

If your patch is part of autoconf, you get thousands of testers for free!

I hope the legal things will be OK,
        Stepan Kasal




reply via email to

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