Skip to content

Commit 53dda19

Browse files
committed
Remove colon from recurese with kept groups
1 parent 2e03e32 commit 53dda19

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

src/pcre2_compile.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5162,7 +5162,7 @@ while (ptr < ptrend)
51625162
case CHAR_R:
51635163
i = 0; /* (?R) == (?R0) */
51645164
ptr++;
5165-
if (ptr >= ptrend || (*ptr != CHAR_RIGHT_PARENTHESIS && *ptr != CHAR_COLON))
5165+
if (ptr >= ptrend || (*ptr != CHAR_RIGHT_PARENTHESIS && *ptr != CHAR_LEFT_PARENTHESIS))
51665166
{
51675167
errorcode = ERR58;
51685168
goto FAILED;
@@ -5215,9 +5215,8 @@ while (ptr < ptrend)
52155215
/* Arguments are not supported for \g construct. */
52165216
if (terminator != CHAR_NUL) break;
52175217

5218-
if (ptr < ptrend && *ptr == CHAR_COLON)
5218+
if (ptr < ptrend && *ptr == CHAR_LEFT_PARENTHESIS)
52195219
{
5220-
ptr++;
52215220
parsed_pattern = parse_capture_list(&ptr, ptrend, utf, parsed_pattern,
52225221
offset, &errorcode, cb);
52235222
if (parsed_pattern == NULL) goto FAILED;

testdata/testinput2

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7873,67 +7873,67 @@ a)"xI
78737873

78747874
# Parse error tests
78757875

7876-
/(?1:/
7876+
/(?1/
78777877

7878-
/(?1:1/
7878+
/(?1(/
78797879

7880-
/(?R:(1/
7880+
/(?R(1/
78817881

7882-
/(?R:(1,/
7882+
/(?R(1,/
78837883

7884-
/(?R0:(1,2!/
7884+
/(?R0(1,2!/
78857885

7886-
/(?1:(1,0))()/
7886+
/(?1(1,0))()/
78877887

7888-
/(?1:(1,+2))()/
7888+
/(?1(1,+2))()/
78897889

7890-
/(?1:(<name>))/
7890+
/(?1(<name>))/
78917891

78927892
# Operation tests
78937893

7894-
/^(?1:(2))\2(?(DEFINE)(a(.)b(.)c))/B
7894+
/^(?1(2))\2(?(DEFINE)(a(.)b(.)c))/B
78957895
axbycx
78967896
\= Expect no match
78977897
axby
78987898
axbycy
78997899

7900-
/^((.)(?<id>.))(?1:('id'))(.)/B
7900+
/^((.)(?<id>.))(?1('id'))(.)/B
79017901
abcde
79027902

7903-
/^(?1:(3,2,2,3,2))(?1:(3))(?(DEFINE)(a(.)b(.)c))/B
7903+
/^(?1(3,2,2,3,2))(?1(3))(?(DEFINE)(a(.)b(.)c))/B
79047904
a1b2cafbgc
79057905

7906-
/(?1:(2))#(?1:(3))#(?1:(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
7906+
/(?1(2))#(?1(3))#(?1(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
79077907
aabbcc#ddeeff#gghhii!aabbcc#ddeeff#gghhii#
79087908
\= Expect no match
79097909
aabbcc#ddeeff#gghhii
79107910

7911-
/^(?1:(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
7911+
/^(?1(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
79127912
aa#bb#xx#
79137913
aa#bb#cc#xx#
79147914
aa#bb#cc#dd#xx#
79157915
\= Expect no match
79167916
aa#xx#
79177917
aa#bb#cc#dd#ee#xx#
79187918

7919-
/^(?1:(1,2)){2,}+(?(DEFINE)((..)#))!/B
7919+
/^(?1(1,2)){2,}+(?(DEFINE)((..)#))!/B
79207920
aa#bb#!
79217921
aa#bb#cc#dd#ee#!
79227922
\= Expect no match
79237923
aa#!
79247924
aa#bb#cc#dd#ee#
79257925

7926-
/^(?1)(?(DEFINE)(<(?2:(3,4))><\4\3>)((..)(..)))/
7926+
/^(?1)(?(DEFINE)(<(?2(3,4))><\4\3>)((..)(..)))/
79277927
<abcd><cdab>
79287928

79297929
/(?1)#(?(DEFINE)(a(.(*ACCEPT).)b))/
79307930
#axyb#axax#
79317931

7932-
/^(?>(?1:(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
7932+
/^(?>(?1(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
79337933
abcd!
79347934
abcde
79357935

7936-
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R:(1))))+>/
7936+
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R(1))))+>/
79377937
<aa<bb>cc<dd>ee>
79387938
<aa<bb<cc>dd>ee<ff<gg>hh>ii>
79397939
<aa<bb<cc>dd>ee
@@ -7943,7 +7943,7 @@ a)"xI
79437943
<aa<bb<ABcc>dd>ee<ff<gg>hh>ii>
79447944
<aa<bb<cc>dd>ee<ff<gg>hABhABh>ii>
79457945

7946-
/(?:(?1:(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
7946+
/(?:(?1(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
79477947
abc#abcdef#defghi#ghijkl#
79487948
abc#abcdef#defghi#ghijkl#jklmno#
79497949
abc#abcdef#defghi#ghijkl#jklmno#mnopqr#

testdata/testoutput2

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22102,33 +22102,33 @@ Failed: error -69: error performing replacement case transformation
2210222102

2210322103
# Parse error tests
2210422104

22105-
/(?1:/
22106-
Failed: error 218 at offset 4: missing opening parenthesis
22105+
/(?1/
22106+
Failed: error 114 at offset 3: missing closing parenthesis
2210722107

22108-
/(?1:1/
22109-
Failed: error 218 at offset 4: missing opening parenthesis
22108+
/(?1(/
22109+
Failed: error 217 at offset 4: expected capture group number or name
2211022110

22111-
/(?R:(1/
22112-
Failed: error 114 at offset 6: missing closing parenthesis
22111+
/(?R(1/
22112+
Failed: error 114 at offset 5: missing closing parenthesis
2211322113

22114-
/(?R:(1,/
22115-
Failed: error 217 at offset 7: expected capture group number or name
22114+
/(?R(1,/
22115+
Failed: error 217 at offset 6: expected capture group number or name
2211622116

22117-
/(?R0:(1,2!/
22117+
/(?R0(1,2!/
2211822118
Failed: error 158 at offset 3: (?R (recursive pattern call) must be followed by a closing parenthesis
2211922119

22120-
/(?1:(1,0))()/
22121-
Failed: error 115 at offset 8: reference to non-existent subpattern
22122-
22123-
/(?1:(1,+2))()/
22120+
/(?1(1,0))()/
2212422121
Failed: error 115 at offset 7: reference to non-existent subpattern
2212522122

22126-
/(?1:(<name>))/
22123+
/(?1(1,+2))()/
22124+
Failed: error 115 at offset 6: reference to non-existent subpattern
22125+
22126+
/(?1(<name>))/
2212722127
Failed: error 115 at offset 3: reference to non-existent subpattern
2212822128

2212922129
# Operation tests
2213022130

22131-
/^(?1:(2))\2(?(DEFINE)(a(.)b(.)c))/B
22131+
/^(?1(2))\2(?(DEFINE)(a(.)b(.)c))/B
2213222132
------------------------------------------------------------------
2213322133
Bra
2213422134
^
@@ -22162,7 +22162,7 @@ No match
2216222162
axbycy
2216322163
No match
2216422164

22165-
/^((.)(?<id>.))(?1:('id'))(.)/B
22165+
/^((.)(?<id>.))(?1('id'))(.)/B
2216622166
------------------------------------------------------------------
2216722167
Bra
2216822168
^
@@ -22189,7 +22189,7 @@ No match
2218922189
3: d
2219022190
4: e
2219122191

22192-
/^(?1:(3,2,2,3,2))(?1:(3))(?(DEFINE)(a(.)b(.)c))/B
22192+
/^(?1(3,2,2,3,2))(?1(3))(?(DEFINE)(a(.)b(.)c))/B
2219322193
------------------------------------------------------------------
2219422194
Bra
2219522195
^
@@ -22221,7 +22221,7 @@ No match
2222122221
2: 1
2222222222
3: g
2222322223

22224-
/(?1:(2))#(?1:(3))#(?1:(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
22224+
/(?1(2))#(?1(3))#(?1(4))#(?(DEFINE)((.)\2(.)\3(.)\4))/
2222522225
aabbcc#ddeeff#gghhii!aabbcc#ddeeff#gghhii#
2222622226
0: aabbcc#ddeeff#gghhii#
2222722227
1: <unset>
@@ -22232,7 +22232,7 @@ No match
2223222232
aabbcc#ddeeff#gghhii
2223322233
No match
2223422234

22235-
/^(?1:(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
22235+
/^(?1(1,2)){2,4}(?(DEFINE)((..)#))xx#/B
2223622236
------------------------------------------------------------------
2223722237
Bra
2223822238
^
@@ -22288,7 +22288,7 @@ No match
2228822288
aa#bb#cc#dd#ee#xx#
2228922289
No match
2229022290

22291-
/^(?1:(1,2)){2,}+(?(DEFINE)((..)#))!/B
22291+
/^(?1(1,2)){2,}+(?(DEFINE)((..)#))!/B
2229222292
------------------------------------------------------------------
2229322293
Bra
2229422294
^
@@ -22332,15 +22332,15 @@ No match
2233222332
aa#bb#cc#dd#ee#
2233322333
No match
2233422334

22335-
/^(?1)(?(DEFINE)(<(?2:(3,4))><\4\3>)((..)(..)))/
22335+
/^(?1)(?(DEFINE)(<(?2(3,4))><\4\3>)((..)(..)))/
2233622336
<abcd><cdab>
2233722337
0: <abcd><cdab>
2233822338

2233922339
/(?1)#(?(DEFINE)(a(.(*ACCEPT).)b))/
2234022340
#axyb#axax#
2234122341
0: ax#
2234222342

22343-
/^(?>(?1:(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
22343+
/^(?>(?1(<n>)))!(?(DEFINE)((?<n>..)(?<n>..)))|abcde/dupnames
2234422344
abcd!
2234522345
0: abcd!
2234622346
1: <unset>
@@ -22349,7 +22349,7 @@ No match
2234922349
abcde
2235022350
0: abcde
2235122351

22352-
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R:(1))))+>/
22352+
/<(?:[^<>]*?(?:(AB)[^<>]*|)(?:|(?R(1))))+>/
2235322353
<aa<bb>cc<dd>ee>
2235422354
0: <aa<bb>cc<dd>ee>
2235522355
<aa<bb<cc>dd>ee<ff<gg>hh>ii>
@@ -22372,7 +22372,7 @@ No match
2237222372
0: <aa<bb<cc>dd>ee<ff<gg>hABhABh>ii>
2237322373
1: AB
2237422374

22375-
/(?:(?1:(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
22375+
/(?:(?1(<prefix>))#){4}(?(DEFINE)((?(<prefix>)\2)(?<prefix>.{3})))$/
2237622376
abc#abcdef#defghi#ghijkl#
2237722377
0: abc#abcdef#defghi#ghijkl#
2237822378
1: <unset>

0 commit comments

Comments
 (0)