From a89246834d8d2b60ece05b5ee34a012973b53df6 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Mon, 28 Jan 2019 18:52:39 +0900 Subject: 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 --- regcomp.c | 4 ++-- test/ruby/test_regexp.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/regcomp.c b/regcomp.c index 664806f085..3b738b1a67 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 b69c148305..2d7a67dd54 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1743,6 +1743,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]]) -- cgit v1.2.3