Skip to content

Commit e76eae6

Browse files
author
Zoltan Herczeg
committed
Another fix for vreverse support in jit
1 parent 936fef2 commit e76eae6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/pcre2_jit_compile.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3093,8 +3093,16 @@ if (*cc == OP_COND || *cc == OP_SCOND)
30933093
has_alternatives = FALSE;
30943094

30953095
cc = next_opcode(common, cc);
3096+
30963097
if (has_alternatives)
3098+
{
3099+
if (*cc == OP_REVERSE)
3100+
cc += 1 + IMM2_SIZE;
3101+
else if (*cc == OP_VREVERSE)
3102+
cc += 1 + 2 * IMM2_SIZE;
3103+
30973104
current_offset = common->then_offsets + (cc - common->start);
3105+
}
30983106

30993107
while (cc < end)
31003108
{
@@ -3103,7 +3111,18 @@ while (cc < end)
31033111
else
31043112
{
31053113
if (*cc == OP_ALT && has_alternatives)
3106-
current_offset = common->then_offsets + (cc + 1 + LINK_SIZE - common->start);
3114+
{
3115+
cc += 1 + LINK_SIZE;
3116+
3117+
if (*cc == OP_REVERSE)
3118+
cc += 1 + IMM2_SIZE;
3119+
else if (*cc == OP_VREVERSE)
3120+
cc += 1 + 2 * IMM2_SIZE;
3121+
3122+
current_offset = common->then_offsets + (cc - common->start);
3123+
continue;
3124+
}
3125+
31073126
if (*cc >= OP_THEN && *cc <= OP_THEN_ARG && current_offset != NULL)
31083127
*current_offset = 1;
31093128
cc = next_opcode(common, cc);

src/pcre2_jit_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ static struct regression_test_case regression_test_cases[] = {
879879
{ MU, A, 0, 0, "(?!(?(?=a)ab|b(*THEN)d))bn|bnn", "bnn" },
880880
{ MU, A, 0, 0, "(?=(*THEN: ))* ", " " },
881881
{ MU, A, 0, 0, "a(*THEN)(?R) |", "a" },
882+
{ MU, A, 0, 0 | F_NOMATCH, "(?<!(*THEN)a|(*THEN)b|(*THEN)ab?|(*THEN)ba?|)", "c" },
882883

883884
/* Recurse and control verbs. */
884885
{ MU, A, 0, 0, "(a(*ACCEPT)b){0}a(?1)b", "aacaabb" },

0 commit comments

Comments
 (0)