Skip to content

Commit 878e2d7

Browse files
committed
Fix test-only bug in pcre2_printint
Fixes #725, #726, #727 Found by YinChen001 <497907957@qq.com>
1 parent f515080 commit 878e2d7

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

src/pcre2_printint_inc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,25 +934,25 @@ for(;;)
934934

935935
case OP_REFI:
936936
flag = "/i";
937-
extra = code[1 + IMM2_SIZE];
938937
/* Fall through */
939938
case OP_REF:
940939
fprintf(f, " %s \\%d", flag, GET2(code,1));
941-
if (extra != 0) fprintf(f, " 0x%02x", extra);
940+
i = (*code == OP_REFI)? code[1 + IMM2_SIZE] : 0;
941+
if (i != 0) fprintf(f, " 0x%02x", i);
942942
ccode = code + OP_lengths[*code];
943943
goto CLASS_REF_REPEAT;
944944

945945
case OP_DNREFI:
946946
flag = "/i";
947-
extra = code[1 + 2*IMM2_SIZE];
948947
/* Fall through */
949948
case OP_DNREF:
950949
{
951950
PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE;
952951
fprintf(f, " %s \\k<", flag);
953952
print_custring(f, entry);
954953
fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
955-
if (extra != 0) fprintf(f, " 0x%02x", extra);
954+
i = (*code == OP_DNREFI)? code[1 + 2*IMM2_SIZE] : 0;
955+
if (i != 0) fprintf(f, " 0x%02x", i);
956956
}
957957
ccode = code + OP_lengths[*code];
958958
goto CLASS_REF_REPEAT;

testdata/testinput5

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,14 @@
23092309
s \x{17f}
23102310
k \x{212a}
23112311

2312+
/(.) \1 z/Bir
2313+
s s z
2314+
s S z
2315+
2316+
/(?J:(?<DNAME>s)|(?<DNAME>.)) \k<DNAME> z/Bir
2317+
s s z
2318+
s S z
2319+
23122320
/(.) \1/i,utf
23132321
s S
23142322
k K

testdata/testoutput5

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5273,6 +5273,50 @@ No match
52735273
k \x{212a}
52745274
No match
52755275

5276+
/(.) \1 z/Bir
5277+
------------------------------------------------------------------
5278+
Bra
5279+
CBra 1
5280+
Any
5281+
Ket
5282+
/i
5283+
/i \1 0x01
5284+
/i z
5285+
Ket
5286+
End
5287+
------------------------------------------------------------------
5288+
s s z
5289+
0: s s z
5290+
1: s
5291+
s S z
5292+
0: s S z
5293+
1: s
5294+
5295+
/(?J:(?<DNAME>s)|(?<DNAME>.)) \k<DNAME> z/Bir
5296+
------------------------------------------------------------------
5297+
Bra
5298+
Bra
5299+
CBra 1
5300+
/i s
5301+
Ket
5302+
Alt
5303+
CBra 2
5304+
Any
5305+
Ket
5306+
Ket
5307+
/i
5308+
/i \k<DNAME>2 0x01
5309+
/i z
5310+
Ket
5311+
End
5312+
------------------------------------------------------------------
5313+
s s z
5314+
0: s s z
5315+
1: s
5316+
s S z
5317+
0: s S z
5318+
1: s
5319+
52765320
/(.) \1/i,utf
52775321
s S
52785322
0: s S

0 commit comments

Comments
 (0)