#define STK_MASK_TO_VOID_TARGET 0x10ff
#define STK_MASK_MEM_END_OR_MARK 0x8000 /* MEM_END or MEM_END_MARK */
+typedef struct _StackType {
+ unsigned int type;
+ union {
+ struct {
+ UChar *pcode; /* byte code position */
+ UChar *pstr; /* string position */
+ UChar *pstr_prev; /* previous char position of pstr */
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+ unsigned int state_check;
+#endif
+ } state;
+ struct {
+ int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
+ UChar *pcode; /* byte code position (head of repeated target) */
+ int num; /* repeat id */
+ } repeat;
+ struct {
+ OnigStackIndex si; /* index of stack */
+ } repeat_inc;
+ struct {
+ int num; /* memory num */
+ UChar *pstr; /* start/end position */
+ /* Following information is set, if this stack type is MEM-START */
+ OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
+ OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
+ } mem;
+ struct {
+ int num; /* null check id */
+ UChar *pstr; /* start position */
+ } empty_check;
+#ifdef USE_CALL
+ struct {
+ UChar *ret_addr; /* byte code position */
+ int num; /* null check id */
+ UChar *pstr; /* string position */
+ } call_frame;
+#endif
+ } u;
+} StackType;
+
+
#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
#define MATCH_ARG_INIT(msa, reg, arg_option, arg_region, arg_start) do {\
(msa).stack_p = (void* )0;\
if (msa->stack_p) {\
is_alloca = 0;\
alloc_base = msa->stack_p;\
- stk_base = (OnigStackType* )(alloc_base\
+ stk_base = (StackType* )(alloc_base\
+ (sizeof(OnigStackIndex) * msa->ptr_num));\
stk = stk_base;\
stk_end = stk_base + msa->stack_n;\
else if (msa->ptr_num > ALLOCA_PTR_NUM_LIMIT) {\
is_alloca = 0;\
alloc_base = (char* )xmalloc(sizeof(OnigStackIndex) * msa->ptr_num\
- + sizeof(OnigStackType) * (stack_num));\
+ + sizeof(StackType) * (stack_num));\
CHECK_NULL_RETURN_MEMERR(alloc_base);\
- stk_base = (OnigStackType* )(alloc_base\
+ stk_base = (StackType* )(alloc_base\
+ (sizeof(OnigStackIndex) * msa->ptr_num));\
stk = stk_base;\
stk_end = stk_base + (stack_num);\
else {\
is_alloca = 1;\
alloc_base = (char* )xalloca(sizeof(OnigStackIndex) * msa->ptr_num\
- + sizeof(OnigStackType) * (stack_num));\
+ + sizeof(StackType) * (stack_num));\
CHECK_NULL_RETURN_MEMERR(alloc_base);\
- stk_base = (OnigStackType* )(alloc_base\
+ stk_base = (StackType* )(alloc_base\
+ (sizeof(OnigStackIndex) * msa->ptr_num));\
stk = stk_base;\
stk_end = stk_base + (stack_num);\
msa->stack_n = stk_end - stk_base;\
if (is_alloca != 0) {\
size_t size = sizeof(OnigStackIndex) * msa->ptr_num \
- + sizeof(OnigStackType) * msa->stack_n;\
+ + sizeof(StackType) * msa->stack_n;\
msa->stack_p = xmalloc(size);\
CHECK_NULL_RETURN_MEMERR(msa->stack_p);\
xmemcpy(msa->stack_p, alloc_base, size);\
static int
stack_double(int is_alloca, char** arg_alloc_base,
- OnigStackType** arg_stk_base,
- OnigStackType** arg_stk_end, OnigStackType** arg_stk,
+ StackType** arg_stk_base,
+ StackType** arg_stk_end, StackType** arg_stk,
OnigMatchArg* msa)
{
unsigned int n;
size_t new_size;
char* alloc_base;
char* new_alloc_base;
- OnigStackType *stk_base, *stk_end, *stk;
+ StackType *stk_base, *stk_end, *stk;
alloc_base = *arg_alloc_base;
stk_base = *arg_stk_base;
stk = *arg_stk;
n = stk_end - stk_base;
- size = sizeof(OnigStackIndex) * msa->ptr_num + sizeof(OnigStackType) * n;
+ size = sizeof(OnigStackIndex) * msa->ptr_num + sizeof(StackType) * n;
n *= 2;
- new_size = sizeof(OnigStackIndex) * msa->ptr_num + sizeof(OnigStackType) * n;
+ new_size = sizeof(OnigStackIndex) * msa->ptr_num + sizeof(StackType) * n;
if (is_alloca != 0) {
new_alloc_base = (char* )xmalloc(new_size);
if (IS_NULL(new_alloc_base)) {
alloc_base = new_alloc_base;
used = stk - stk_base;
*arg_alloc_base = alloc_base;
- *arg_stk_base = (OnigStackType* )(alloc_base
+ *arg_stk_base = (StackType* )(alloc_base
+ (sizeof(OnigStackIndex) * msa->ptr_num));
*arg_stk = *arg_stk_base + used;
*arg_stk_end = *arg_stk_base + n;
} while(0)
#define STACK_STOP_BT_END do {\
- OnigStackType *k = stk;\
+ StackType *k = stk;\
while (1) {\
k--;\
STACK_BASE_CHECK(k, "STACK_STOP_BT_END"); \
} while(0)
#define STACK_EMPTY_CHECK(isnull,id,s) do {\
- OnigStackType* k = stk;\
+ StackType* k = stk;\
while (1) {\
k--;\
STACK_BASE_CHECK(k, "STACK_EMPTY_CHECK"); \
#ifdef USE_INSISTENT_CHECK_CAPTURES_STATUS_IN_ENDLESS_REPEAT
#define STACK_EMPTY_CHECK_MEMST(isnull,id,s,reg) do {\
- OnigStackType* k = stk;\
+ StackType* k = stk;\
while (1) {\
k--;\
STACK_BASE_CHECK(k, "STACK_EMPTY_CHECK_MEMST"); \
#define STACK_EMPTY_CHECK_MEMST_REC(isnull,id,s,reg) do {\
int level = 0;\
- OnigStackType* k = stk;\
+ StackType* k = stk;\
while (1) {\
k--;\
STACK_BASE_CHECK(k, "STACK_EMPTY_CHECK_MEMST_REC"); \
#else
#define STACK_EMPTY_CHECK_REC(isnull,id,s) do {\
int level = 0;\
- OnigStackType* k = stk;\
+ StackType* k = stk;\
while (1) {\
k--;\
STACK_BASE_CHECK(k, "STACK_EMPTY_CHECK_REC"); \
#define STACK_RETURN(addr) do {\
int level = 0;\
- OnigStackType* k = stk;\
+ StackType* k = stk;\
while (1) {\
k--;\
STACK_BASE_CHECK(k, "STACK_RETURN"); \
#ifdef USE_CAPTURE_HISTORY
static int
-make_capture_history_tree(OnigCaptureTreeNode* node, OnigStackType** kp,
- OnigStackType* stk_top, UChar* str, regex_t* reg)
+make_capture_history_tree(OnigCaptureTreeNode* node, StackType** kp,
+ StackType* stk_top, UChar* str, regex_t* reg)
{
int n, r;
OnigCaptureTreeNode* child;
- OnigStackType* k = *kp;
+ StackType* k = *kp;
while (k < stk_top) {
if (k->type == STK_MEM_START) {
}
static int backref_match_at_nested_level(regex_t* reg
- , OnigStackType* top, OnigStackType* stk_base
+ , StackType* top, StackType* stk_base
, int ignore_case, int case_fold_flag
, int nest, int mem_num, UChar* memp, UChar** s, const UChar* send)
{
UChar *ss, *p, *pstart, *pend = NULL_UCHARP;
int level;
- OnigStackType* k;
+ StackType* k;
level = 0;
k = top;
static int
backref_check_at_nested_level(regex_t* reg,
- OnigStackType* top, OnigStackType* stk_base,
+ StackType* top, StackType* stk_base,
int nest, int mem_num, UChar* memp)
{
int level;
- OnigStackType* k;
+ StackType* k;
level = 0;
k = top;
UChar *s, *q, *sbegin;
int is_alloca;
char *alloc_base;
- OnigStackType *stk_base, *stk, *stk_end;
- OnigStackType *stkp; /* used as any purpose. */
+ StackType *stk_base, *stk, *stk_end;
+ StackType *stkp; /* used as any purpose. */
OnigStackIndex si;
OnigStackIndex *repeat_stk;
OnigStackIndex *mem_start_stk, *mem_end_stk;