From 02903b739a08cf4ee09612d7d171fee406f89822 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Fri, 16 Jun 2017 17:37:44 +0900 Subject: [PATCH] define NST_IN_CALLED flag and use it for bytecode compile --- src/regcomp.c | 5 ++++- src/regparse.h | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/regcomp.c b/src/regcomp.c index d28b98d..d947a3d 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -777,7 +777,7 @@ compile_range_repeat_node(QtfrNode* qn, int target_len, int empty_info, if ( #ifdef USE_SUBEXP_CALL - reg->num_call > 0 || + NODE_IS_IN_CALLED(qn) || #endif NODE_IS_IN_REPEAT(qn)) { r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC_SG : OP_REPEAT_INC_NG_SG); @@ -3851,6 +3851,9 @@ setup_qtfr(Node* node, regex_t* reg, int state, ScanEnv* env) if ((state & IN_REPEAT) != 0) { NODE_STATUS_ADD(node, NST_IN_REPEAT); } + if ((state & IN_CALL) != 0) { + NODE_STATUS_ADD(node, NST_IN_CALLED); + } if (IS_REPEAT_INFINITE(qn->upper) || qn->upper >= 1) { r = get_min_len(target, &d, env); diff --git a/src/regparse.h b/src/regparse.h index 354d746..eb0eeb2 100644 --- a/src/regparse.h +++ b/src/regparse.h @@ -131,8 +131,9 @@ typedef enum { #define NST_NAMED_GROUP (1<<9) #define NST_NAME_REF (1<<10) #define NST_IN_REPEAT (1<<11) /* STK_REPEAT is nested in stack. */ -#define NST_NEST_LEVEL (1<<12) -#define NST_BY_NUMBER (1<<13) /* {n,m} */ +#define NST_IN_CALLED (1<<12) +#define NST_NEST_LEVEL (1<<13) +#define NST_BY_NUMBER (1<<14) /* {n,m} */ #define NODE_STATUS(node) (((Node* )node)->u.base.status) #define NODE_STATUS_ADD(node,f) (NODE_STATUS(node) |= (f)) @@ -141,6 +142,7 @@ typedef enum { #define NODE_IS_BY_NUMBER(node) ((NODE_STATUS(node) & NST_BY_NUMBER) != 0) #define NODE_IS_IN_REPEAT(node) ((NODE_STATUS(node) & NST_IN_REPEAT) != 0) #define NODE_IS_CALLED(node) ((NODE_STATUS(node) & NST_CALLED) != 0) +#define NODE_IS_IN_CALLED(node) ((NODE_STATUS(node) & NST_IN_CALLED) != 0) #define NODE_IS_RECURSION(node) ((NODE_STATUS(node) & NST_RECURSION) != 0) #define NODE_IS_STOP_BT_SIMPLE_REPEAT(node) \ ((NODE_STATUS(node) & NST_STOP_BT_SIMPLE_REPEAT) != 0) -- 2.40.0