From 49f174ef7843977e3859dceb2a84444a2993cc43 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" 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. --- ChangeLog | 3 +++ src/pcre2_match.c | 7 ++++--- testdata/testinput1 | 8 ++++++++ testdata/testoutput1 | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55d56dd..ab6b925 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,9 @@ minimum is potentially useful. * When no minimum length is set by the normal scan, but a first and/or last code unit is recorded, set the minimum to 1 or 2 as appropriate. + +10. A (*MARK) value inside a successful condition was not being returned by the +interpretive matcher (it was returned by JIT). This bug has been mended. Version 10.33 16-April-2019 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)* \. (? \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