}
#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
-/* set skip map for Sunday quick search */
static int
-set_sunday_quick_search_skip_table(UChar* s, UChar* end,
- OnigEncoding enc ARG_UNUSED, UChar skip[])
+set_sunday_quick_search_skip_table(UChar* s, UChar* end, OnigEncoding enc,
+ UChar skip[])
{
- int i, len;
+ int i, len, emin;
+
+ emin = ONIGENC_MBC_MINLEN(enc);
len = (int )(end - s);
- if (len + 1 >= ONIG_CHAR_TABLE_SIZE)
+ if (len + emin >= ONIG_CHAR_TABLE_SIZE)
return ONIGERR_PARSER_BUG;
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + 1);
+ for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + emin);
for (i = 0; i < len; i++)
- skip[s[i]] = len - i;
+ skip[s[i]] = len - i + (emin - 1);
return 0;
}
sunday_quick_search_step_forward(regex_t* reg,
const UChar* target, const UChar* target_end,
const UChar* text, const UChar* text_end,
- const UChar* text_range)
+ const UChar* text_range)
{
const UChar *s, *se, *t, *p, *end;
const UChar *tail;
int skip, tlen1;
+ int enc_minlen;
#ifdef ONIG_DEBUG_SEARCH
fprintf(stderr,
if (end + tlen1 > text_end)
end = text_end - tlen1;
+ enc_minlen = ONIGENC_MBC_MINLEN(reg->enc);
s = text;
while (s < end) {
if (t == target) return (UChar* )s;
p--; t--;
}
- if (se + 1 >= text_end) break;
- skip = reg->map[*(se + 1)];
+ if (se + enc_minlen >= text_end) break;
+ skip = reg->map[*(se + enc_minlen)];
t = s;
do {
s += enclen(reg->enc, s);
{
const UChar *s, *t, *p, *end;
const UChar *tail;
+ int enc_minlen;
end = text_range + (target_end - target);
if (end > text_end)
end = text_end;
+ enc_minlen = ONIGENC_MBC_MINLEN(reg->enc);
tail = target_end - 1;
s = text + (tail - target);
if (t == target) return (UChar* )p;
p--; t--;
}
- if (s + 1 >= text_end) break;
- s += reg->map[*(s + 1)];
+ if (s + enc_minlen >= text_end) break;
+ s += reg->map[*(s + enc_minlen)];
}
return (UChar* )NULL;