From 19a84e77a6adcc83cbbd0d0f480a9ee7806f310d Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Mon, 11 Dec 2017 15:11:25 +0900 Subject: [PATCH] refactoring --- src/regcomp.c | 12 ++++++------ src/regparse.h | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/regcomp.c b/src/regcomp.c index 2ac462c..97a5493 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -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)) { diff --git a/src/regparse.h b/src/regparse.h index 99fe7c9..e7cbf9f 100644 --- a/src/regparse.h +++ b/src/regparse.h @@ -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} */ -- 2.50.1