Revision: 630
http://vcs.pcre.org/viewvc?view=rev&revision=630
Author: ph10
Date: 2011-07-22 11:00:10 +0100 (Fri, 22 Jul 2011)
Log Message:
-----------
Make (*MARK) work in positive assertions.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/doc/pcrepattern.3
code/trunk/pcre_exec.c
code/trunk/testdata/testinput11
code/trunk/testdata/testoutput11
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2011-07-22 09:18:11 UTC (rev 629)
+++ code/trunk/ChangeLog 2011-07-22 10:00:10 UTC (rev 630)
@@ -162,6 +162,9 @@
30. If \k was not followed by a braced, angle-bracketed, or quoted name, PCRE
compiled something random. Now it gives a compile-time error (as does
Perl).
+
+31. A *MARK encountered during the processing of a positive assertion is now
+ recorded and passed back (compatible with Perl).
Version 8.12 15-Jan-2011
Modified: code/trunk/doc/pcrepattern.3
===================================================================
--- code/trunk/doc/pcrepattern.3 2011-07-22 09:18:11 UTC (rev 629)
+++ code/trunk/doc/pcrepattern.3 2011-07-22 10:00:10 UTC (rev 630)
@@ -2492,8 +2492,10 @@
.P
If any of these verbs are used in an assertion or subroutine subpattern
(including recursive subpatterns), their effect is confined to that subpattern;
-it does not extend to the surrounding pattern. Note that such subpatterns are
-processed as anchored at the point where they are tested.
+it does not extend to the surrounding pattern, with one exception: a *MARK that
+is encountered in a positive assertion \fIis\fP passed back (compare capturing
+parentheses in assertions). Note that such subpatterns are processed as
+anchored at the point where they are tested.
.P
The new verbs make use of what was previously invalid syntax: an opening
parenthesis followed by an asterisk. They are generally of the form
@@ -2584,6 +2586,10 @@
of obtaining this information than putting each alternative in its own
capturing parentheses.
.P
+If (*MARK) is encountered in a positive assertion, its name is recorded and
+passed back if it is the last-encountered. This does not happen for negative
+assetions.
+.P
A name may also be returned after a failed match if the final path through the
pattern involves (*MARK). However, unless (*MARK) used in conjunction with
(*COMMIT), this is unlikely to happen for an unanchored pattern because, as the
@@ -2755,6 +2761,6 @@
.rs
.sp
.nf
-Last updated: 20 July 2011
+Last updated: 22 July 2011
Copyright (c) 1997-2011 University of Cambridge.
.fi
Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c 2011-07-22 09:18:11 UTC (rev 629)
+++ code/trunk/pcre_exec.c 2011-07-22 10:00:10 UTC (rev 630)
@@ -1365,6 +1365,7 @@
if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
{
mstart = md->start_match_ptr; /* In case \K reset it */
+ markptr = md->mark;
break;
}
if (rrc != MATCH_NOMATCH &&
@@ -1653,7 +1654,7 @@
md->end_match_ptr = eptr; /* For ONCE */
md->end_offset_top = offset_top;
md->start_match_ptr = mstart;
- MRRETURN(MATCH_MATCH);
+ MRRETURN(MATCH_MATCH); /* Sets md->mark */
}
/* For capturing groups we have to check the group number back at the start
Modified: code/trunk/testdata/testinput11
===================================================================
--- code/trunk/testdata/testinput11 2011-07-22 09:18:11 UTC (rev 629)
+++ code/trunk/testdata/testinput11 2011-07-22 10:00:10 UTC (rev 630)
@@ -639,4 +639,10 @@
/^(a)(?1)++ab/
aaaab
+/^(?=a(*:M))aZ/K
+ aZbc
+
+/^(?!(*:M)b)aZ/K
+ aZbc
+
/-- End of testinput11 --/
Modified: code/trunk/testdata/testoutput11
===================================================================
--- code/trunk/testdata/testoutput11 2011-07-22 09:18:11 UTC (rev 629)
+++ code/trunk/testdata/testoutput11 2011-07-22 10:00:10 UTC (rev 630)
@@ -1212,4 +1212,13 @@
aaaab
No match
+/^(?=a(*:M))aZ/K
+ aZbc
+ 0: aZ
+MK: M
+
+/^(?!(*:M)b)aZ/K
+ aZbc
+ 0: aZ
+
/-- End of testinput11 --/