Skip to content

Commit

Permalink
Ensure jitfast is used when set with replace in pcre2test
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipHazel committed Dec 29, 2023
1 parent aadef0c commit 78b7c5b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ all of a, b, and d as possible starting code units; now it sets only a and d.

54. Fix incorrect class character matches in JIT.

55. In pcre2test, ensure pcre2_jit_match() is used when jitfast is used with
substitution testing.


Version 10.42 11-December-2022
------------------------------
Expand Down
18 changes: 13 additions & 5 deletions src/pcre2test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7513,9 +7513,9 @@ if (dat_datctl.replacement[0] != 0 && (dat_datctl.control & CTL_DFA) != 0)
dat_datctl.replacement[0] = 0;
}

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

if (dat_datctl.replacement[0] != 0)
{
Expand Down Expand Up @@ -7559,8 +7559,16 @@ if (dat_datctl.replacement[0] != 0)

if (emoption != 0)
{
PCRE2_MATCH(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
dat_datctl.options, match_data, use_dat_context);
if ((pat_patctl.control & CTL_JITFAST) != 0)
{
PCRE2_JIT_MATCH(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
dat_datctl.options, match_data, use_dat_context);
}
else
{
PCRE2_MATCH(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
dat_datctl.options, match_data, use_dat_context);
}
}

xoptions = emoption |
Expand Down
3 changes: 3 additions & 0 deletions testdata/testinput17
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,8 @@

//jit
\=null_subject

/(.)(.)/jitfast,replace=$2+$1
ABCD

# End of testinput17
4 changes: 4 additions & 0 deletions testdata/testoutput17
Original file line number Diff line number Diff line change
Expand Up @@ -553,5 +553,9 @@ Failed: error -47: match limit exceeded
//jit
\=null_subject
0: (JIT)

/(.)(.)/jitfast,replace=$2+$1
ABCD
1: B+ACD

# End of testinput17

0 comments on commit 78b7c5b

Please sign in to comment.