From fdbb2313a659476e9e47c71964c78f4893867165 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Thu, 28 Mar 2019 09:40:12 +0900 Subject: [PATCH] refactoring --- src/regcomp.c | 28 ++++++++++++++-------------- src/regparse.c | 2 +- src/regparse.h | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/regcomp.c b/src/regcomp.c index 625b3a9..c0ef71a 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -604,7 +604,7 @@ compile_tree_empty_check(Node* node, regex_t* reg, int empty_info, ScanEnv* env) int r; int saved_num_null_check = reg->num_null_check; - if (empty_info != QUANT_BODY_IS_NOT_EMPTY) { + if (empty_info != BODY_IS_NOT_EMPTY) { r = add_op(reg, OP_EMPTY_CHECK_START); if (r != 0) return r; COP(reg)->empty_check_start.mem = reg->num_null_check; /* NULL CHECK ID */ @@ -614,12 +614,12 @@ compile_tree_empty_check(Node* node, regex_t* reg, int empty_info, ScanEnv* env) r = compile_tree(node, reg, env); if (r != 0) return r; - if (empty_info != QUANT_BODY_IS_NOT_EMPTY) { - if (empty_info == QUANT_BODY_IS_EMPTY) + if (empty_info != BODY_IS_NOT_EMPTY) { + if (empty_info == BODY_IS_EMPTY) r = add_op(reg, OP_EMPTY_CHECK_END); - else if (empty_info == QUANT_BODY_IS_EMPTY_MEM) + else if (empty_info == BODY_IS_EMPTY_MEM) r = add_op(reg, OP_EMPTY_CHECK_END_MEMST); - else if (empty_info == QUANT_BODY_IS_EMPTY_REC) + else if (empty_info == BODY_IS_EMPTY_REC) r = add_op(reg, OP_EMPTY_CHECK_END_MEMST_PUSH); if (r != 0) return r; @@ -969,7 +969,7 @@ compile_length_quantifier_node(QuantNode* qn, regex_t* reg) } } - if (empty_info == QUANT_BODY_IS_NOT_EMPTY) + if (empty_info == BODY_IS_NOT_EMPTY) mod_tlen = tlen; else mod_tlen = tlen + (SIZE_OP_EMPTY_CHECK_START + SIZE_OP_EMPTY_CHECK_END); @@ -1055,7 +1055,7 @@ compile_quantifier_node(QuantNode* qn, regex_t* reg, ScanEnv* env) } } - if (empty_info == QUANT_BODY_IS_NOT_EMPTY) + if (empty_info == BODY_IS_NOT_EMPTY) mod_tlen = tlen; else mod_tlen = tlen + (SIZE_OP_EMPTY_CHECK_START + SIZE_OP_EMPTY_CHECK_END); @@ -4005,7 +4005,7 @@ expand_case_fold_string(Node* node, regex_t* reg, int state) static enum QuantBodyEmpty quantifiers_memory_node_info(Node* node) { - int r = QUANT_BODY_IS_EMPTY; + int r = BODY_IS_EMPTY; switch (NODE_TYPE(node)) { case NODE_LIST: @@ -4022,7 +4022,7 @@ quantifiers_memory_node_info(Node* node) #ifdef USE_CALL case NODE_CALL: if (NODE_IS_RECURSION(node)) { - return QUANT_BODY_IS_EMPTY_REC; /* tiny version */ + return BODY_IS_EMPTY_REC; /* tiny version */ } else r = quantifiers_memory_node_info(NODE_BODY(node)); @@ -4044,9 +4044,9 @@ quantifiers_memory_node_info(Node* node) switch (en->type) { case BAG_MEMORY: if (NODE_IS_RECURSION(node)) { - return QUANT_BODY_IS_EMPTY_REC; + return BODY_IS_EMPTY_REC; } - return QUANT_BODY_IS_EMPTY_MEM; + return BODY_IS_EMPTY_MEM; break; case BAG_OPTION: @@ -4605,14 +4605,14 @@ setup_quant(Node* node, regex_t* reg, int state, ScanEnv* env) if (d == 0) { #ifdef USE_INSISTENT_CHECK_CAPTURES_IN_EMPTY_REPEAT qn->empty_info = quantifiers_memory_node_info(body); - if (qn->empty_info == QUANT_BODY_IS_EMPTY_REC) { + if (qn->empty_info == BODY_IS_EMPTY_REC) { if (NODE_TYPE(body) == NODE_BAG && BAG_(body)->type == BAG_MEMORY) { MEM_STATUS_ON(env->bt_mem_end, BAG_(body)->m.regnum); } } #else - qn->empty_info = QUANT_BODY_IS_EMPTY; + qn->empty_info = BODY_IS_EMPTY; #endif } } @@ -4646,7 +4646,7 @@ setup_quant(Node* node, regex_t* reg, int state, ScanEnv* env) } } - if (qn->greedy && (qn->empty_info == QUANT_BODY_IS_NOT_EMPTY)) { + if (qn->greedy && (qn->empty_info == 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.c b/src/regparse.c index 266bc11..13d32a9 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -2394,7 +2394,7 @@ node_new_quantifier(int lower, int upper, int by_number) QUANT_(node)->lower = lower; QUANT_(node)->upper = upper; QUANT_(node)->greedy = 1; - QUANT_(node)->empty_info = QUANT_BODY_IS_NOT_EMPTY; + QUANT_(node)->empty_info = BODY_IS_NOT_EMPTY; QUANT_(node)->head_exact = NULL_NODE; QUANT_(node)->next_head_exact = NULL_NODE; QUANT_(node)->is_refered = 0; diff --git a/src/regparse.h b/src/regparse.h index ae2e940..f673c1a 100644 --- a/src/regparse.h +++ b/src/regparse.h @@ -67,10 +67,10 @@ enum GimmickType { }; 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 + BODY_IS_NOT_EMPTY = 0, + BODY_IS_EMPTY = 1, + BODY_IS_EMPTY_MEM = 2, + BODY_IS_EMPTY_REC = 3 }; typedef struct { -- 2.40.0