]> granicus.if.org Git - onig/commitdiff
refactoring
authorK.Kosako <kkosako0@gmail.com>
Sat, 22 Sep 2018 07:07:48 +0000 (16:07 +0900)
committerK.Kosako <kkosako0@gmail.com>
Sat, 22 Sep 2018 07:07:48 +0000 (16:07 +0900)
src/regcomp.c
src/regexec.c
src/regint.h

index 6bd882522f9f7bf446c228068c458511509e4f8f..ffe87105eda28d7aa2deeff656619461dc502d79 100644 (file)
@@ -4552,7 +4552,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
   return r;
 }
 
-/* set skip map for Boyer-Moore search */
+/* set skip map for Boyer-Moore-Horspool search */
 static int
 set_bm_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED, UChar skip[])
 {
@@ -5564,7 +5564,7 @@ set_optimize_exact(regex_t* reg, OptExact* e)
       if (r != 0) return r;
 
       reg->optimize = (allow_reverse != 0
-                       ? OPTIMIZE_EXACT_BM : OPTIMIZE_EXACT_BM_NO_REV);
+                       ? OPTIMIZE_EXACT_BMH : OPTIMIZE_EXACT_BMH_FORWARD);
     }
     else {
       reg->optimize = OPTIMIZE_EXACT;
@@ -5789,7 +5789,8 @@ print_anchor(FILE* f, int anchor)
 static void
 print_optimize_info(FILE* f, regex_t* reg)
 {
-  static const char* on[] = { "NONE", "EXACT", "EXACT_BM", "EXACT_BM_NOT_REV",
+  static const char* on[] = { "NONE", "EXACT",
+                              "EXACT_BMH", "EXACT_BMH_FORWARD",
                               "EXACT_IC", "MAP" };
 
   fprintf(f, "optimize: %s\n", on[reg->optimize]);
index 2e66744b719c8b78b42868fc7eef156736e7c3e4..609eec71a6b91f1782f65bb6b58d07f063a14581 100644 (file)
@@ -4113,16 +4113,16 @@ slow_search_backward_ic(OnigEncoding enc, int case_fold_flag,
 }
 
 static UChar*
-bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
-                 const UChar* text, const UChar* text_end,
-                 const UChar* text_range)
+bm_search_forward(regex_t* reg, const UChar* target, const UChar* target_end,
+                  const UChar* text, const UChar* text_end,
+                  const UChar* text_range)
 {
   const UChar *s, *se, *t, *p, *end;
   const UChar *tail;
   int skip, tlen1;
 
 #ifdef ONIG_DEBUG_SEARCH
-  fprintf(stderr, "bm_search_notrev: text: %p, text_end: %p, text_range: %p\n",
+  fprintf(stderr, "bm_search_forward: text: %p, text_end: %p, text_range: %p\n",
           text, text_end, text_range);
 #endif
 
@@ -4291,12 +4291,12 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
                        reg->exact, reg->exact_end, p, end, range);
     break;
 
-  case OPTIMIZE_EXACT_BM:
+  case OPTIMIZE_EXACT_BMH:
     p = bm_search(reg, reg->exact, reg->exact_end, p, end, range);
     break;
 
-  case OPTIMIZE_EXACT_BM_NO_REV:
-    p = bm_search_notrev(reg, reg->exact, reg->exact_end, p, end, range);
+  case OPTIMIZE_EXACT_BMH_FORWARD:
+    p = bm_search_forward(reg, reg->exact, reg->exact_end, p, end, range);
     break;
 
   case OPTIMIZE_MAP:
@@ -4419,8 +4419,8 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
                                 range, adjrange, end, p);
     break;
 
-  case OPTIMIZE_EXACT_BM:
-  case OPTIMIZE_EXACT_BM_NO_REV:
+  case OPTIMIZE_EXACT_BMH:
+  case OPTIMIZE_EXACT_BMH_FORWARD:
     goto exact_method;
     break;
 
index 6dea894391a86d7840ada55b45ba30e7b69be538..1782dbe26ab7c5a1fc7949fba7c54260f310d653 100644 (file)
@@ -316,12 +316,12 @@ enum StackPopLevel {
 
 /* optimize flags */
 enum OptimizeType {
-  OPTIMIZE_NONE            = 0,
-  OPTIMIZE_EXACT           = 1,  /* Slow Search */
-  OPTIMIZE_EXACT_BM        = 2,  /* Boyer Moore Search */
-  OPTIMIZE_EXACT_BM_NO_REV = 3,  /* BM   (but not simple match) */
-  OPTIMIZE_EXACT_IC        = 4,  /* Slow Search (ignore case) */
-  OPTIMIZE_MAP             = 5   /* char map */
+  OPTIMIZE_NONE              = 0,
+  OPTIMIZE_EXACT             = 1,  /* Slow Search */
+  OPTIMIZE_EXACT_BMH         = 2,  /* Boyer-Moore-Horspool */
+  OPTIMIZE_EXACT_BMH_FORWARD = 3,  /* Boyer-Moore-Horspool (forward) */
+  OPTIMIZE_EXACT_IC          = 4,  /* Slow Search (ignore case) */
+  OPTIMIZE_MAP               = 5   /* char map */
 };
 
 /* bit status */