]> granicus.if.org Git - onig/commitdiff
disable OP_PUSH_OR_JUMP_EXACT1
authorK.Kosako <kosako@sofnec.co.jp>
Tue, 19 Feb 2019 04:37:24 +0000 (13:37 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Thu, 28 Feb 2019 05:28:18 +0000 (14:28 +0900)
src/regcomp.c
src/regexec.c
src/regint.h

index f44ac5cdc14206364c995ebf4c48892972792464..69c73c7f96d357050b0824aa4bccf6af5f359070 100644 (file)
@@ -811,9 +811,12 @@ compile_length_quantifier_node(QuantNode* qn, regex_t* reg)
     }
 
     if (qn->greedy) {
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
       if (IS_NOT_NULL(qn->head_exact))
         len += SIZE_OP_PUSH_OR_JUMP_EXACT1 + mod_tlen + SIZE_OP_JUMP;
-      else if (IS_NOT_NULL(qn->next_head_exact))
+      else
+#endif
+      if (IS_NOT_NULL(qn->next_head_exact))
         len += SIZE_OP_PUSH_IF_PEEK_NEXT + mod_tlen + SIZE_OP_JUMP;
       else
         len += SIZE_OP_PUSH + mod_tlen + SIZE_OP_JUMP;
@@ -888,9 +891,12 @@ compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env)
       r = add_op(reg, OP_JUMP);
       if (r != 0) return r;
       if (qn->greedy) {
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
         if (IS_NOT_NULL(qn->head_exact))
           COP(reg)->jump.addr = SIZE_OP_PUSH_OR_JUMP_EXACT1 + SIZE_INC_OP;
-        else if (IS_NOT_NULL(qn->next_head_exact))
+        else
+#endif
+        if (IS_NOT_NULL(qn->next_head_exact))
           COP(reg)->jump.addr = SIZE_OP_PUSH_IF_PEEK_NEXT + SIZE_INC_OP;
         else
           COP(reg)->jump.addr = SIZE_OP_PUSH + SIZE_INC_OP;
@@ -905,6 +911,7 @@ compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env)
     }
 
     if (qn->greedy) {
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
       if (IS_NOT_NULL(qn->head_exact)) {
         r = add_op(reg, OP_PUSH_OR_JUMP_EXACT1);
         if (r != 0) return r;
@@ -916,7 +923,9 @@ compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env)
 
         addr = -(mod_tlen + (int )SIZE_OP_PUSH_OR_JUMP_EXACT1);
       }
-      else if (IS_NOT_NULL(qn->next_head_exact)) {
+      else
+#endif
+      if (IS_NOT_NULL(qn->next_head_exact)) {
         r = add_op(reg, OP_PUSH_IF_PEEK_NEXT);
         if (r != 0) return r;
         COP(reg)->push_if_peek_next.addr = SIZE_INC_OP + mod_tlen + SIZE_OP_JUMP;
@@ -4450,7 +4459,6 @@ setup_quant(Node* node, regex_t* reg, int state, ScanEnv* env)
     }
   }
 
-#ifdef USE_OP_PUSH_OR_JUMP_EXACT
   if (qn->greedy && (qn->body_empty_info == QUANT_BODY_IS_NOT_EMPTY)) {
     if (NODE_TYPE(body) == NODE_QUANT) {
       QuantNode* tqn = QUANT_(body);
@@ -4463,7 +4471,6 @@ setup_quant(Node* node, regex_t* reg, int state, ScanEnv* env)
       qn->head_exact = get_head_value_node(NODE_BODY(node), 1, reg);
     }
   }
-#endif
 
   return r;
 }
