[Top][All Lists]

[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: Mon, 17 Jan 2005 11:13:11 +0100
User-agent: Mutt/1.4.1i


this sounds very interesting.  I admit I don't fully understand your code
so please forgive me any errors in the following comments:

On Thu, Jan 13, 2005 at 05:49:36PM -0500, Dan Manthey wrote:
> It appears to me that since the set of substitutions is fixed at the time
> of running autoconf, then this breakup can be done in m4, which I did.

This is very nice!

On Fri, Jan 14, 2005 at 02:56:16AM -0800, Noah Misch wrote:
> s/[^t]$/&\\/ does not do the job?

I don't think so.  What if the substituted value were "first\nsecond"?
The newline wouldn't get escaped.

On Thu, Jan 13, 2005 at 05:49:36PM -0500, Dan Manthey wrote:
> [...] so that the right-hand side of the substitution was quoted by
> a separate call to sed for each variable, [...]

As you already mentioned, there are two possible solutions:

1) list all variables and the values to be substitute and post-process the
list by a sed command to for the final sed program,

2) use a separate call to sed for each variable.

You decided to use 2), which is the most correct solution.  Unfortunately,
the performance penalty may be high.  I'm afraid it's to high to be worth it.

Current code uses the approach 1).  The problem is that the post-processing
sed program has to understand what are the individual variable values.
Currently the values are delimited in fact by newline, so the values cannot
contain the newline character.  Noah's proposal in fact uses "t\n" as the
delimiter, so my complain above was that no value can contain that string.

I think that if we choose a sufficiently unusual delimiter, we can go with
it.  I suggest that we use the delimiter "@!_!#_ \n" (the last two characters
are space and newline).

For the case of clarity, I'll use "DELIM\n" as the delimiter in the rest
of this mail.  (So DELIM is a shortcut for "@!_!#_ " ; I guess a macro can
be used to make the code in status.m4 more readable.)

Then, the code would do the following:

- list all variables and their values to a file which would look like this:

address@hidden contains
two lines.DELIM\n

- use  grep -c 'DELIM$'  to check that the file contains the right number
of delimiters.  If this check fails, issue an error message explaining that
the repacement text cannot contain "DELIM\n".

- post process the list by the following sed program (untested):

/DELIM$/b ok
b loop
s/DELIM$/,;t t/

I think this solution is general enough for practical purposes, yet it
presents no slowdown of configure run.

Dan, would you volunteer to rewrite your patch along this suggestion?

Thank you gain for your nice ideas,
        Stepan Kasal

reply via email to

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