From 0a084cb995cb3d46f06f725dbfb115f3237bbd96 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Fri, 21 Sep 2018 16:00:01 +0900 Subject: [PATCH] remove int_map_backward member from re_pattern_buffer --- src/regcomp.c | 2 -- src/regexec.c | 66 --------------------------------------------------- src/regint.h | 1 - 3 files changed, 69 deletions(-) diff --git a/src/regcomp.c b/src/regcomp.c index 053ca85..6bd8825 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -5906,7 +5906,6 @@ onig_free_body(regex_t* reg) if (IS_NOT_NULL(reg)) { if (IS_NOT_NULL(reg->p)) xfree(reg->p); if (IS_NOT_NULL(reg->exact)) xfree(reg->exact); - if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward); if (IS_NOT_NULL(reg->repeat_range)) xfree(reg->repeat_range); if (IS_NOT_NULL(REG_EXTP(reg))) { free_regex_ext(REG_EXTP(reg)); @@ -6162,7 +6161,6 @@ onig_reg_init(regex_t* reg, OnigOptionType option, OnigCaseFoldType case_fold_fl (reg)->syntax = syntax; (reg)->optimize = 0; (reg)->exact = (UChar* )NULL; - (reg)->int_map_backward = (int* )NULL; REG_EXTPL(reg) = NULL; (reg)->p = (UChar* )NULL; diff --git a/src/regexec.c b/src/regexec.c index aff504f..5ac6654 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -4178,57 +4178,6 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end, return (UChar* )NULL; } -#ifdef USE_INT_MAP_BACKWARD -static int -set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED, int** skip) -{ - int i, len; - - if (IS_NULL(*skip)) { - *skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE); - if (IS_NULL(*skip)) return ONIGERR_MEMORY; - } - - len = end - s; - for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) - (*skip)[i] = len; - - for (i = len - 1; i > 0; i--) - (*skip)[s[i]] = i; - - return 0; -} - -static UChar* -bm_search_backward(regex_t* reg, const UChar* target, const UChar* target_end, - const UChar* text, const UChar* adjust_text, - const UChar* text_end, const UChar* text_start) -{ - const UChar *s, *t, *p; - - s = text_end - (target_end - target); - if (text_start < s) - s = text_start; - else - s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s); - - while (s >= text) { - p = s; - t = target; - while (t < target_end && *p == *t) { - p++; t++; - } - if (t == target_end) - return (UChar* )s; - - s -= reg->int_map_backward[*s]; - s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s); - } - - return (UChar* )NULL; -} -#endif - static UChar* map_search(OnigEncoding enc, UChar map[], const UChar* text, const UChar* text_range) @@ -4472,22 +4421,7 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end, case OPTIMIZE_EXACT_BM: case OPTIMIZE_EXACT_BM_NO_REV: -#ifdef USE_INT_MAP_BACKWARD - if (IS_NULL(reg->int_map_backward)) { - int r; - - if (s - range < BM_BACKWARD_SEARCH_LENGTH_THRESHOLD) - goto exact_method; - - r = set_bm_backward_skip(reg->exact, reg->exact_end, reg->enc, - &(reg->int_map_backward)); - if (r != 0) return r; - } - p = bm_search_backward(reg, reg->exact, reg->exact_end, range, adjrange, - end, p); -#else goto exact_method; -#endif break; case OPTIMIZE_MAP: diff --git a/src/regint.h b/src/regint.h index cd1cc7b..6dea894 100644 --- a/src/regint.h +++ b/src/regint.h @@ -299,7 +299,6 @@ struct re_pattern_buffer { unsigned char *exact; unsigned char *exact_end; unsigned char map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */ - int *int_map_backward; /* BM skip for backward search */ OnigLen dmin; /* min-distance of exact or map */ OnigLen dmax; /* max-distance of exact or map */ -- 2.40.0