[pcre-dev] [Bug 892] a duplicate named subpattern returns th…

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 892] a duplicate named subpattern returns the first match/nomatch result for conditional match of that pattern within the expression.
------- You are receiving this mail because: -------
You are on the CC list for the bug.

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




--- Comment #4 from Philip Hazel <ph10@???> 2009-10-01 09:19:48 ---
On Thu, 1 Oct 2009, JW wrote:

> ironically, the "(?|" feature to set up multiple sub-patterns with
> the same number at issue in #760 works around the duplicate name
> conditional as the index will correctly match if the duplicate names
> are in different sections of the multiple.


Indeed. That occurred to me too.

> where duplicate names are allowed, tracking/associating with each
> pattern name the 'last match' (or 'first match') capturing parenthesis
> number and looking to *that* association to determine the pattern
> number (for both conditional and named backreferences) would solve the
> issue.


I believe I have figured out a way to solve your issue (but it will be
Saturday before I get a chance to try it). If it works, it will be in
the next release (out soon). It requires remembering, in the compiled
code, that a capturing parenthesis was associated with a name, then
searching the name/number table, first to find the name, and then for
any other associated numbers. This will make it the same as
multiply-numbered subpatterns: if *any* of them matched, the condition
is true.

The problem with #760 is that there is nowhere to remember which of
several identically-numbered subpatterns matched, without making an
incompatible change to the API.

> but then again, what do I know.


Quite a lot, it seems!

Regards,
Philip


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