Skip to content

Commit 78b7c5b

Browse files
committed
Ensure jitfast is used when set with replace in pcre2test
1 parent aadef0c commit 78b7c5b

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ all of a, b, and d as possible starting code units; now it sets only a and d.
197197

198198
54. Fix incorrect class character matches in JIT.
199199

200+
55. In pcre2test, ensure pcre2_jit_match() is used when jitfast is used with
201+
substitution testing.
202+
200203

201204
Version 10.42 11-December-2022
202205
------------------------------

src/pcre2test.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7513,9 +7513,9 @@ if (dat_datctl.replacement[0] != 0 && (dat_datctl.control & CTL_DFA) != 0)
75137513
dat_datctl.replacement[0] = 0;
75147514
}
75157515

7516-
/* If a replacement string is provided, call pcre2_substitute() instead of one
7517-
of the matching functions. First we have to convert the replacement string to
7518-
the appropriate width. */
7516+
/* If a replacement string is provided, call pcre2_substitute() instead of or
7517+
after one of the matching functions. First we have to convert the replacement
7518+
string to the appropriate width. */
75197519

75207520
if (dat_datctl.replacement[0] != 0)
75217521
{
@@ -7559,8 +7559,16 @@ if (dat_datctl.replacement[0] != 0)
75597559

75607560
if (emoption != 0)
75617561
{
7562-
PCRE2_MATCH(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
7563-
dat_datctl.options, match_data, use_dat_context);
7562+
if ((pat_patctl.control & CTL_JITFAST) != 0)
7563+
{
7564+
PCRE2_JIT_MATCH(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
7565+
dat_datctl.options, match_data, use_dat_context);
7566+
}
7567+
else
7568+
{
7569+
PCRE2_MATCH(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
7570+
dat_datctl.options, match_data, use_dat_context);
7571+
}
75647572
}
75657573

75667574
xoptions = emoption |

testdata/testinput17

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,8 @@
306306

307307
//jit
308308
\=null_subject
309+
310+
/(.)(.)/jitfast,replace=$2+$1
311+
ABCD
309312

310313
# End of testinput17

testdata/testoutput17

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,5 +553,9 @@ Failed: error -47: match limit exceeded
553553
//jit
554554
\=null_subject
555555
0: (JIT)
556+
557+
/(.)(.)/jitfast,replace=$2+$1
558+
ABCD
559+
1: B+ACD
556560

557561
# End of testinput17

0 commit comments

Comments
 (0)