Skip to content

Commit a892468

Browse files
k-takatanobu
authored andcommitted
Fix initialization of the table for quick search
This fixes k-takata/Onigmo#120. The commit k-takata/Onigmo@9c13de8 was insufficient. k-takata/Onigmo@1de602d
1 parent 54b9639 commit a892468

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

regcomp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4309,8 +4309,6 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg,
43094309

43104310
len = end - s;
43114311
if (len < ONIG_CHAR_TABLE_SIZE) {
4312-
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + 1);
4313-
43144312
if (ignore_case) {
43154313
for (i = 0; i < len; i += clen) {
43164314
p = s + i;
@@ -4339,6 +4337,8 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg,
43394337
}
43404338

43414339
len = end - s;
4340+
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
4341+
skip[i] = (UChar )(len + 1);
43424342
n = 0;
43434343
for (i = 0; i < len; i += clen) {
43444344
p = s + i;

test/ruby/test_regexp.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,10 @@ def test_conditional_expression
17431743
assert_raise(RegexpError, bug12418){ Regexp.new('(0?0|(?(5)||)|(?(5)||))?') }
17441744
end
17451745

1746+
def test_quick_search
1747+
assert_match_at('(?i) *TOOKY', 'Mozilla/5.0 (Linux; Android 4.0.3; TOOKY', [[34, 40]]) # Issue #120
1748+
end
1749+
17461750
def test_ss_in_look_behind
17471751
assert_match_at("(?i:ss)", "ss", [[0, 2]])
17481752
assert_match_at("(?i:ss)", "Ss", [[0, 2]])

0 commit comments

Comments
 (0)