Fix [Bug #20083]: correct a cache point size for atomic groups (#9367)

This commit is contained in:
Hiroya Fujinami 2023-12-28 23:20:03 +09:00 committed by GitHub
parent 87e8e961b7
commit d8702ddbfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -542,7 +542,7 @@ init_cache_opcodes(const regex_t* reg, OnigCacheOpcode* cache_opcodes, long* num
cache_opcodes->num_cache_points_at_outer_repeat = num_cache_points_at_repeat;\
cache_opcodes->num_cache_points_in_outer_repeat = 0;\
cache_opcodes->lookaround_nesting = lookaround_nesting;\
cache_point += lookaround_nesting > 0 ? 2 : 1;\
cache_point += lookaround_nesting != 0 ? 2 : 1;\
cache_opcodes++;\
} while (0)

View File

@ -1979,6 +1979,14 @@ class TestRegexp < Test::Unit::TestCase
end
end
def test_bug_20083 # [Bug #20083]
re = /([\s]*ABC)$/i
(1..100).each do |n|
text = "#{"0" * n}ABC"
assert text.match?(re)
end
end
def test_linear_time_p
assert_send [Regexp, :linear_time?, /a/]
assert_send [Regexp, :linear_time?, 'a']