summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK.Takata <kentkt@csc.jp>2019-01-28 18:52:39 +0900
committernagachika <nagachika@ruby-lang.org>2025-11-02 14:12:22 +0900
commitcd116d2ac5369b9d0f5ae4421c2994556ebbf0ad (patch)
tree6e2ca2a19b111a44bcedc4a404dcf0dda4043792
parent9f81d53068de6cd6ff96e7f102e6059c573b9005 (diff)
Fix initialization of the table for quick search
This fixes k-takata/Onigmo#120. The commit k-takata/Onigmo@9c13de8d0684ebde97e3709d7693997c81ca374b was insufficient. https://github.com/k-takata/Onigmo/commit/1de602ddff140d91419e3f86dd35c81d7bd2d8e7
-rw-r--r--regcomp.c4
-rw-r--r--test/ruby/test_regexp.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/regcomp.c b/regcomp.c
index 6f5a7ec782..3492108510 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4309,8 +4309,6 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg,
len = end - s;
if (len < ONIG_CHAR_TABLE_SIZE) {
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + 1);
-
if (ignore_case) {
for (i = 0; i < len; i += clen) {
p = s + i;
@@ -4339,6 +4337,8 @@ endcheck:
}
len = end - s;
+ for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
+ skip[i] = (UChar )(len + 1);
n = 0;
for (i = 0; i < len; i += clen) {
p = s + i;
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 0c9dc78fd6..cab60ee37b 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -1602,6 +1602,10 @@ class TestRegexp < Test::Unit::TestCase
assert_raise(RegexpError, bug12418){ Regexp.new('(0?0|(?(5)||)|(?(5)||))?') }
end
+ def test_quick_search
+ assert_match_at('(?i) *TOOKY', 'Mozilla/5.0 (Linux; Android 4.0.3; TOOKY', [[34, 40]]) # Issue #120
+ end
+
def test_ss_in_look_behind
assert_match_at("(?i:ss)", "ss", [[0, 2]])
assert_match_at("(?i:ss)", "Ss", [[0, 2]])