index 99272b0cdde0791ea84ea453ea9b520548c37859..80c98cba93ce7e24643bee6a7a996b5e7133554b 100644 (file)
@@ -215,7 +215,9 @@ static OpInfoType OpInfo[] = {
   { OP_PUSH,                  "push"                  },
   { OP_PUSH_SUPER,            "push-super"            },
   { OP_POP_OUT,               "pop-out"               },
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
   { OP_PUSH_OR_JUMP_EXACT1,   "push-or-jump-e1"       },
+#endif
   { OP_PUSH_IF_PEEK_NEXT,     "push-if-peek-next"     },
   { OP_REPEAT,                "repeat"                },
   { OP_REPEAT_NG,             "repeat-ng"             },
@@ -461,12 +463,14 @@ onig_print_compiled_byte_code(FILE* f, Operation* p, Operation* start, OnigEncod
     p_rel_addr(f, addr, p, start);
     break;
 
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
   case OP_PUSH_OR_JUMP_EXACT1:
     addr = p->push_or_jump_exact1.addr;
     fputc(':', f);
     p_rel_addr(f, addr, p, start);
     p_string(f, 1, &(p->push_or_jump_exact1.c));
     break;
+#endif
 
   case OP_PUSH_IF_PEEK_NEXT:
     addr = p->push_if_peek_next.addr;
@@ -2513,7 +2517,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
   &&L_PUSH,
   &&L_PUSH_SUPER,
   &&L_POP_OUT,
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
   &&L_PUSH_OR_JUMP_EXACT1,
+#endif
   &&L_PUSH_IF_PEEK_NEXT,
   &&L_REPEAT,
   &&L_REPEAT_NG,
@@ -3699,6 +3705,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
       INC_OP;
       JUMP_OUT;
 
+ #ifdef USE_OP_PUSH_OR_JUMP_EXACT
     CASE_OP(PUSH_OR_JUMP_EXACT1)
       {
         UChar c;
@@ -3713,6 +3720,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
       }
       p += addr;
       JUMP_OUT;
+#endif
 
     CASE_OP(PUSH_IF_PEEK_NEXT)
       {
index c10b80acd88e2d6f9c0e584302944d172cb9e918..30df0a576cc1d7d9899589c3f4a8cf9691320159 100644 (file)
@@ -72,7 +72,7 @@
 #endif
 
 /* internal config */
-#define USE_OP_PUSH_OR_JUMP_EXACT
+/* #define USE_OP_PUSH_OR_JUMP_EXACT */
 #define USE_QUANT_PEEK_NEXT
 #define USE_ST_LIBRARY
 
@@ -565,7 +565,9 @@ enum OpCode {
   OP_PUSH,
   OP_PUSH_SUPER,
   OP_POP_OUT,
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
   OP_PUSH_OR_JUMP_EXACT1,  /* if match exact then push, else jump. */
+#endif
   OP_PUSH_IF_PEEK_NEXT,    /* if match exact then push, else none. */
   OP_REPEAT,               /* {n,m} */
   OP_REPEAT_NG,            /* {n,m}? (non greedy) */
@@ -662,7 +664,9 @@ typedef int ModeType;
 #define SIZE_OP_PUSH                   (SIZE_OPCODE + SIZE_RELADDR)
 #define SIZE_OP_PUSH_SUPER             (SIZE_OPCODE + SIZE_RELADDR)
 #define SIZE_OP_POP_OUT                 SIZE_OPCODE
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
 #define SIZE_OP_PUSH_OR_JUMP_EXACT1    (SIZE_OPCODE + SIZE_RELADDR + 1)
+#endif
 #define SIZE_OP_PUSH_IF_PEEK_NEXT      (SIZE_OPCODE + SIZE_RELADDR + 1)
 #define SIZE_OP_REPEAT_INC             (SIZE_OPCODE + SIZE_MEMNUM)
 #define SIZE_OP_REPEAT_INC_NG          (SIZE_OPCODE + SIZE_MEMNUM)
@@ -706,7 +710,9 @@ typedef int ModeType;
 #define SIZE_OP_PUSH                    1
 #define SIZE_OP_PUSH_SUPER              1
 #define SIZE_OP_POP_OUT                 1
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
 #define SIZE_OP_PUSH_OR_JUMP_EXACT1     1
+#endif
 #define SIZE_OP_PUSH_IF_PEEK_NEXT       1
 #define SIZE_OP_REPEAT                  1
 #define SIZE_OP_REPEAT_INC              1