Fix [Bug 19273], set correct value to outer_repeat on OP_REPEAT (#7035)

This commit is contained in:
TSUYUSATO Kitsune 2022-12-28 20:03:25 +09:00 committed by GitHub
parent 3931921607
commit b726d60c98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2022-12-28 11:03:53 +00:00
Merged-By: makenowjust <make.just.on@gmail.com>
2 changed files with 6 additions and 1 deletions

View File

@ -615,7 +615,7 @@ init_cache_index_table(regex_t* reg, OnigCacheIndex *table)
if (reg->repeat_range[mem].lower == 0) { if (reg->repeat_range[mem].lower == 0) {
table->addr = pbegin; table->addr = pbegin;
table->num = num - current_mem_num; table->num = num - current_mem_num;
table->outer_repeat = mem; table->outer_repeat = -1;
num++; num++;
table++; table++;
} }

View File

@ -1721,6 +1721,11 @@ class TestRegexp < Test::Unit::TestCase
end; end;
end end
def test_bug_19273 # [Bug #19273]
pattern = /(?:(?:-?b)|(?:-?(?:1_?(?:0_?)*)?0))(?::(?:(?:-?b)|(?:-?(?:1_?(?:0_?)*)?0))){0,3}/
assert_equal("10:0:0".match(pattern)[0], "10:0:0")
end
def test_linear_time_p def test_linear_time_p
assert_send [Regexp, :linear_time?, /a/] assert_send [Regexp, :linear_time?, /a/]
assert_send [Regexp, :linear_time?, 'a'] assert_send [Regexp, :linear_time?, 'a']