This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Brokenness in sed -er- fixincludes
- From: bkorb at gnu dot org
- To: Stepan Kasal <kasal at ucw dot cz>
- Cc: bug-gnu-utils at gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 17 Nov 2003 19:42:31 +0100
- Subject: Re: Brokenness in sed -er- fixincludes
- References: <20031117184231.GA15745@matsrv.math.cas.cz>
> Hello,
> thank you for your bug report.
> Sorry that the answer is so late.
No biggie. Thanks, Stepan.
> On Sun, Oct 26, 2003 at 04:45:44PM -0800, bkorb@gnu.org wrote:
> > When you join two lines into the pattern space with the 'N'
> > command, an insertion should precede all the text in the
> > current pattern. It does on every UNIX box I have access to,
> > except for GNU's sed program.
>
> The GNU sed does the same, in fact.
?? It _is_ GNU's sed I am referring to.
> First, a tricky answer: replace the line
> > cmd='/extern "C\+\+"/N
> with
> cmd='/extern "C\+\+/N
> and it'll start working. Too much quotes.
No, not too many quotes, but the '\+\+' are meta and are used
to (possibly) repeat the match of the 'C' character. Very cute. :)
> And now, a serious answer: the line should be
> cmd='/extern "C++"/N
>
> as sed uses so called basic regular expressions, and + is not a metacharacter.
Ah, now I see why the quote removal works. :-)
> The behaviour of \+ is _undefined_, says POSIX. In old implementations, \+ is
> just like +, but in sed, it has special meaning, "repeat at least once", as
> the meaning of + in extended or perl regexps.
I wish we didn't have so many regex syntaxes, ....
> Thats why your script happened to work on some systems, but it may not work
> on other POSIX compliant systems.
>
> Hope that this explains it.
It seems to work on all POSIX-y seds that I have access to, leaving
GNU's sed anomalously correct. I'll fix fixincludes. Thank you.
Regards, Bruce