[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: patsubst: multiline text
From: |
Eric Blake |
Subject: |
Re: patsubst: multiline text |
Date: |
Mon, 06 Sep 2010 15:34:13 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.1.2 |
On 09/06/2010 09:57 AM, clemens fischer wrote:
My problem is with the newlines in the text, I'm unable to match the
portions before and after them. I already tried a number of
combinations, with and without literal newlines in {regex}, using eg.
{^\(.+?\)\n} or {^\(.+?\)\\n} or {^\([^\\n]\)+} for {regex}, but the
statements in m4.info referring to the emacs regex syntax seem to need
qualification, so to speak. I've also tried to "define({_nl_},<literal
newline here>)" or using that literal directly, nothing helps.
Thanks for the question.
Unfortunately, there is admittedly a problem with the current regex
implementation - it is line based, rather than argument based, so you
can't really get at newlines directly. Ultimately, the right fix is to
add another argument to the various regex macros that lets you set flags
(line vs. argument, case insensitive, maybe others?) for how a given
regex will behave.
On the other hand, since it is all line based, it may be easier than you
think. First, note that this inserts spaces on every line:
patsubst({ml_text}, {^}, { })
Then, if you concatenate text before the first line, then a second pass
can clean up the first line:
patsubst({-}patsubst({{ml_text}}, {^}, { }), {^- }, {- })
(Untested, but hopefully gives you enough ideas).
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org