mirror of
https://github.com/PCRE2Project/pcre2.git
synced 2025-10-17 15:25:55 +08:00
Remove colon from recurse with kept groups (#737)
This commit is contained in:
@@ -5162,7 +5162,7 @@ while (ptr < ptrend)
|
||||
case CHAR_R:
|
||||
i = 0; /* (?R) == (?R0) */
|
||||
ptr++;
|
||||
if (ptr >= ptrend || (*ptr != CHAR_RIGHT_PARENTHESIS && *ptr != CHAR_COLON))
|
||||
if (ptr >= ptrend || (*ptr != CHAR_RIGHT_PARENTHESIS && *ptr != CHAR_LEFT_PARENTHESIS))
|
||||
{
|
||||
errorcode = ERR58;
|
||||
goto FAILED;
|
||||
@@ -5215,9 +5215,8 @@ while (ptr < ptrend)
|
||||
/* Arguments are not supported for \g construct. */
|
||||
if (terminator != CHAR_NUL) break;
|
||||
|
||||
if (ptr < ptrend && *ptr == CHAR_COLON)
|
||||
if (ptr < ptrend && *ptr == CHAR_LEFT_PARENTHESIS)
|
||||
{
|
||||
ptr++;
|
||||
parsed_pattern = parse_capture_list(&ptr, ptrend, utf, parsed_pattern,
|
||||
offset, &errorcode, cb);
|
||||
if (parsed_pattern == NULL) goto FAILED;
|
||||
|
@@ -655,7 +655,7 @@ static struct regression_test_case regression_test_cases[] = {
|
||||
{ MU, A, 0, 0, "a(?=)b", "ab" },
|
||||
{ MU, A, 0, 0 | F_NOMATCH, "a(?!)b", "ab" },
|
||||
{ MU, A, 0, 0, "(?(?<!|(|a)))", "a" },
|
||||
{ MU, A, 0, 0, "(?=((?|(a)(.)|(b)(..)|(c)(...)))(?1:(2,3))).x", "b12c123bx2c123" },
|
||||
{ MU, A, 0, 0, "(?=((?|(a)(.)|(b)(..)|(c)(...)))(?1(2,3))).x", "b12c123bx2c123" },
|
||||
|
||||
/* Not empty, ACCEPT, FAIL */
|
||||
{ MU, A, PCRE2_NOTEMPTY, 0 | F_NOMATCH, "a*", "bcx" },
|
||||
|
36
testdata/testinput2
vendored
36
testdata/testinput2
vendored
@@ -7873,42 +7873,42 @@ a)"xI
|
||||
|
||||
# Parse error tests
|
||||
|
||||
/(?1:/
|
||||
/(?1/
|
||||
|
||||
/(?1:1/
|
||||
/(?1(/
|
||||
|
||||
/(?R:(1/
|
||||
/(?R(1/
|
||||
|
||||
/(?R:(1,/
|
||||
/(?R(1,/
|
||||
|
||||
/(?R0:(1,2!/
|
||||
/(?R0(1,2!/
|
||||
|
||||
/(?1:(1,0))()/
|
||||
/(?1(1,0))()/
|
||||
|
||||
/(?1:(1,+2))()/
|
||||
/(?1(1,+2))()/
|
||||
|
||||
/(?1:(<name>))/
|
||||
/(?1(<name>))/
|
||||
|
||||
# Operation tests
|
||||
|
||||
/^(?1:(2))\2(?(DEFINE)(a(.)b(.)c))/B
|
||||
/^(?1(2))\2(?(DEFINE)(a(.)b(.)c))/B
|
||||
axbycx
|
||||
\= Expect no match
|
||||
axby
|
||||
axbycy
|
||||
|
||||
/^((.)(?<id>.))(?1:('id'))(.)/B
|
||||
/^((.)(?<id>.))(?1('id'))(.)/B
|
||||
abcde
|
||||
|
||||
/^(?1:(3,2,2,3,2))(?1:(3))(?(DEFINE)(a(.)b(.)c))/B
|
||||
/^(?1(3,2,2,3,2))(?1(3))(?(DEFINE)(a(.)b(.)c))/B
|
||||
a1b2cafbgc
|
||||
|
||||
/(?1:(2))#(?1:(3))#(?1:(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
|
||||
/(?1(2))#(?1(3))#(?1(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
|
||||
aabbcc#ddeeff#gghhii!aabbcc#ddeeff#gghhii#
|
||||
\= Expect no match
|
||||
aabbcc#ddeeff#gghhii
|
||||
|
||||
/^(?1:(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
|
||||
/^(?1(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
|
||||
aa#bb#xx#
|
||||
aa#bb#cc#xx#
|
||||
aa#bb#cc#dd#xx#
|
||||
@@ -7916,24 +7916,24 @@ a)"xI
|
||||
aa#xx#
|
||||
aa#bb#cc#dd#ee#xx#
|
||||
|
||||
/^(?1:(1,2)){2,}+(?(DEFINE)((..)#))!/B
|
||||
/^(?1(1,2)){2,}+(?(DEFINE)((..)#))!/B
|
||||
aa#bb#!
|
||||
aa#bb#cc#dd#ee#!
|
||||
\= Expect no match
|
||||
aa#!
|
||||
aa#bb#cc#dd#ee#
|
||||
|
||||
/^(?1)(?(DEFINE)(<(?2:(3,4))><\4\3>)((..)(..)))/
|
||||
/^(?1)(?(DEFINE)(<(?2(3,4))><\4\3>)((..)(..)))/
|
||||
<abcd><cdab>
|
||||
|
||||
/(?1)#(?(DEFINE)(a(.(*ACCEPT).)b))/
|
||||
#axyb#axax#
|
||||
|
||||
/^(?>(?1:(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
|
||||
/^(?>(?1(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
|
||||
abcd!
|
||||
abcde
|
||||
|
||||
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R:(1))))+>/
|
||||
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R(1))))+>/
|
||||
<aa<bb>cc<dd>ee>
|
||||
<aa<bb<cc>dd>ee<ff<gg>hh>ii>
|
||||
<aa<bb<cc>dd>ee
|
||||
@@ -7943,7 +7943,7 @@ a)"xI
|
||||
<aa<bb<ABcc>dd>ee<ff<gg>hh>ii>
|
||||
<aa<bb<cc>dd>ee<ff<gg>hABhABh>ii>
|
||||
|
||||
/(?:(?1:(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
|
||||
/(?:(?1(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
|
||||
abc#abcdef#defghi#ghijkl#
|
||||
abc#abcdef#defghi#ghijkl#jklmno#
|
||||
abc#abcdef#defghi#ghijkl#jklmno#mnopqr#
|
||||
|
2
testdata/testinput6
vendored
2
testdata/testinput6
vendored
@@ -5248,7 +5248,7 @@
|
||||
|
||||
# --------------
|
||||
|
||||
/^(?1:(2))(?(DEFINE)(a(.)b))/
|
||||
/^(?1(2))(?(DEFINE)(a(.)b))/
|
||||
axb
|
||||
|
||||
# End of testinput6
|
||||
|
48
testdata/testoutput2
vendored
48
testdata/testoutput2
vendored
@@ -22102,33 +22102,33 @@ Failed: error -69: error performing replacement case transformation
|
||||
|
||||
# Parse error tests
|
||||
|
||||
/(?1:/
|
||||
Failed: error 218 at offset 4: missing opening parenthesis
|
||||
/(?1/
|
||||
Failed: error 114 at offset 3: missing closing parenthesis
|
||||
|
||||
/(?1:1/
|
||||
Failed: error 218 at offset 4: missing opening parenthesis
|
||||
/(?1(/
|
||||
Failed: error 217 at offset 4: expected capture group number or name
|
||||
|
||||
/(?R:(1/
|
||||
Failed: error 114 at offset 6: missing closing parenthesis
|
||||
/(?R(1/
|
||||
Failed: error 114 at offset 5: missing closing parenthesis
|
||||
|
||||
/(?R:(1,/
|
||||
Failed: error 217 at offset 7: expected capture group number or name
|
||||
/(?R(1,/
|
||||
Failed: error 217 at offset 6: expected capture group number or name
|
||||
|
||||
/(?R0:(1,2!/
|
||||
/(?R0(1,2!/
|
||||
Failed: error 158 at offset 3: (?R (recursive pattern call) must be followed by a closing parenthesis
|
||||
|
||||
/(?1:(1,0))()/
|
||||
Failed: error 115 at offset 8: reference to non-existent subpattern
|
||||
|
||||
/(?1:(1,+2))()/
|
||||
/(?1(1,0))()/
|
||||
Failed: error 115 at offset 7: reference to non-existent subpattern
|
||||
|
||||
/(?1:(<name>))/
|
||||
/(?1(1,+2))()/
|
||||
Failed: error 115 at offset 6: reference to non-existent subpattern
|
||||
|
||||
/(?1(<name>))/
|
||||
Failed: error 115 at offset 3: reference to non-existent subpattern
|
||||
|
||||
# Operation tests
|
||||
|
||||
/^(?1:(2))\2(?(DEFINE)(a(.)b(.)c))/B
|
||||
/^(?1(2))\2(?(DEFINE)(a(.)b(.)c))/B
|
||||
------------------------------------------------------------------
|
||||
Bra
|
||||
^
|
||||
@@ -22162,7 +22162,7 @@ No match
|
||||
axbycy
|
||||
No match
|
||||
|
||||
/^((.)(?<id>.))(?1:('id'))(.)/B
|
||||
/^((.)(?<id>.))(?1('id'))(.)/B
|
||||
------------------------------------------------------------------
|
||||
Bra
|
||||
^
|
||||
@@ -22189,7 +22189,7 @@ No match
|
||||
3: d
|
||||
4: e
|
||||
|
||||
/^(?1:(3,2,2,3,2))(?1:(3))(?(DEFINE)(a(.)b(.)c))/B
|
||||
/^(?1(3,2,2,3,2))(?1(3))(?(DEFINE)(a(.)b(.)c))/B
|
||||
------------------------------------------------------------------
|
||||
Bra
|
||||
^
|
||||
@@ -22221,7 +22221,7 @@ No match
|
||||
2: 1
|
||||
3: g
|
||||
|
||||
/(?1:(2))#(?1:(3))#(?1:(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
|
||||
/(?1(2))#(?1(3))#(?1(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
|
||||
aabbcc#ddeeff#gghhii!aabbcc#ddeeff#gghhii#
|
||||
0: aabbcc#ddeeff#gghhii#
|
||||
1: <unset>
|
||||
@@ -22232,7 +22232,7 @@ No match
|
||||
aabbcc#ddeeff#gghhii
|
||||
No match
|
||||
|
||||
/^(?1:(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
|
||||
/^(?1(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
|
||||
------------------------------------------------------------------
|
||||
Bra
|
||||
^
|
||||
@@ -22288,7 +22288,7 @@ No match
|
||||
aa#bb#cc#dd#ee#xx#
|
||||
No match
|
||||
|
||||
/^(?1:(1,2)){2,}+(?(DEFINE)((..)#))!/B
|
||||
/^(?1(1,2)){2,}+(?(DEFINE)((..)#))!/B
|
||||
------------------------------------------------------------------
|
||||
Bra
|
||||
^
|
||||
@@ -22332,7 +22332,7 @@ No match
|
||||
aa#bb#cc#dd#ee#
|
||||
No match
|
||||
|
||||
/^(?1)(?(DEFINE)(<(?2:(3,4))><\4\3>)((..)(..)))/
|
||||
/^(?1)(?(DEFINE)(<(?2(3,4))><\4\3>)((..)(..)))/
|
||||
<abcd><cdab>
|
||||
0: <abcd><cdab>
|
||||
|
||||
@@ -22340,7 +22340,7 @@ No match
|
||||
#axyb#axax#
|
||||
0: ax#
|
||||
|
||||
/^(?>(?1:(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
|
||||
/^(?>(?1(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
|
||||
abcd!
|
||||
0: abcd!
|
||||
1: <unset>
|
||||
@@ -22349,7 +22349,7 @@ No match
|
||||
abcde
|
||||
0: abcde
|
||||
|
||||
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R:(1))))+>/
|
||||
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R(1))))+>/
|
||||
<aa<bb>cc<dd>ee>
|
||||
0: <aa<bb>cc<dd>ee>
|
||||
<aa<bb<cc>dd>ee<ff<gg>hh>ii>
|
||||
@@ -22372,7 +22372,7 @@ No match
|
||||
0: <aa<bb<cc>dd>ee<ff<gg>hABhABh>ii>
|
||||
1: AB
|
||||
|
||||
/(?:(?1:(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
|
||||
/(?:(?1(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
|
||||
abc#abcdef#defghi#ghijkl#
|
||||
0: abc#abcdef#defghi#ghijkl#
|
||||
1: <unset>
|
||||
|
2
testdata/testoutput6
vendored
2
testdata/testoutput6
vendored
@@ -8212,7 +8212,7 @@ No match
|
||||
|
||||
# --------------
|
||||
|
||||
/^(?1:(2))(?(DEFINE)(a(.)b))/
|
||||
/^(?1(2))(?(DEFINE)(a(.)b))/
|
||||
axb
|
||||
Failed: error -42: pattern contains an item that is not supported for DFA matching
|
||||
|
||||
|
Reference in New Issue
Block a user