84 lines
2.3 KiB
Diff
84 lines
2.3 KiB
Diff
From 993928201df0c42258f32da6c882b791b1fab441 Mon Sep 17 00:00:00 2001
|
|
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
|
|
Date: Thu, 13 Jun 2019 16:49:40 +0000
|
|
Subject: [PATCH] Make pcre2_match() return (*MARK) names from successful
|
|
conditional assertions, as Perl and the JIT do.
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1104 6239d852-aaf2-0410-a92c-79f79f948069
|
|
Petr Písař: Ported to 10.33.
|
|
---
|
|
src/pcre2_match.c | 7 ++++---
|
|
testdata/testinput1 | 8 ++++++++
|
|
testdata/testoutput1 | 14 ++++++++++++++
|
|
|
|
diff --git a/src/pcre2_match.c b/src/pcre2_match.c
|
|
index 849bb58..c7730a2 100644
|
|
--- a/src/pcre2_match.c
|
|
+++ b/src/pcre2_match.c
|
|
@@ -5472,15 +5472,16 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
|
|
|
|
/* If we are at the end of an assertion that is a condition, return a
|
|
match, discarding any intermediate backtracking points. Copy back the
|
|
- captures into the frame before N so that they are set on return. Doing
|
|
- this for all assertions, both positive and negative, seems to match what
|
|
- Perl does. */
|
|
+ mark setting and the captures into the frame before N so that they are
|
|
+ set on return. Doing this for all assertions, both positive and negative,
|
|
+ seems to match what Perl does. */
|
|
|
|
if (GF_IDMASK(N->group_frame_type) == GF_CONDASSERT)
|
|
{
|
|
memcpy((char *)P + offsetof(heapframe, ovector), Fovector,
|
|
Foffset_top * sizeof(PCRE2_SIZE));
|
|
P->offset_top = Foffset_top;
|
|
+ P->mark = Fmark;
|
|
Fback_frame = (char *)F - (char *)P;
|
|
RRETURN(MATCH_MATCH);
|
|
}
|
|
diff --git a/testdata/testinput1 b/testdata/testinput1
|
|
index 3fd5d2a..7b6918a 100644
|
|
--- a/testdata/testinput1
|
|
+++ b/testdata/testinput1
|
|
@@ -6343,4 +6343,12 @@ ef) x/x,mark
|
|
/(?&word)* \. (?<word> \w+ )/xi
|
|
pokus.hokus
|
|
|
|
+/a(?(?=(*:2)b).)/mark
|
|
+ abc
|
|
+ acb
|
|
+
|
|
+/a(?(?!(*:2)b).)/mark
|
|
+ acb
|
|
+ abc
|
|
+
|
|
# End of testinput1
|
|
diff --git a/testdata/testoutput1 b/testdata/testoutput1
|
|
index 8fd67b3..d9f8c3b 100644
|
|
--- a/testdata/testoutput1
|
|
+++ b/testdata/testoutput1
|
|
@@ -10049,4 +10049,18 @@ No match
|
|
0: pokus.hokus
|
|
1: hokus
|
|
|
|
+/a(?(?=(*:2)b).)/mark
|
|
+ abc
|
|
+ 0: ab
|
|
+MK: 2
|
|
+ acb
|
|
+ 0: a
|
|
+
|
|
+/a(?(?!(*:2)b).)/mark
|
|
+ acb
|
|
+ 0: ac
|
|
+ abc
|
|
+ 0: a
|
|
+MK: 2
|
|
+
|
|
# End of testinput1
|
|
--
|
|
2.20.1
|
|
|