]> granicus.if.org Git - onig/commitdiff
refactoring
authorK.Kosako <kosako@sofnec.co.jp>
Mon, 11 Dec 2017 06:11:25 +0000 (15:11 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Mon, 11 Dec 2017 06:11:25 +0000 (15:11 +0900)
src/regcomp.c
src/regparse.h

index 2ac462cbcd3cdfd8ed066a982410f80cba76237c..97a549328bbc99065fc7eeb4b8c0ff5f0249fb32 100644 (file)
@@ -831,7 +831,7 @@ compile_length_quantifier_node(QuantNode* qn, regex_t* reg)
   int len, mod_tlen, cklen;
   int ckn;
   int infinite = IS_REPEAT_INFINITE(qn->upper);
-  int empty_info = qn->body_empty_info;
+  enum QuantBodyEmpty empty_info = qn->body_empty_info;
   int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg);
 
   if (tlen < 0) return tlen;
@@ -910,7 +910,7 @@ compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env)
   int r, mod_tlen;
   int ckn;
   int infinite = IS_REPEAT_INFINITE(qn->upper);
-  int empty_info = qn->body_empty_info;
+  enum QuantBodyEmpty empty_info = qn->body_empty_info;
   int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg);
 
   if (tlen < 0) return tlen;
@@ -1063,7 +1063,7 @@ compile_length_quantifier_node(QuantNode* qn, regex_t* reg)
 {
   int len, mod_tlen;
   int infinite = IS_REPEAT_INFINITE(qn->upper);
-  int empty_info = qn->body_empty_info;
+  enum QuantBodyEmpty empty_info = qn->body_empty_info;
   int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg);
 
   if (tlen < 0) return tlen;
@@ -1129,7 +1129,7 @@ compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env)
 {
   int i, r, mod_tlen;
   int infinite = IS_REPEAT_INFINITE(qn->upper);
-  int empty_info = qn->body_empty_info;
+  enum QuantBodyEmpty empty_info = qn->body_empty_info;
   int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg);
 
   if (tlen < 0) return tlen;
@@ -4112,7 +4112,7 @@ setup_comb_exp_check(Node* node, int state, ScanEnv* env)
 #endif
 
 #ifdef USE_INSISTENT_CHECK_CAPTURES_STATUS_IN_ENDLESS_REPEAT
-static int
+static enum QuantBodyEmpty
 quantifiers_memory_node_info(Node* node)
 {
   int r = QUANT_BODY_IS_EMPTY;
@@ -4767,7 +4767,7 @@ 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 != 0)) {
+  if (qn->greedy && (qn->body_empty_info != QUANT_BODY_IS_NOT_EMPTY)) {
     if (NODE_TYPE(body) == NODE_QUANT) {
       QuantNode* tqn = QUANT_(body);
       if (IS_NOT_NULL(tqn->head_exact)) {
index 99fe7c9b9fe448d1c09a318d7b2d4b5ceb9b1bf4..e7cbf9f884a21a265d2652af3e8bda0a96b56e87 100644 (file)
@@ -129,10 +129,12 @@ enum EnclosureType {
 #define BACKREFS_P(br) \
   (IS_NOT_NULL((br)->back_dynamic) ? (br)->back_dynamic : (br)->back_static)
 
-#define QUANT_BODY_IS_NOT_EMPTY    0
-#define QUANT_BODY_IS_EMPTY        1
-#define QUANT_BODY_IS_EMPTY_MEM    2
-#define QUANT_BODY_IS_EMPTY_REC    3
+enum QuantBodyEmpty {
+  QUANT_BODY_IS_NOT_EMPTY = 0,
+  QUANT_BODY_IS_EMPTY     = 1,
+  QUANT_BODY_IS_EMPTY_MEM = 2,
+  QUANT_BODY_IS_EMPTY_REC = 3
+};
 
 /* node status bits */
 #define NST_MIN_FIXED             (1<<0)
@@ -221,7 +223,7 @@ typedef struct {
   int lower;
   int upper;
   int greedy;
-  int body_empty_info;
+  enum QuantBodyEmpty body_empty_info;
   struct _Node* head_exact;
   struct _Node* next_head_exact;
   int is_refered;     /* include called node. don't eliminate even if {0} */