From 80febad521ba48f98aeb6cb97b2cc615d37ac3cd Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Wed, 28 Aug 2019 09:13:41 +0900 Subject: [PATCH] refactoring --- src/regcomp.c | 36 ++++++++++++++++++------------------ src/regexec.c | 12 ++++++------ src/regint.h | 4 ++-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/regcomp.c b/src/regcomp.c index 559a316..03cd2e4 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -1277,7 +1277,7 @@ compile_length_bag_node(BagNode* node, regex_t* reg) if (NODE_IS_CALLED(node)) { len = OPSIZE_MEMORY_START_PUSH + tlen + OPSIZE_CALL + OPSIZE_JUMP + OPSIZE_RETURN; - if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) + if (MEM_STATUS_AT0(reg->push_mem_end, node->m.regnum)) len += (NODE_IS_RECURSION(node) ? OPSIZE_MEMORY_END_PUSH_REC : OPSIZE_MEMORY_END_PUSH); else @@ -1286,18 +1286,18 @@ compile_length_bag_node(BagNode* node, regex_t* reg) } else if (NODE_IS_RECURSION(node)) { len = OPSIZE_MEMORY_START_PUSH; - len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) + len += tlen + (MEM_STATUS_AT0(reg->push_mem_end, node->m.regnum) ? OPSIZE_MEMORY_END_PUSH_REC : OPSIZE_MEMORY_END_REC); } else #endif { - if (MEM_STATUS_AT0(reg->bt_mem_start, node->m.regnum)) + if (MEM_STATUS_AT0(reg->push_mem_start, node->m.regnum)) len = OPSIZE_MEMORY_START_PUSH; else len = OPSIZE_MEMORY_START; - len += tlen + (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum) + len += tlen + (MEM_STATUS_AT0(reg->push_mem_end, node->m.regnum) ? OPSIZE_MEMORY_END_PUSH : OPSIZE_MEMORY_END); } break; @@ -1390,7 +1390,7 @@ compile_bag_memory_node(BagNode* node, regex_t* reg, ScanEnv* env) else { len = compile_length_tree(NODE_BAG_BODY(node), reg); len += (OPSIZE_MEMORY_START_PUSH + OPSIZE_RETURN); - if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) + if (MEM_STATUS_AT0(reg->push_mem_end, node->m.regnum)) len += (NODE_IS_RECURSION(node) ? OPSIZE_MEMORY_END_PUSH_REC : OPSIZE_MEMORY_END_PUSH); else @@ -1404,7 +1404,7 @@ compile_bag_memory_node(BagNode* node, regex_t* reg, ScanEnv* env) } #endif - if (MEM_STATUS_AT0(reg->bt_mem_start, node->m.regnum)) + if (MEM_STATUS_AT0(reg->push_mem_start, node->m.regnum)) r = add_op(reg, OP_MEMORY_START_PUSH); else r = add_op(reg, OP_MEMORY_START); @@ -1415,7 +1415,7 @@ compile_bag_memory_node(BagNode* node, regex_t* reg, ScanEnv* env) if (r != 0) return r; #ifdef USE_CALL - if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) + if (MEM_STATUS_AT0(reg->push_mem_end, node->m.regnum)) r = add_op(reg, (NODE_IS_RECURSION(node) ? OP_MEMORY_END_PUSH_REC : OP_MEMORY_END_PUSH)); else @@ -1428,7 +1428,7 @@ compile_bag_memory_node(BagNode* node, regex_t* reg, ScanEnv* env) r = add_op(reg, OP_RETURN); } #else - if (MEM_STATUS_AT0(reg->bt_mem_end, node->m.regnum)) + if (MEM_STATUS_AT0(reg->push_mem_end, node->m.regnum)) r = add_op(reg, OP_MEMORY_END_PUSH); else r = add_op(reg, OP_MEMORY_END); @@ -6592,24 +6592,24 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, #endif reg->capture_history = scan_env.cap_history; - reg->bt_mem_start = scan_env.backtrack_mem | scan_env.cap_history; + reg->push_mem_start = scan_env.backtrack_mem | scan_env.cap_history; #ifdef USE_CALLOUT if (IS_NOT_NULL(reg->extp) && reg->extp->callout_num != 0) { - reg->bt_mem_end = reg->bt_mem_start; + reg->push_mem_end = reg->push_mem_start; } else { - if (MEM_STATUS_IS_ALL_ON(reg->bt_mem_start)) - reg->bt_mem_end = scan_env.backrefed_mem | scan_env.cap_history; + if (MEM_STATUS_IS_ALL_ON(reg->push_mem_start)) + reg->push_mem_end = scan_env.backrefed_mem | scan_env.cap_history; else - reg->bt_mem_end = reg->bt_mem_start & + reg->push_mem_end = reg->push_mem_start & (scan_env.backrefed_mem | scan_env.cap_history); } #else - if (MEM_STATUS_IS_ALL_ON(reg->bt_mem_start)) - reg->bt_mem_end = scan_env.backrefed_mem | scan_env.cap_history; + if (MEM_STATUS_IS_ALL_ON(reg->push_mem_start)) + reg->push_mem_end = scan_env.backrefed_mem | scan_env.cap_history; else - reg->bt_mem_end = reg->bt_mem_start & + reg->push_mem_end = reg->push_mem_start & (scan_env.backrefed_mem | scan_env.cap_history); #endif @@ -6645,14 +6645,14 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, } #endif - if ((reg->num_repeat != 0) || (reg->bt_mem_end != 0) + if ((reg->num_repeat != 0) || (reg->push_mem_end != 0) #ifdef USE_CALLOUT || (IS_NOT_NULL(reg->extp) && reg->extp->callout_num != 0) #endif ) reg->stack_pop_level = STACK_POP_LEVEL_ALL; else { - if (reg->bt_mem_start != 0) + if (reg->push_mem_start != 0) reg->stack_pop_level = STACK_POP_LEVEL_MEM_START; else reg->stack_pop_level = STACK_POP_LEVEL_FREE; diff --git a/src/regexec.c b/src/regexec.c index cc56cbe..de3e784 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -40,11 +40,11 @@ #define CHECK_INTERRUPT_IN_MATCH #define STACK_MEM_START(reg, i) \ - (MEM_STATUS_AT((reg)->bt_mem_start, (i)) != 0 ? \ + (MEM_STATUS_AT((reg)->push_mem_start, (i)) != 0 ? \ STACK_AT(mem_start_stk[i])->u.mem.pstr : (UChar* )((void* )(mem_start_stk[i]))) #define STACK_MEM_END(reg, i) \ - (MEM_STATUS_AT((reg)->bt_mem_end, (i)) != 0 ? \ + (MEM_STATUS_AT((reg)->push_mem_end, (i)) != 0 ? \ STACK_AT(mem_end_stk[i])->u.mem.pstr : (UChar* )((void* )(mem_end_stk[i]))) @@ -634,8 +634,8 @@ onig_print_compiled_byte_code_list(FILE* f, regex_t* reg) Operation* start = reg->ops; Operation* end = reg->ops + reg->ops_used; - fprintf(f, "bt_mem_start: 0x%x, bt_mem_end: 0x%x\n", - reg->bt_mem_start, reg->bt_mem_end); + fprintf(f, "push_mem_start: 0x%x, push_mem_end: 0x%x\n", + reg->push_mem_start, reg->push_mem_end); fprintf(f, "code-length: %d\n", reg->ops_used); bp = start; @@ -1938,7 +1938,7 @@ stack_double(int is_alloca, char** arg_alloc_base, (addr) = 0;\ }\ else {\ - if (MEM_STATUS_AT((reg)->bt_mem_end, k->zid))\ + if (MEM_STATUS_AT((reg)->push_mem_end, k->zid))\ (addr) = STACK_AT(k->u.mem.prev_end)->u.mem.pstr;\ else\ (addr) = (UChar* )k->u.mem.prev_end;\ @@ -3426,7 +3426,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, mem_end_stk[mem] = (StackIndex )((void* )s); STACK_GET_MEM_START(mem, stkp); - if (MEM_STATUS_AT(reg->bt_mem_start, mem)) + if (MEM_STATUS_AT(reg->push_mem_start, mem)) mem_start_stk[mem] = GET_STACK_INDEX(stkp); else mem_start_stk[mem] = (StackIndex )((void* )stkp->u.mem.pstr); diff --git a/src/regint.h b/src/regint.h index a8e1fa1..6dae378 100644 --- a/src/regint.h +++ b/src/regint.h @@ -908,8 +908,8 @@ struct re_pattern_buffer { int num_null_check; /* OP_EMPTY_CHECK_START/END id counter */ int num_call; /* number of subexp call */ unsigned int capture_history; /* (?@...) flag (1-31) */ - unsigned int bt_mem_start; /* need backtrack flag */ - unsigned int bt_mem_end; /* need backtrack flag */ + unsigned int push_mem_start; /* need backtrack flag */ + unsigned int push_mem_end; /* need backtrack flag */ unsigned int empty_status_mem; int stack_pop_level; int repeat_range_alloc; -- 2.40.0