[pcre-dev] [Bug 1565] pcregrep doesn't correctly anchor star…

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: pcre-dev
Sujet: [pcre-dev] [Bug 1565] pcregrep doesn't correctly anchor start of subject
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1565




--- Comment #4 from Philip Hazel <ph10@???> 2014-12-30 17:13:53 ---
On Tue, 30 Dec 2014, Nicolas Sitbon wrote:

> As far as I know only pcregrep allows the multiline mode other programs match
> line by line.


That is true, but in some sense it still matches "line by line". It does
*not* do one ginormous match on the whole file (see below).

> This is weird to allow the subject to span multiple lines without
> honoring the right behaviour for the anchor \A.


I am not sure what you mean by "the right behaviour". Down at the
library level, when pcre_exec() is called, \A means "match at the start
of the subject string". What pcregrep does is to pass pcre_exec() a
subject string that starts at the start of a line. If -M is set, further
lines are also included in the subject string. If the match fails,
pcregrep moves on to the start of the next line (as all greps do) and
tries again.

As far as I can see, the is consistent behaviour with and without -M; \A
always matches at the start of the line that pcregrep is considering.
All that -M does is to allow the match to continue over the end of the
line.

What do you think \A should do?

Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email