diff options
author | Zoltan Herczeg <hzmester@freemail.hu> | 2023-11-24 06:19:55 +0000 |
---|---|---|
committer | Zoltan Herczeg <hzmester@freemail.hu> | 2023-11-24 06:24:52 +0000 |
commit | e76eae69292162bedf31bf04c9403ebcb2f71d25 (patch) | |
tree | 72560ef6eb1a4d6fba1f8b15c87755bd0c1c7cb4 | |
parent | 936fef2a4480b21f5c43b207181097736fb311e3 (diff) | |
download | pcre-e76eae69292162bedf31bf04c9403ebcb2f71d25.tar.gz |
Another fix for vreverse support in jit
-rw-r--r-- | src/pcre2_jit_compile.c | 21 | ||||
-rw-r--r-- | src/pcre2_jit_test.c | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index 8110d8cc..2e11c3c3 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -3093,8 +3093,16 @@ if (*cc == OP_COND || *cc == OP_SCOND) has_alternatives = FALSE; cc = next_opcode(common, cc); + if (has_alternatives) + { + if (*cc == OP_REVERSE) + cc += 1 + IMM2_SIZE; + else if (*cc == OP_VREVERSE) + cc += 1 + 2 * IMM2_SIZE; + current_offset = common->then_offsets + (cc - common->start); + } while (cc < end) { @@ -3103,7 +3111,18 @@ while (cc < end) else { if (*cc == OP_ALT && has_alternatives) - current_offset = common->then_offsets + (cc + 1 + LINK_SIZE - common->start); + { + cc += 1 + LINK_SIZE; + + if (*cc == OP_REVERSE) + cc += 1 + IMM2_SIZE; + else if (*cc == OP_VREVERSE) + cc += 1 + 2 * IMM2_SIZE; + + current_offset = common->then_offsets + (cc - common->start); + continue; + } + if (*cc >= OP_THEN && *cc <= OP_THEN_ARG && current_offset != NULL) *current_offset = 1; cc = next_opcode(common, cc); diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c index 8bff3dcf..b5d95d57 100644 --- a/src/pcre2_jit_test.c +++ b/src/pcre2_jit_test.c @@ -879,6 +879,7 @@ static struct regression_test_case regression_test_cases[] = { { MU, A, 0, 0, "(?!(?(?=a)ab|b(*THEN)d))bn|bnn", "bnn" }, { MU, A, 0, 0, "(?=(*THEN: ))* ", " " }, { MU, A, 0, 0, "a(*THEN)(?R) |", "a" }, + { MU, A, 0, 0 | F_NOMATCH, "(?<!(*THEN)a|(*THEN)b|(*THEN)ab?|(*THEN)ba?|)", "c" }, /* Recurse and control verbs. */ { MU, A, 0, 0, "(a(*ACCEPT)b){0}a(?1)b", "aacaabb" }, |