34 # undef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE 36 # define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE 39 #ifndef USE_TOKEN_THREADED_VM 41 # define USE_TOKEN_THREADED_VM 1 43 # define USE_TOKEN_THREADED_VM 0 48 # define ENC_DUMMY_FLAG (1<<24) 54 # undef ONIGENC_IS_MBC_ASCII_WORD 55 # define ONIGENC_IS_MBC_ASCII_WORD(enc,s,end) \ 56 (rb_enc_asciicompat(enc) ? (ISALNUM(*s) || *s=='_') : \ 57 onigenc_ascii_is_code_ctype( \ 58 ONIGENC_MBC_TO_CODE(enc,s,end),ONIGENC_CTYPE_WORD,enc)) 61 #ifdef USE_CRNL_AS_LINE_TERMINATOR 62 # define ONIGENC_IS_MBC_CRNL(enc,p,end) \ 63 (ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \ 64 ONIGENC_MBC_TO_CODE(enc,(p+enclen(enc,p,end)),end) == 10) 65 # define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \ 66 is_mbc_newline_ex((enc),(p),(start),(end),(option),(check_prev)) 99 # define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \ 100 ONIGENC_IS_MBC_NEWLINE((enc), (p), (end)) 103 #ifdef USE_CAPTURE_HISTORY 114 history_tree_free(node->
childs[i]);
132 history_tree_clear(node);
146 history_node_new(
void)
165 # define HISTORY_TREE_INIT_ALLOC_SIZE 8 171 n = HISTORY_TREE_INIT_ALLOC_SIZE;
183 history_tree_clear(parent);
188 for (i = parent->
allocated; i < n; i++) {
205 clone = history_node_new();
211 child = history_tree_clone(node->
childs[i]);
213 history_tree_free(clone);
216 r = history_tree_add_child(clone, child);
218 history_tree_free(child);
219 history_tree_free(clone);
239 for (i = 0; i < region->
num_regs; i++) {
242 #ifdef USE_CAPTURE_HISTORY 243 history_root_free(region);
257 if (region->
beg == 0)
261 if (region->
end == 0) {
294 onig_region_resize_clear(
OnigRegion* region,
int n)
299 if (r != 0)
return r;
314 region->
beg[at] = beg;
315 region->
end[at] = end;
349 #ifdef USE_CAPTURE_HISTORY 350 history_root_free(r);
352 if (free_self)
xfree(r);
359 #define RREGC_SIZE (sizeof(int) * from->num_regs) 362 if (to == from)
return;
367 for (i = 0; i < from->
num_regs; i++) {
368 to->
beg[i] = from->
beg[i];
369 to->
end[i] = from->
end[i];
373 #ifdef USE_CAPTURE_HISTORY 374 history_root_free(to);
384 #define INVALID_STACK_INDEX -1 388 #define STK_ALT 0x0001 389 #define STK_LOOK_BEHIND_NOT 0x0002 390 #define STK_POS_NOT 0x0003 392 #define STK_MEM_START 0x0100 393 #define STK_MEM_END 0x8200 394 #define STK_REPEAT_INC 0x0300 395 #define STK_STATE_CHECK_MARK 0x1000 397 #define STK_NULL_CHECK_START 0x3000 398 #define STK_NULL_CHECK_END 0x5000 399 #define STK_MEM_END_MARK 0x8400 400 #define STK_POS 0x0500 401 #define STK_STOP_BT 0x0600 402 #define STK_REPEAT 0x0700 403 #define STK_CALL_FRAME 0x0800 404 #define STK_RETURN 0x0900 405 #define STK_VOID 0x0a00 406 #define STK_ABSENT_POS 0x0b00 407 #define STK_ABSENT 0x0c00 410 #define STK_MASK_POP_USED 0x00ff 411 #define STK_MASK_TO_VOID_TARGET 0x10ff 412 #define STK_MASK_MEM_END_OR_MARK 0x8000 414 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE 415 # define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\ 416 (msa).stack_p = (void* )0;\ 417 (msa).options = (arg_option);\ 418 (msa).region = (arg_region);\ 419 (msa).start = (arg_start);\ 420 (msa).gpos = (arg_gpos);\ 421 (msa).best_len = ONIG_MISMATCH;\ 424 # define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\ 425 (msa).stack_p = (void* )0;\ 426 (msa).options = (arg_option);\ 427 (msa).region = (arg_region);\ 428 (msa).start = (arg_start);\ 429 (msa).gpos = (arg_gpos);\ 433 #ifdef USE_COMBINATION_EXPLOSION_CHECK 435 # define STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE 16 437 # define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num) do { \ 438 if ((state_num) > 0 && str_len >= STATE_CHECK_STRING_THRESHOLD_LEN) {\ 439 unsigned int size = (unsigned int )(((str_len) + 1) * (state_num) + 7) >> 3;\ 440 offset = ((offset) * (state_num)) >> 3;\ 441 if (size > 0 && offset < size && size < STATE_CHECK_BUFF_MAX_SIZE) {\ 442 if (size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) {\ 443 (msa).state_check_buff = (void* )xmalloc(size);\ 444 CHECK_NULL_RETURN_MEMERR((msa).state_check_buff);\ 447 (msa).state_check_buff = (void* )xalloca(size);\ 448 xmemset(((char* )((msa).state_check_buff)+(offset)), 0, \ 449 (size_t )(size - (offset))); \ 450 (msa).state_check_buff_size = size;\ 453 (msa).state_check_buff = (void* )0;\ 454 (msa).state_check_buff_size = 0;\ 458 (msa).state_check_buff = (void* )0;\ 459 (msa).state_check_buff_size = 0;\ 463 # define MATCH_ARG_FREE(msa) do {\ 464 if ((msa).stack_p) xfree((msa).stack_p);\ 465 if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \ 466 if ((msa).state_check_buff) xfree((msa).state_check_buff);\ 470 # define MATCH_ARG_FREE(msa) if ((msa).stack_p) xfree((msa).stack_p) 475 #define MAX_PTR_NUM 100 477 #define STACK_INIT(alloc_addr, heap_addr, ptr_num, stack_num) do {\ 478 if (ptr_num > MAX_PTR_NUM) {\ 479 alloc_addr = (char* )xmalloc(sizeof(OnigStackIndex) * (ptr_num));\ 480 heap_addr = alloc_addr;\ 482 stk_alloc = (OnigStackType* )(msa->stack_p);\ 483 stk_base = stk_alloc;\ 485 stk_end = stk_base + msa->stack_n;\ 487 stk_alloc = (OnigStackType* )xalloca(sizeof(OnigStackType) * (stack_num));\ 488 stk_base = stk_alloc;\ 490 stk_end = stk_base + (stack_num);\ 492 } else if (msa->stack_p) {\ 493 alloc_addr = (char* )xalloca(sizeof(OnigStackIndex) * (ptr_num));\ 495 stk_alloc = (OnigStackType* )(msa->stack_p);\ 496 stk_base = stk_alloc;\ 498 stk_end = stk_base + msa->stack_n;\ 501 alloc_addr = (char* )xalloca(sizeof(OnigStackIndex) * (ptr_num)\ 502 + sizeof(OnigStackType) * (stack_num));\ 504 stk_alloc = (OnigStackType* )(alloc_addr + sizeof(OnigStackIndex) * (ptr_num));\ 505 stk_base = stk_alloc;\ 507 stk_end = stk_base + (stack_num);\ 511 #define STACK_SAVE do{\ 512 if (stk_base != stk_alloc) {\ 513 msa->stack_p = stk_base;\ 514 msa->stack_n = stk_end - stk_base; \ 523 return MatchStackLimitSize;
529 MatchStackLimitSize =
size;
540 stk_base = *arg_stk_base;
541 stk_end = *arg_stk_end;
544 n = stk_end - stk_base;
555 unsigned int limit_size = MatchStackLimitSize;
557 if (limit_size != 0 && n > limit_size) {
558 if ((
unsigned int )(stk_end - stk_base) == limit_size)
569 *arg_stk = x + (stk - stk_base);
571 *arg_stk_end = x + n;
575 #define STACK_ENSURE(n) do {\ 576 if (stk_end - stk < (n)) {\ 577 int r = stack_double(&stk_base, &stk_end, &stk, stk_alloc, msa);\ 580 if (xmalloc_base) xfree(xmalloc_base);\ 586 #define STACK_AT(index) (stk_base + (index)) 587 #define GET_STACK_INDEX(stk) ((stk) - stk_base) 589 #define STACK_PUSH_TYPE(stack_type) do {\ 591 stk->type = (stack_type);\ 595 #define IS_TO_VOID_TARGET(stk) (((stk)->type & STK_MASK_TO_VOID_TARGET) != 0) 597 #ifdef USE_COMBINATION_EXPLOSION_CHECK 598 # define STATE_CHECK_POS(s,snum) \ 599 (((s) - str) * num_comb_exp_check + ((snum) - 1)) 600 # define STATE_CHECK_VAL(v,snum) do {\ 601 if (state_check_buff != NULL) {\ 602 int x = STATE_CHECK_POS(s,snum);\ 603 (v) = state_check_buff[x/8] & (1<<(x%8));\ 609 # define ELSE_IF_STATE_CHECK_MARK(stk) \ 610 else if ((stk)->type == STK_STATE_CHECK_MARK) { \ 611 int x = STATE_CHECK_POS(stk->u.state.pstr, stk->u.state.state_check);\ 612 state_check_buff[x/8] |= (1<<(x%8)); \ 615 # define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\ 617 stk->type = (stack_type);\ 618 stk->u.state.pcode = (pat);\ 619 stk->u.state.pstr = (s);\ 620 stk->u.state.pstr_prev = (sprev);\ 621 stk->u.state.state_check = 0;\ 622 stk->u.state.pkeep = (keep);\ 626 # define STACK_PUSH_ENSURED(stack_type,pat) do {\ 627 stk->type = (stack_type);\ 628 stk->u.state.pcode = (pat);\ 629 stk->u.state.state_check = 0;\ 633 # define STACK_PUSH_ALT_WITH_STATE_CHECK(pat,s,sprev,snum,keep) do {\ 635 stk->type = STK_ALT;\ 636 stk->u.state.pcode = (pat);\ 637 stk->u.state.pstr = (s);\ 638 stk->u.state.pstr_prev = (sprev);\ 639 stk->u.state.state_check = ((state_check_buff != NULL) ? (snum) : 0);\ 640 stk->u.state.pkeep = (keep);\ 644 # define STACK_PUSH_STATE_CHECK(s,snum) do {\ 645 if (state_check_buff != NULL) {\ 647 stk->type = STK_STATE_CHECK_MARK;\ 648 stk->u.state.pstr = (s);\ 649 stk->u.state.state_check = (snum);\ 656 # define ELSE_IF_STATE_CHECK_MARK(stk) 658 # define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\ 660 stk->type = (stack_type);\ 661 stk->u.state.pcode = (pat);\ 662 stk->u.state.pstr = (s);\ 663 stk->u.state.pstr_prev = (sprev);\ 664 stk->u.state.pkeep = (keep);\ 668 # define STACK_PUSH_ENSURED(stack_type,pat) do {\ 669 stk->type = (stack_type);\ 670 stk->u.state.pcode = (pat);\ 675 #define STACK_PUSH_ALT(pat,s,sprev,keep) STACK_PUSH(STK_ALT,pat,s,sprev,keep) 676 #define STACK_PUSH_POS(s,sprev,keep) STACK_PUSH(STK_POS,NULL_UCHARP,s,sprev,keep) 677 #define STACK_PUSH_POS_NOT(pat,s,sprev,keep) STACK_PUSH(STK_POS_NOT,pat,s,sprev,keep) 678 #define STACK_PUSH_ABSENT STACK_PUSH_TYPE(STK_ABSENT) 679 #define STACK_PUSH_STOP_BT STACK_PUSH_TYPE(STK_STOP_BT) 680 #define STACK_PUSH_LOOK_BEHIND_NOT(pat,s,sprev,keep) \ 681 STACK_PUSH(STK_LOOK_BEHIND_NOT,pat,s,sprev,keep) 683 #define STACK_PUSH_REPEAT(id, pat) do {\ 685 stk->type = STK_REPEAT;\ 686 stk->u.repeat.num = (id);\ 687 stk->u.repeat.pcode = (pat);\ 688 stk->u.repeat.count = 0;\ 692 #define STACK_PUSH_REPEAT_INC(sindex) do {\ 694 stk->type = STK_REPEAT_INC;\ 695 stk->u.repeat_inc.si = (sindex);\ 699 #define STACK_PUSH_MEM_START(mnum, s) do {\ 701 stk->type = STK_MEM_START;\ 702 stk->u.mem.num = (mnum);\ 703 stk->u.mem.pstr = (s);\ 704 stk->u.mem.start = mem_start_stk[mnum];\ 705 stk->u.mem.end = mem_end_stk[mnum];\ 706 mem_start_stk[mnum] = GET_STACK_INDEX(stk);\ 707 mem_end_stk[mnum] = INVALID_STACK_INDEX;\ 711 #define STACK_PUSH_MEM_END(mnum, s) do {\ 713 stk->type = STK_MEM_END;\ 714 stk->u.mem.num = (mnum);\ 715 stk->u.mem.pstr = (s);\ 716 stk->u.mem.start = mem_start_stk[mnum];\ 717 stk->u.mem.end = mem_end_stk[mnum];\ 718 mem_end_stk[mnum] = GET_STACK_INDEX(stk);\ 722 #define STACK_PUSH_MEM_END_MARK(mnum) do {\ 724 stk->type = STK_MEM_END_MARK;\ 725 stk->u.mem.num = (mnum);\ 729 #define STACK_GET_MEM_START(mnum, k) do {\ 732 while (k > stk_base) {\ 734 if ((k->type & STK_MASK_MEM_END_OR_MARK) != 0 \ 735 && k->u.mem.num == (mnum)) {\ 738 else if (k->type == STK_MEM_START && k->u.mem.num == (mnum)) {\ 739 if (level == 0) break;\ 745 #define STACK_GET_MEM_RANGE(k, mnum, start, end) do {\ 748 if (k->type == STK_MEM_START && k->u.mem.num == (mnum)) {\ 749 if (level == 0) (start) = k->u.mem.pstr;\ 752 else if (k->type == STK_MEM_END && k->u.mem.num == (mnum)) {\ 755 (end) = k->u.mem.pstr;\ 763 #define STACK_PUSH_NULL_CHECK_START(cnum, s) do {\ 765 stk->type = STK_NULL_CHECK_START;\ 766 stk->u.null_check.num = (cnum);\ 767 stk->u.null_check.pstr = (s);\ 771 #define STACK_PUSH_NULL_CHECK_END(cnum) do {\ 773 stk->type = STK_NULL_CHECK_END;\ 774 stk->u.null_check.num = (cnum);\ 778 #define STACK_PUSH_CALL_FRAME(pat) do {\ 780 stk->type = STK_CALL_FRAME;\ 781 stk->u.call_frame.ret_addr = (pat);\ 785 #define STACK_PUSH_RETURN do {\ 787 stk->type = STK_RETURN;\ 791 #define STACK_PUSH_ABSENT_POS(start, end) do {\ 793 stk->type = STK_ABSENT_POS;\ 794 stk->u.absent_pos.abs_pstr = (start);\ 795 stk->u.absent_pos.end_pstr = (end);\ 801 # define STACK_BASE_CHECK(p, at) \ 802 if ((p) < stk_base) {\ 803 fprintf(stderr, "at %s\n", at);\ 807 # define STACK_BASE_CHECK(p, at) 810 #define STACK_POP_ONE do {\ 812 STACK_BASE_CHECK(stk, "STACK_POP_ONE"); \ 815 #define STACK_POP do {\ 816 switch (pop_level) {\ 817 case STACK_POP_LEVEL_FREE:\ 820 STACK_BASE_CHECK(stk, "STACK_POP"); \ 821 if ((stk->type & STK_MASK_POP_USED) != 0) break;\ 822 ELSE_IF_STATE_CHECK_MARK(stk);\ 825 case STACK_POP_LEVEL_MEM_START:\ 828 STACK_BASE_CHECK(stk, "STACK_POP 2"); \ 829 if ((stk->type & STK_MASK_POP_USED) != 0) break;\ 830 else if (stk->type == STK_MEM_START) {\ 831 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 832 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 834 ELSE_IF_STATE_CHECK_MARK(stk);\ 840 STACK_BASE_CHECK(stk, "STACK_POP 3"); \ 841 if ((stk->type & STK_MASK_POP_USED) != 0) break;\ 842 else if (stk->type == STK_MEM_START) {\ 843 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 844 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 846 else if (stk->type == STK_REPEAT_INC) {\ 847 STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\ 849 else if (stk->type == STK_MEM_END) {\ 850 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 851 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 853 ELSE_IF_STATE_CHECK_MARK(stk);\ 859 #define STACK_POP_TIL_POS_NOT do {\ 862 STACK_BASE_CHECK(stk, "STACK_POP_TIL_POS_NOT"); \ 863 if (stk->type == STK_POS_NOT) break;\ 864 else if (stk->type == STK_MEM_START) {\ 865 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 866 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 868 else if (stk->type == STK_REPEAT_INC) {\ 869 STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\ 871 else if (stk->type == STK_MEM_END) {\ 872 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 873 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 875 ELSE_IF_STATE_CHECK_MARK(stk);\ 879 #define STACK_POP_TIL_LOOK_BEHIND_NOT do {\ 882 STACK_BASE_CHECK(stk, "STACK_POP_TIL_LOOK_BEHIND_NOT"); \ 883 if (stk->type == STK_LOOK_BEHIND_NOT) break;\ 884 else if (stk->type == STK_MEM_START) {\ 885 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 886 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 888 else if (stk->type == STK_REPEAT_INC) {\ 889 STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\ 891 else if (stk->type == STK_MEM_END) {\ 892 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 893 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 895 ELSE_IF_STATE_CHECK_MARK(stk);\ 899 #define STACK_POP_TIL_ABSENT do {\ 902 STACK_BASE_CHECK(stk, "STACK_POP_TIL_ABSENT"); \ 903 if (stk->type == STK_ABSENT) break;\ 904 else if (stk->type == STK_MEM_START) {\ 905 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 906 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 908 else if (stk->type == STK_REPEAT_INC) {\ 909 STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\ 911 else if (stk->type == STK_MEM_END) {\ 912 mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ 913 mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\ 915 ELSE_IF_STATE_CHECK_MARK(stk);\ 919 #define STACK_POP_ABSENT_POS(start, end) do {\ 921 STACK_BASE_CHECK(stk, "STACK_POP_ABSENT_POS"); \ 922 (start) = stk->u.absent_pos.abs_pstr;\ 923 (end) = stk->u.absent_pos.end_pstr;\ 926 #define STACK_POS_END(k) do {\ 930 STACK_BASE_CHECK(k, "STACK_POS_END"); \ 931 if (IS_TO_VOID_TARGET(k)) {\ 934 else if (k->type == STK_POS) {\ 941 #define STACK_STOP_BT_END do {\ 942 OnigStackType *k = stk;\ 945 STACK_BASE_CHECK(k, "STACK_STOP_BT_END"); \ 946 if (IS_TO_VOID_TARGET(k)) {\ 949 else if (k->type == STK_STOP_BT) {\ 956 #define STACK_NULL_CHECK(isnull,id,s) do {\ 957 OnigStackType* k = stk;\ 960 STACK_BASE_CHECK(k, "STACK_NULL_CHECK"); \ 961 if (k->type == STK_NULL_CHECK_START) {\ 962 if (k->u.null_check.num == (id)) {\ 963 (isnull) = (k->u.null_check.pstr == (s));\ 970 #define STACK_NULL_CHECK_REC(isnull,id,s) do {\ 972 OnigStackType* k = stk;\ 975 STACK_BASE_CHECK(k, "STACK_NULL_CHECK_REC"); \ 976 if (k->type == STK_NULL_CHECK_START) {\ 977 if (k->u.null_check.num == (id)) {\ 979 (isnull) = (k->u.null_check.pstr == (s));\ 985 else if (k->type == STK_NULL_CHECK_END) {\ 991 #define STACK_NULL_CHECK_MEMST(isnull,id,s,reg) do {\ 992 OnigStackType* k = stk;\ 995 STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST"); \ 996 if (k->type == STK_NULL_CHECK_START) {\ 997 if (k->u.null_check.num == (id)) {\ 998 if (k->u.null_check.pstr != (s)) {\ 1006 if (k->type == STK_MEM_START) {\ 1007 if (k->u.mem.end == INVALID_STACK_INDEX) {\ 1008 (isnull) = 0; break;\ 1010 if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\ 1011 endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\ 1013 endp = (UChar* )k->u.mem.end;\ 1014 if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\ 1015 (isnull) = 0; break;\ 1017 else if (endp != s) {\ 1030 #define STACK_NULL_CHECK_MEMST_REC(isnull,id,s,reg) do {\ 1032 OnigStackType* k = stk;\ 1035 STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST_REC"); \ 1036 if (k->type == STK_NULL_CHECK_START) {\ 1037 if (k->u.null_check.num == (id)) {\ 1039 if (k->u.null_check.pstr != (s)) {\ 1047 if (k->type == STK_MEM_START) {\ 1048 if (k->u.mem.end == INVALID_STACK_INDEX) {\ 1049 (isnull) = 0; break;\ 1051 if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\ 1052 endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\ 1054 endp = (UChar* )k->u.mem.end;\ 1055 if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\ 1056 (isnull) = 0; break;\ 1058 else if (endp != s) {\ 1072 else if (k->type == STK_NULL_CHECK_END) {\ 1073 if (k->u.null_check.num == (id)) level++;\ 1078 #define STACK_GET_REPEAT(id, k) do {\ 1083 STACK_BASE_CHECK(k, "STACK_GET_REPEAT"); \ 1084 if (k->type == STK_REPEAT) {\ 1086 if (k->u.repeat.num == (id)) {\ 1091 else if (k->type == STK_CALL_FRAME) level--;\ 1092 else if (k->type == STK_RETURN) level++;\ 1096 #define STACK_RETURN(addr) do {\ 1098 OnigStackType* k = stk;\ 1101 STACK_BASE_CHECK(k, "STACK_RETURN"); \ 1102 if (k->type == STK_CALL_FRAME) {\ 1104 (addr) = k->u.call_frame.ret_addr;\ 1109 else if (k->type == STK_RETURN)\ 1115 #define STRING_CMP(s1,s2,len) do {\ 1116 while (len-- > 0) {\ 1117 if (*s1++ != *s2++) goto fail;\ 1121 #define STRING_CMP_IC(case_fold_flag,s1,ps2,len,text_end) do {\ 1122 if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len, text_end) == 0) \ 1126 static int string_cmp_ic(
OnigEncoding enc,
int case_fold_flag,
1131 UChar *p1, *p2, *end1, *s2;
1139 if (len1 != len2)
return 0;
1142 while (len1-- > 0) {
1143 if (*p1 != *p2)
return 0;
1153 #define STRING_CMP_VALUE(s1,s2,len,is_fail) do {\ 1155 while (len-- > 0) {\ 1156 if (*s1++ != *s2++) {\ 1157 is_fail = 1; break;\ 1162 #define STRING_CMP_VALUE_IC(case_fold_flag,s1,ps2,len,text_end,is_fail) do {\ 1163 if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len, text_end) == 0) \ 1170 #define IS_EMPTY_STR (str == end) 1171 #define ON_STR_BEGIN(s) ((s) == str) 1172 #define ON_STR_END(s) ((s) == end) 1173 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE 1174 # define DATA_ENSURE_CHECK1 (s < right_range) 1175 # define DATA_ENSURE_CHECK(n) (s + (n) <= right_range) 1176 # define DATA_ENSURE(n) if (s + (n) > right_range) goto fail 1177 # define ABSENT_END_POS right_range 1179 # define DATA_ENSURE_CHECK1 (s < end) 1180 # define DATA_ENSURE_CHECK(n) (s + (n) <= end) 1181 # define DATA_ENSURE(n) if (s + (n) > end) goto fail 1182 # define ABSENT_END_POS end 1186 #ifdef USE_CAPTURE_HISTORY 1195 while (k < stk_top) {
1200 child = history_node_new();
1203 child->
beg = k->
u.
mem.pstr - str;
1204 r = history_tree_add_child(node, child);
1206 history_tree_free(child);
1210 r = make_capture_history_tree(child, kp, stk_top, str, reg);
1211 if (r != 0)
return r;
1214 child->
end = k->
u.
mem.pstr - str;
1219 node->
end = k->
u.
mem.pstr - str;
1231 #ifdef USE_BACKREF_WITH_LEVEL 1232 static int mem_is_in_memp(
int mem,
int num,
UChar* memp)
1237 for (i = 0; i < num; i++) {
1239 if (mem == (
int )m)
return 1;
1244 static int backref_match_at_nested_level(
regex_t* reg,
1246 int ignore_case,
int case_fold_flag,
1256 while (k >= stk_base) {
1263 else if (level == nest) {
1265 if (mem_is_in_memp(k->
u.
mem.num, mem_num, memp)) {
1266 pstart = k->
u.
mem.pstr;
1268 if (pend - pstart > send - *s)
return 0;
1272 if (ignore_case != 0) {
1273 if (string_cmp_ic(reg->
enc, case_fold_flag,
1274 pstart, &ss, pend - pstart, send) == 0)
1279 if (*p++ != *ss++)
return 0;
1289 if (mem_is_in_memp(k->
u.
mem.num, mem_num, memp)) {
1290 pend = k->
u.
mem.pstr;
1302 #ifdef ONIG_DEBUG_STATISTICS 1305 # include <windows.h> 1306 static LARGE_INTEGER ts, te, freq;
1307 # define GETTIME(t) QueryPerformanceCounter(&(t)) 1308 # define TIMEDIFF(te,ts) (unsigned long )(((te).QuadPart - (ts).QuadPart) \ 1309 * 1000000 / freq.QuadPart) 1312 # define USE_TIMEOFDAY 1314 # ifdef USE_TIMEOFDAY 1315 # ifdef HAVE_SYS_TIME_H 1316 # include <sys/time.h> 1318 # ifdef HAVE_UNISTD_H 1322 # define GETTIME(t) gettimeofday(&(t), (struct timezone* )0) 1323 # define TIMEDIFF(te,ts) (((te).tv_usec - (ts).tv_usec) + \ 1324 (((te).tv_sec - (ts).tv_sec)*1000000)) 1326 # ifdef HAVE_SYS_TIMES_H 1327 # include <sys/times.h> 1329 static struct tms ts, te;
1330 # define GETTIME(t) times(&(t)) 1331 # define TIMEDIFF(te,ts) ((te).tms_utime - (ts).tms_utime) 1336 static int OpCounter[256];
1337 static int OpPrevCounter[256];
1338 static unsigned long OpTime[256];
1340 static int OpPrevTarget =
OP_FAIL;
1341 static int MaxStackDepth = 0;
1343 # define MOP_IN(opcode) do {\ 1344 if (opcode == OpPrevTarget) OpPrevCounter[OpCurr]++;\ 1346 OpCounter[opcode]++;\ 1350 # define MOP_OUT do {\ 1352 OpTime[OpCurr] += TIMEDIFF(te, ts);\ 1356 onig_statistics_init(
void)
1359 for (i = 0; i < 256; i++) {
1360 OpCounter[i] = OpPrevCounter[i] = 0; OpTime[i] = 0;
1364 QueryPerformanceFrequency(&freq);
1369 onig_print_statistics(
FILE*
f)
1372 fprintf(f,
" count prev time\n");
1373 for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
1374 fprintf(f,
"%8d: %8d: %10lu: %s\n",
1375 OpCounter[i], OpPrevCounter[i], OpTime[i], OnigOpInfo[i].
name);
1377 fprintf(f,
"\nmax stack depth: %d\n", MaxStackDepth);
1380 # define STACK_INC do {\ 1382 if (stk - stk_base > MaxStackDepth) \ 1383 MaxStackDepth = stk - stk_base;\ 1387 # define STACK_INC stk++ 1389 # define MOP_IN(opcode) 1394 #ifdef ONIG_DEBUG_MATCH 1398 switch (stack_type) {
1417 default:
return " ";
1426 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
1427 const UChar* right_range,
1433 int i, num_mem, pop_level;
1434 ptrdiff_t n, best_len;
1441 UChar *s, *q, *sbegin;
1445 char *xmalloc_base =
NULL;
1451 #ifdef USE_COMBINATION_EXPLOSION_CHECK 1453 unsigned char* state_check_buff = msa->state_check_buff;
1457 #if USE_TOKEN_THREADED_VM 1458 # define OP_OFFSET 1 1459 # define VM_LOOP JUMP; 1460 # define VM_LOOP_END 1461 # define CASE(x) L_##x: sbegin = s; OPCODE_EXEC_HOOK; 1462 # define DEFAULT L_DEFAULT: 1463 # define NEXT sprev = sbegin; JUMP 1464 # define JUMP goto *oplabels[*p++] 1466 static const void *oplabels[] = {
1490 &&L_OP_CCLASS_MB_NOT,
1491 &&L_OP_CCLASS_MIX_NOT,
1495 &&L_OP_ANYCHAR_STAR,
1496 &&L_OP_ANYCHAR_ML_STAR,
1497 &&L_OP_ANYCHAR_STAR_PEEK_NEXT,
1498 &&L_OP_ANYCHAR_ML_STAR_PEEK_NEXT,
1503 &&L_OP_NOT_WORD_BOUND,
1504 # ifdef USE_WORD_BEGIN_END 1512 &&L_OP_NOT_ASCII_WORD,
1513 &&L_OP_ASCII_WORD_BOUND,
1514 &&L_OP_NOT_ASCII_WORD_BOUND,
1515 # ifdef USE_WORD_BEGIN_END 1516 &&L_OP_ASCII_WORD_BEGIN,
1517 &&L_OP_ASCII_WORD_END,
1527 &&L_OP_SEMI_END_BUF,
1528 &&L_OP_BEGIN_POSITION,
1534 &&L_OP_BACKREF_MULTI,
1535 &&L_OP_BACKREF_MULTI_IC,
1536 # ifdef USE_BACKREF_WITH_LEVEL 1537 &&L_OP_BACKREF_WITH_LEVEL,
1541 &&L_OP_MEMORY_START,
1542 &&L_OP_MEMORY_START_PUSH,
1543 &&L_OP_MEMORY_END_PUSH,
1544 # ifdef USE_SUBEXP_CALL 1545 &&L_OP_MEMORY_END_PUSH_REC,
1550 # ifdef USE_SUBEXP_CALL 1551 &&L_OP_MEMORY_END_REC,
1562 # ifdef USE_OP_PUSH_OR_JUMP_EXACT 1563 &&L_OP_PUSH_OR_JUMP_EXACT1,
1567 &&L_OP_PUSH_IF_PEEK_NEXT,
1571 &&L_OP_REPEAT_INC_NG,
1572 &&L_OP_REPEAT_INC_SG,
1573 &&L_OP_REPEAT_INC_NG_SG,
1574 &&L_OP_NULL_CHECK_START,
1575 &&L_OP_NULL_CHECK_END,
1576 # ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT 1577 &&L_OP_NULL_CHECK_END_MEMST,
1581 # ifdef USE_SUBEXP_CALL 1582 &&L_OP_NULL_CHECK_END_MEMST_PUSH,
1589 &&L_OP_PUSH_POS_NOT,
1591 &&L_OP_PUSH_STOP_BT,
1594 &&L_OP_PUSH_LOOK_BEHIND_NOT,
1595 &&L_OP_FAIL_LOOK_BEHIND_NOT,
1596 &&L_OP_PUSH_ABSENT_POS,
1600 # ifdef USE_SUBEXP_CALL 1609 # ifdef USE_COMBINATION_EXPLOSION_CHECK 1610 &&L_OP_STATE_CHECK_PUSH,
1611 &&L_OP_STATE_CHECK_PUSH_OR_JUMP,
1618 # ifdef USE_COMBINATION_EXPLOSION_CHECK 1619 &&L_OP_STATE_CHECK_ANYCHAR_STAR,
1620 &&L_OP_STATE_CHECK_ANYCHAR_ML_STAR,
1627 &&L_OP_SET_OPTION_PUSH,
1636 # define OP_OFFSET 0 1642 # define VM_LOOP_END } sprev = sbegin; } 1643 # define CASE(x) case x: 1644 # define DEFAULT default: 1646 # define JUMP continue; break 1650 #ifdef USE_SUBEXP_CALL 1653 # define ADD_NUMMEM 1 1656 # define ADD_NUMMEM 0 1667 mem_end_stk = mem_start_stk + (num_mem +
ADD_NUMMEM);
1670 for (; pp < repeat_stk + n; pp += 2) {
1675 #ifndef USE_SUBEXP_CALL 1682 #ifdef ONIG_DEBUG_MATCH 1685 fprintf(stderr,
"size: %d, start offset: %d\n",
1686 (
int )(end - str), (
int )(sstart - str));
1687 fprintf(stderr,
"\n ofs> str stk:type addr:opcode\n");
1692 s = (
UChar* )sstart;
1693 pkeep = (
UChar* )sstart;
1696 #ifdef ONIG_DEBUG_MATCH 1697 # define OPCODE_EXEC_HOOK \ 1699 UChar *op, *q, *bp, buf[50]; \ 1701 op = p - OP_OFFSET; \ 1702 fprintf(stderr, "%4"PRIdPTR"> \"", (*op == OP_FINISH) ? (ptrdiff_t )-1 : s - str); \ 1705 if (*op != OP_FINISH) { \ 1706 for (i = 0; i < 7 && q < end; i++) { \ 1707 len = enclen(encode, q, end); \ 1708 while (len-- > 0) *bp++ = *q++; \ 1710 if (q < end) { xmemcpy(bp, "...", 3); bp += 3; } \ 1712 xmemcpy(bp, "\"", 1); bp += 1; \ 1714 fputs((char* )buf, stderr); \ 1715 for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr); \ 1716 fprintf(stderr, "%4"PRIdPTR":%s %4"PRIdPTR":", \ 1717 stk - stk_base - 1, \ 1718 (stk > stk_base) ? stack_type_str(stk[-1].type) : " ", \ 1719 (op == FinishCode) ? (ptrdiff_t )-1 : op - reg->p); \ 1720 onig_print_compiled_byte_code(stderr, op, reg->p+reg->used, NULL, encode); \ 1721 fprintf(stderr, "\n"); \ 1724 # define OPCODE_EXEC_HOOK ((void) 0) 1733 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE 1746 region->
beg[0] = ((pkeep > s) ? s : pkeep) - str;
1747 region->
end[0] = s - str;
1748 for (i = 1; i <= num_mem; i++) {
1751 region->
beg[i] =
STACK_AT(mem_start_stk[i])->u.mem.pstr - str;
1753 region->
beg[i] = (
UChar* )((
void* )mem_start_stk[i]) - str;
1756 ?
STACK_AT(mem_end_stk[i])->u.mem.pstr
1757 : (
UChar* )((
void* )mem_end_stk[i])) - str;
1764 #ifdef USE_CAPTURE_HISTORY 1775 history_tree_clear(node);
1779 node->
beg = ((pkeep > s) ? s : pkeep) - str;
1780 node->
end = s - str;
1783 r = make_capture_history_tree(region->
history_root, &stkp,
1784 stk, (
UChar* )str, reg);
1794 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE 1816 if (*p != *s)
goto fail;
1819 if (*p != *s++)
goto fail;
1849 if (*p != *s)
goto fail;
1851 if (*p != *s)
goto fail;
1859 if (*p != *s)
goto fail;
1861 if (*p != *s)
goto fail;
1863 if (*p != *s)
goto fail;
1871 if (*p != *s)
goto fail;
1873 if (*p != *s)
goto fail;
1875 if (*p != *s)
goto fail;
1877 if (*p != *s)
goto fail;
1885 if (*p != *s)
goto fail;
1887 if (*p != *s)
goto fail;
1889 if (*p != *s)
goto fail;
1891 if (*p != *s)
goto fail;
1893 if (*p != *s)
goto fail;
1902 while (tlen-- > 0) {
1903 if (*p++ != *s++)
goto fail;
1927 if (*p != *q)
goto fail;
1938 if (*p != *s)
goto fail;
1940 if (*p != *s)
goto fail;
1947 if (*p != *s)
goto fail;
1949 if (*p != *s)
goto fail;
1952 if (*p != *s)
goto fail;
1954 if (*p != *s)
goto fail;
1961 if (*p != *s)
goto fail;
1963 if (*p != *s)
goto fail;
1965 if (*p != *s)
goto fail;
1967 if (*p != *s)
goto fail;
1970 if (*p != *s)
goto fail;
1972 if (*p != *s)
goto fail;
1980 while (tlen-- > 0) {
1981 if (*p != *s)
goto fail;
1983 if (*p != *s)
goto fail;
1993 while (tlen-- > 0) {
1994 if (*p != *s)
goto fail;
1996 if (*p != *s)
goto fail;
1998 if (*p != *s)
goto fail;
2010 while (tlen2-- > 0) {
2011 if (*p != *s)
goto fail;
2022 s +=
enclen(encode, s, end);
2037 mb_len =
enclen(encode, s, end);
2043 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS 2077 s +=
enclen(encode, s, end);
2087 goto cc_mb_not_success;
2095 int mb_len =
enclen(encode, s, end);
2101 goto cc_mb_not_success;
2108 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS 2142 n =
enclen(encode, s, end);
2151 n =
enclen(encode, s, end);
2160 n =
enclen(encode, s, end);
2172 n =
enclen(encode, s, end);
2191 n =
enclen(encode, s, end);
2206 n =
enclen(encode, s, end);
2221 #ifdef USE_COMBINATION_EXPLOSION_CHECK 2225 STATE_CHECK_VAL(scv, mem);
2228 STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem, pkeep);
2229 n =
enclen(encode, s, end);
2243 STATE_CHECK_VAL(scv, mem);
2246 STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem, pkeep);
2247 n =
enclen(encode, s, end);
2267 s +=
enclen(encode, s, end);
2276 s +=
enclen(encode, s, end);
2285 s +=
enclen(encode, s, end);
2294 s +=
enclen(encode, s, end);
2368 #ifdef USE_WORD_BEGIN_END 2444 #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE 2450 #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE 2463 #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE 2469 #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE 2479 #ifdef USE_CRNL_AS_LINE_TERMINATOR 2482 ss +=
enclen(encode, ss, end);
2529 #ifdef USE_SUBEXP_CALL 2568 UChar *pstart, *pend;
2572 if (mem > num_mem)
goto fail;
2577 pstart =
STACK_AT(mem_start_stk[mem])->u.mem.pstr;
2579 pstart = (
UChar* )((
void* )mem_start_stk[mem]);
2582 ?
STACK_AT(mem_end_stk[mem])->u.mem.pstr
2583 : (
UChar* )((
void* )mem_end_stk[mem]));
2588 while (sprev + (len =
enclen(encode, sprev, end)) < s)
2599 UChar *pstart, *pend;
2603 if (mem > num_mem)
goto fail;
2608 pstart =
STACK_AT(mem_start_stk[mem])->u.mem.pstr;
2610 pstart = (
UChar* )((
void* )mem_start_stk[mem]);
2613 ?
STACK_AT(mem_end_stk[mem])->u.mem.pstr
2614 : (
UChar* )((
void* )mem_end_stk[mem]));
2619 while (sprev + (len =
enclen(encode, sprev, end)) < s)
2630 UChar *pstart, *pend, *swork;
2633 for (i = 0; i < tlen; i++) {
2640 pstart =
STACK_AT(mem_start_stk[mem])->u.mem.pstr;
2642 pstart = (
UChar* )((
void* )mem_start_stk[mem]);
2645 ?
STACK_AT(mem_end_stk[mem])->u.mem.pstr
2646 : (
UChar* )((
void* )mem_end_stk[mem]));
2652 if (is_fail)
continue;
2654 while (sprev + (len =
enclen(encode, sprev, end)) < s)
2660 if (i == tlen)
goto fail;
2669 UChar *pstart, *pend, *swork;
2672 for (i = 0; i < tlen; i++) {
2679 pstart =
STACK_AT(mem_start_stk[mem])->u.mem.pstr;
2681 pstart = (
UChar* )((
void* )mem_start_stk[mem]);
2684 ?
STACK_AT(mem_end_stk[mem])->u.mem.pstr
2685 : (
UChar* )((
void* )mem_end_stk[mem]));
2691 if (is_fail)
continue;
2693 while (sprev + (len =
enclen(encode, sprev, end)) < s)
2699 if (i == tlen)
goto fail;
2704 #ifdef USE_BACKREF_WITH_LEVEL 2716 if (backref_match_at_nested_level(reg, stk, stk_base, ic,
2717 case_fold_flag, (
int )level, (
int )tlen, p, &s, end)) {
2718 while (sprev + (len =
enclen(encode, sprev, end)) < s)
2759 #ifdef ONIG_DEBUG_MATCH 2760 fprintf(stderr,
"NULL_CHECK_END: skip id:%d, s:%"PRIuPTR
" (%p)\n",
2777 goto unexpected_bytecode_error;
2785 #ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT 2793 # ifdef ONIG_DEBUG_MATCH 2794 fprintf(stderr,
"NULL_CHECK_END_MEMST: skip id:%d, s:%"PRIuPTR
" (%p)\n",
2797 if (isnull == -1)
goto fail;
2798 goto null_check_found;
2805 #ifdef USE_SUBEXP_CALL 2812 # ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT 2818 # ifdef ONIG_DEBUG_MATCH 2819 fprintf(stderr,
"NULL_CHECK_END_MEMST_PUSH: skip id:%d, s:%"PRIuPTR
" (%p)\n",
2822 if (isnull == -1)
goto fail;
2823 goto null_check_found;
2846 #ifdef USE_COMBINATION_EXPLOSION_CHECK 2849 STATE_CHECK_VAL(scv, mem);
2853 STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem, pkeep);
2860 STATE_CHECK_VAL(scv, mem);
2865 STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem, pkeep);
2872 STATE_CHECK_VAL(scv, mem);
2875 STACK_PUSH_STATE_CHECK(s, mem);
2885 #ifdef USE_OP_PUSH_OR_JUMP_EXACT 2946 si = repeat_stk[mem];
2975 si = repeat_stk[mem];
3015 sprev = stkp->
u.
state.pstr_prev;
3082 UChar* selfp = p - 1;
3086 #ifdef ONIG_DEBUG_MATCH 3087 fprintf(stderr,
"ABSENT: s:%p, end:%p, absent:%p, aend:%p\n", s, end, absent, aend);
3089 if ((absent > aend) && (s > absent)) {
3095 else if ((s >= aend) && (s > absent)) {
3107 n =
enclen(encode, s, end);
3122 #ifdef ONIG_DEBUG_MATCH 3129 #ifdef USE_SUBEXP_CALL 3147 if ((mem > num_mem) ||
3169 sprev = stk->
u.
state.pstr_prev;
3170 pkeep = stk->
u.
state.pkeep;
3172 #ifdef USE_COMBINATION_EXPLOSION_CHECK 3173 if (stk->
u.
state.state_check != 0) {
3183 goto bytecode_error;
3188 if (xmalloc_base)
xfree(xmalloc_base);
3194 if (xmalloc_base)
xfree(xmalloc_base);
3200 if (xmalloc_base)
xfree(xmalloc_base);
3203 unexpected_bytecode_error:
3205 if (xmalloc_base)
xfree(xmalloc_base);
3214 UChar *t, *p, *s, *end;
3216 end = (
UChar* )text_end;
3217 end -= target_end - target - 1;
3218 if (end > text_range)
3227 if (*s == *target) {
3230 if (target_end == t ||
memcmp(t, p, target_end - t) == 0)
3238 if (*s == *target) {
3241 if (target_end == t ||
memcmp(t, p, target_end - t) == 0)
3244 s +=
enclen(enc, s, text_end);
3251 str_lower_case_match(
OnigEncoding enc,
int case_fold_flag,
3261 while (lowlen > 0) {
3262 if (*t++ != *q++)
return 0;
3277 end = (
UChar* )text_end;
3278 end -= target_end - target - 1;
3279 if (end > text_range)
3285 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3289 s +=
enclen(enc, s, text_end);
3298 const UChar* text_end,
const UChar* text_start)
3302 s = (
UChar* )text_end;
3303 s -= (target_end - target);
3305 s = (
UChar* )text_start;
3310 if (*s == *target) {
3313 while (t < target_end) {
3318 if (t == target_end)
3328 slow_search_backward_ic(
OnigEncoding enc,
int case_fold_flag,
3331 const UChar* text_end,
const UChar* text_start)
3335 s = (
UChar* )text_end;
3336 s -= (target_end - target);
3338 s = (
UChar* )text_start;
3343 if (str_lower_case_match(enc, case_fold_flag,
3344 target, target_end, s, text_end))
3353 #ifndef USE_SUNDAY_QUICK_SEARCH 3358 const UChar* text_range)
3360 const UChar *s, *se, *t, *p, *end;
3362 ptrdiff_t skip, tlen1;
3364 # ifdef ONIG_DEBUG_SEARCH 3365 fprintf(stderr,
"bm_search_notrev: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
3369 tail = target_end - 1;
3370 tlen1 = tail - target;
3372 if (end + tlen1 > text_end)
3373 end = text_end - tlen1;
3382 if (t == target)
return (
UChar* )s;
3385 skip = reg->
map[*se];
3389 }
while ((s - t) < skip && s < end);
3393 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3398 if (t == target)
return (
UChar* )s;
3405 }
while ((s - t) < skip && s < end);
3418 const UChar *s, *t, *p, *end;
3421 # ifdef ONIG_DEBUG_SEARCH 3422 fprintf(stderr,
"bm_search: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
3426 end = text_range + (target_end - target) - 1;
3430 tail = target_end - 1;
3431 s = text + (target_end - target) - 1;
3436 # ifdef ONIG_DEBUG_SEARCH 3437 fprintf(stderr,
"bm_search_loop: pos: %"PRIdPTR" %s\n",
3441 if (t == target)
return (
UChar* )p;
3448 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3453 if (t == target)
return (
UChar* )p;
3467 const UChar* text_range)
3469 const UChar *s, *se, *t, *end;
3471 ptrdiff_t skip, tlen1;
3475 # ifdef ONIG_DEBUG_SEARCH 3476 fprintf(stderr,
"bm_search_notrev_ic: text: %d (%p), text_end: %d (%p), text_range: %d (%p)\n",
3477 (
int )text, text, (
int )text_end, text_end, (
int )text_range, text_range);
3480 tail = target_end - 1;
3481 tlen1 = tail - target;
3483 if (end + tlen1 > text_end)
3484 end = text_end - tlen1;
3491 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3494 skip = reg->
map[*se];
3498 }
while ((s - t) < skip && s < end);
3502 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3505 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3512 }
while ((s - t) < skip && s < end);
3525 const UChar *s, *p, *end;
3530 # ifdef ONIG_DEBUG_SEARCH 3531 fprintf(stderr,
"bm_search_ic: text: %d (%p), text_end: %d (%p), text_range: %d (%p)\n",
3532 (
int )text, text, (
int )text_end, text_end, (
int )text_range, text_range);
3535 end = text_range + (target_end - target) - 1;
3539 tail = target_end - 1;
3540 s = text + (target_end - target) - 1;
3543 p = s - (target_end - target) + 1;
3544 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3551 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3553 p = s - (target_end - target) + 1;
3554 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3570 const UChar* text_range)
3572 const UChar *s, *se, *t, *p, *end;
3574 ptrdiff_t skip, tlen1;
3577 # ifdef ONIG_DEBUG_SEARCH 3578 fprintf(stderr,
"bm_search_notrev: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
3582 tail = target_end - 1;
3583 tlen1 = tail - target;
3585 if (end + tlen1 > text_end)
3586 end = text_end - tlen1;
3595 if (t == target)
return (
UChar* )s;
3598 if (s + 1 >= end)
break;
3599 skip = reg->
map[se[1]];
3602 s +=
enclen(enc, s, end);
3603 }
while ((s - t) < skip && s < end);
3607 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3612 if (t == target)
return (
UChar* )s;
3615 if (s + 1 >= end)
break;
3619 s +=
enclen(enc, s, end);
3620 }
while ((s - t) < skip && s < end);
3633 const UChar *s, *t, *p, *end;
3637 # ifdef ONIG_DEBUG_SEARCH 3638 fprintf(stderr,
"bm_search: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
3642 tail = target_end - 1;
3643 tlen1 = tail - target;
3644 end = text_range + tlen1;
3654 if (t == target)
return (
UChar* )p;
3657 if (s + 1 >= end)
break;
3658 s += reg->
map[s[1]];
3662 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3667 if (t == target)
return (
UChar* )p;
3670 if (s + 1 >= end)
break;
3682 const UChar* text_range)
3684 const UChar *s, *se, *t, *end;
3686 ptrdiff_t skip, tlen1;
3690 # ifdef ONIG_DEBUG_SEARCH 3691 fprintf(stderr,
"bm_search_notrev_ic: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
3695 tail = target_end - 1;
3696 tlen1 = tail - target;
3698 if (end + tlen1 > text_end)
3699 end = text_end - tlen1;
3706 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3709 if (s + 1 >= end)
break;
3710 skip = reg->
map[se[1]];
3713 s +=
enclen(enc, s, end);
3714 }
while ((s - t) < skip && s < end);
3718 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3721 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3724 if (s + 1 >= end)
break;
3728 s +=
enclen(enc, s, end);
3729 }
while ((s - t) < skip && s < end);
3742 const UChar *s, *p, *end;
3748 # ifdef ONIG_DEBUG_SEARCH 3749 fprintf(stderr,
"bm_search_ic: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
3753 tail = target_end - 1;
3754 tlen1 = tail - target;
3755 end = text_range + tlen1;
3763 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3766 if (s + 1 >= end)
break;
3767 s += reg->
map[s[1]];
3771 # if OPT_EXACT_MAXLEN >= ONIG_CHAR_TABLE_SIZE 3774 if (str_lower_case_match(enc, case_fold_flag, target, target_end,
3777 if (s + 1 >= end)
break;
3786 #ifdef USE_INT_MAP_BACKWARD 3798 len = (int )(end - s);
3802 for (i = len - 1; i > 0; i--)
3811 const UChar* text_end,
const UChar* text_start)
3813 const UChar *s, *t, *p;
3815 s = text_end - (target_end - target);
3824 while (t < target_end && *p == *t) {
3827 if (t == target_end)
3842 const UChar *s = text;
3844 while (s < text_range) {
3845 if (map[*s])
return (
UChar* )s;
3847 s +=
enclen(enc, s, text_end);
3855 const UChar* text_start,
const UChar* text_end)
3857 const UChar *s = text_start;
3860 if (map[*s])
return (
UChar* )s;
3876 #ifdef USE_COMBINATION_EXPLOSION_CHECK 3878 int offset = at - str;
3884 r = onig_region_resize_clear(region, reg->
num_mem + 1);
3891 r = match_at(reg, str, end,
3892 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
3908 #ifdef ONIG_DEBUG_SEARCH 3914 if (reg->
dmin > 0) {
3920 while (p < q) p +=
enclen(reg->
enc, p, end);
3939 p = bm_search_notrev(reg, reg->
exact, reg->
exact_end, p, end, range);
3943 p = bm_search_ic(reg, reg->
exact, reg->
exact_end, p, end, range);
3947 p = bm_search_notrev_ic(reg, reg->
exact, reg->
exact_end, p, end, range);
3951 p = map_search(reg->
enc, reg->
map, p, range, end);
3955 if (p && p < range) {
3956 if (p - reg->
dmin < s) {
3970 (pprev ? pprev : str), p, end);
3978 #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE 3980 (pprev ? pprev : str), p);
3991 if (reg->
dmax == 0) {
3998 (pprev ? pprev : str), p, end);
4003 *low = p - reg->
dmax;
4006 *low, end, (
const UChar** )low_prev);
4007 if (low_prev &&
IS_NULL(*low_prev))
4009 (pprev ? pprev : s), *low, end);
4014 (pprev ? pprev : str), *low, end);
4019 *high = p - reg->
dmin;
4021 #ifdef ONIG_DEBUG_SEARCH 4024 *low - str, *high - str, reg->
dmin, reg->
dmax);
4032 #define BM_BACKWARD_SEARCH_LENGTH_THRESHOLD 100 4049 range, adjrange, end, p);
4057 range, adjrange, end, p);
4062 #ifdef USE_INT_MAP_BACKWARD 4072 p = bm_search_backward(reg, reg->
exact, reg->
exact_end, range, adjrange,
4080 p = map_search_backward(reg->
enc, reg->
map, range, adjrange, p, end);
4101 #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE 4121 *low = p - reg->
dmax;
4122 *high = p - reg->
dmin;
4126 #ifdef ONIG_DEBUG_SEARCH 4127 fprintf(stderr,
"backward_search_range: low: %d, high: %d\n",
4128 (
int )(*low - str), (
int )(*high - str));
4134 #ifdef ONIG_DEBUG_SEARCH 4135 fprintf(stderr,
"backward_search_range: fail.\n");
4145 return onig_search_gpos(reg, str, end, start, start, range, region, option);
4150 const UChar* global_pos,
4156 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE 4157 const UChar *orig_start = start;
4161 #ifdef ONIG_DEBUG_SEARCH 4164 (
uintptr_t )str, str, end - str, start - str, range - str);
4168 r = onig_region_resize_clear(region, reg->
num_mem + 1);
4169 if (r)
goto finish_no_msa;
4172 if (start > end || start < str)
goto mismatch_no_msa;
4175 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE 4176 # ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE 4177 # define MATCH_AND_RETURN_CHECK(upper_range) \ 4178 r = match_at(reg, str, end, (upper_range), s, prev, &msa); \ 4179 if (r != ONIG_MISMATCH) {\ 4181 if (! IS_FIND_LONGEST(reg->options)) {\ 4188 # define MATCH_AND_RETURN_CHECK(upper_range) \ 4189 r = match_at(reg, str, end, (upper_range), s, prev, &msa); \ 4190 if (r != ONIG_MISMATCH) {\ 4198 # ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE 4199 # define MATCH_AND_RETURN_CHECK(none) \ 4200 r = match_at(reg, str, end, s, prev, &msa);\ 4201 if (r != ONIG_MISMATCH) {\ 4203 if (! IS_FIND_LONGEST(reg->options)) {\ 4210 # define MATCH_AND_RETURN_CHECK(none) \ 4211 r = match_at(reg, str, end, s, prev, &msa);\ 4212 if (r != ONIG_MISMATCH) {\ 4223 if (reg->
anchor != 0 && str < end) {
4224 UChar *min_semi_end, *max_semi_end;
4231 if (global_pos > start)
4233 if (global_pos < range)
4234 range = global_pos + 1;
4244 if (range > start) {
4245 if (start != str)
goto mismatch_no_msa;
4254 goto mismatch_no_msa;
4258 min_semi_end = max_semi_end = (
UChar* )end;
4262 goto mismatch_no_msa;
4264 if (range > start) {
4274 if (start > range)
goto mismatch_no_msa;
4286 if (range > start)
goto mismatch_no_msa;
4292 max_semi_end = (
UChar* )end;
4294 min_semi_end = pre_end;
4296 #ifdef USE_CRNL_AS_LINE_TERMINATOR 4301 min_semi_end = pre_end;
4304 if (min_semi_end > str && start <= min_semi_end) {
4309 min_semi_end = (
UChar* )end;
4314 goto begin_position;
4317 else if (str == end) {
4318 static const UChar address_for_empty_string[] =
"";
4320 #ifdef ONIG_DEBUG_SEARCH 4321 fprintf(stderr,
"onig_search: empty string.\n");
4325 start = end = str = address_for_empty_string;
4330 #ifdef USE_COMBINATION_EXPLOSION_CHECK 4331 msa.state_check_buff = (
void* )0;
4332 msa.state_check_buff_size = 0;
4337 goto mismatch_no_msa;
4340 #ifdef ONIG_DEBUG_SEARCH 4341 fprintf(stderr,
"onig_search(apply anchor): end: %d, start: %d, range: %d\n",
4342 (
int )(end - str), (
int )(start - str), (
int )(range - str));
4346 #ifdef USE_COMBINATION_EXPLOSION_CHECK 4348 int offset = (
MIN(start, range) - str);
4354 if (range > start) {
4361 UChar *sch_range, *low, *high, *low_prev;
4363 sch_range = (
UChar* )range;
4364 if (reg->
dmax != 0) {
4366 sch_range = (
UChar* )end;
4368 sch_range += reg->
dmax;
4369 if (sch_range > end) sch_range = (
UChar* )end;
4378 if (! forward_search_range(reg, str, end, s, sch_range,
4379 &low, &high, &low_prev))
goto mismatch;
4389 }
while (s < range);
4393 if (! forward_search_range(reg, str, end, s, sch_range,
4394 &low, &high, (
UChar** )
NULL))
goto mismatch;
4409 }
while (s < range);
4419 }
while (s < range);
4427 UChar *low, *high, *adjrange, *sch_start;
4432 adjrange = (
UChar* )end;
4437 sch_start = s + reg->
dmax;
4438 if (sch_start > end) sch_start = (
UChar* )end;
4439 if (backward_search_range(reg, str, end, sch_start, range, adjrange,
4451 }
while (s >= range);
4458 if (reg->
dmax != 0) {
4460 sch_start = (
UChar* )end;
4462 sch_start += reg->
dmax;
4463 if (sch_start > end) sch_start = (
UChar* )end;
4466 start, sch_start, end);
4469 if (backward_search_range(reg, str, end, sch_start, range, adjrange,
4470 &low, &high) <= 0)
goto mismatch;
4478 }
while (s >= range);
4482 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE 4503 fprintf(stderr,
"onig_search: error %"PRIdPTRDIFF"\n", r);
4512 fprintf(stderr,
"onig_search: error %"PRIdPTRDIFF"\n", r);
4535 r =
onig_search(reg, str, end, start, end, region, option);
4537 rs = scan_callback(n, r, region, callback_arg);
4542 if (region->
end[0] == start - str)
4545 start = str + region->
end[0];
4594 #ifdef USE_CAPTURE_HISTORY unsigned int OnigOptionType
#define STACK_PUSH_POS_NOT(pat, s, sprev, keep)
int onig_region_resize(OnigRegion *region, int n)
#define ANCHOR_ANYCHAR_STAR_ML
#define BIT_STATUS_AT(stats, n)
#define IS_NOTEOS(option)
#define ONIGERR_MATCH_STACK_LIMIT_OVER
unsigned int onig_get_match_stack_limit_size(void)
#define STACK_RETURN(addr)
unsigned int OnigCodePoint
#define STK_LOOK_BEHIND_NOT
#define ONIG_REGION_NOTPOS
ONIG_EXTERN OnigUChar * onigenc_get_right_adjust_char_head(OnigEncoding enc, const OnigUChar *start, const OnigUChar *s, const OnigUChar *end)
#define STACK_GET_MEM_START(mnum, k)
struct _OnigStackType::@95::@97 repeat
#define DATA_ENSURE_CHECK(n)
#define STACK_PUSH_ABSENT
union _OnigStackType::@95 u
#define IS_NOTEOL(option)
#define STACK_PUSH_STOP_BT
#define STACK_PUSH_MEM_END_MARK(mnum)
#define ONIG_OPTIMIZE_EXACT
#define ONIGENC_IS_MBC_HEAD(enc, p, e)
#define STACK_POP_TIL_POS_NOT
#define STACK_PUSH_ENSURED(stack_type, pat)
OnigPosition onig_scan(regex_t *reg, const UChar *str, const UChar *end, OnigRegion *region, OnigOptionType option, int(*scan_callback)(OnigPosition, OnigPosition, OnigRegion *, void *), void *callback_arg)
#define STACK_POP_ABSENT_POS(start, end)
#define ANCHOR_BEGIN_LINE
#define STACK_PUSH_ABSENT_POS(start, end)
int onig_number_of_capture_histories(const regex_t *reg)
int onig_set_match_stack_limit_size(unsigned int size)
int onig_is_in_code_range(const UChar *p, OnigCodePoint code)
#define GET_STATE_CHECK_NUM_INC(num, p)
#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos)
struct _OnigStackType::@95::@99 mem
void onig_region_copy(OnigRegion *to, const OnigRegion *from)
unsigned int OnigCaseFoldType
#define STACK_PUSH_MEM_END(mnum, s)
void onig_region_clear(OnigRegion *region)
unsigned char map[ONIG_CHAR_TABLE_SIZE]
OnigEncoding onig_get_encoding(const regex_t *reg)
#define STACK_NULL_CHECK_MEMST(isnull, id, s, reg)
#define STACK_PUSH_NULL_CHECK_END(cnum)
#define ONIG_OPTIMIZE_EXACT_IC
#define MATCH_AND_RETURN_CHECK(none)
#define GET_OPTION_INC(option, p)
#define ANCHOR_BEGIN_POSITION
#define GET_LENGTH_INC(len, p)
#define ONIGENC_MBC_CASE_FOLD_MAXLEN
#define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end)
OnigCaptureTreeNode * history_root
unsigned int bt_mem_start
#define STACK_PUSH_LOOK_BEHIND_NOT(pat, s, sprev, keep)
#define INIT_MATCH_STACK_SIZE
#define STACK_STOP_BT_END
#define STACK_GET_REPEAT(id, k)
#define MATCH_ARG_FREE(msa)
int onig_number_of_captures(const regex_t *reg)
const OnigSyntaxType * onig_get_syntax(const regex_t *reg)
#define ONIGENC_IS_MBC_CRNL(enc, p, end)
ONIG_EXTERN OnigUChar * onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc, const OnigUChar *start, const OnigUChar *s, const OnigUChar *end, const OnigUChar **prev)
OnigRepeatRange * repeat_range
#define GET_MEMNUM_INC(num, p)
#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC
#define ONIGENC_IS_MBC_ASCII_WORD(enc, s, end)
int onig_region_set(OnigRegion *region, int at, int beg, int end)
void onig_region_init(OnigRegion *region)
#define CHECK_INTERRUPT_IN_MATCH_AT
OnigCaseFoldType case_fold_flag
#define STK_NULL_CHECK_START
#define ONIG_MAX_CAPTURE_HISTORY_GROUP
#define ONIGENC_IS_MBC_NEWLINE(enc, p, end)
#define ONIGENC_MBC_CASE_FOLD(enc, flag, pp, end, buf)
#define IS_FIND_LONGEST(option)
#define ONIGERR_INVALID_ARGUMENT
#define DATA_ENSURE_CHECK1
#define ALIGNMENT_RIGHT(addr)
#define IS_NOTBOS(option)
#define BITSET_AT(bs, pos)
#define ONIGERR_UNDEFINED_BYTECODE
#define CHECK_NULL_RETURN_MEMERR(p)
void onig_region_free(OnigRegion *r, int free_self)
#define ONIG_OPTIMIZE_MAP
#define ONIG_INFINITE_DISTANCE
#define GET_STACK_INDEX(stk)
#define ONIGENC_MBC_MINLEN(enc)
#define range(low, item, hi)
#define DEFAULT_MATCH_STACK_LIMIT_SIZE
#define ONIG_OPTIMIZE_EXACT_BM_IC
#define STACK_PUSH_CALL_FRAME(pat)
struct _OnigStackType::@95::@96 state
#define ONIG_CHAR_TABLE_SIZE
OnigPosition onig_search_gpos(regex_t *reg, const UChar *str, const UChar *end, const UChar *global_pos, const UChar *start, const UChar *range, OnigRegion *region, OnigOptionType option)
#define STRING_CMP_IC(case_fold_flag, s1, ps2, len, text_end)
#define STRING_CMP(s1, s2, len)
ONIG_EXTERN OnigUChar * onigenc_get_prev_char_head(OnigEncoding enc, const OnigUChar *start, const OnigUChar *s, const OnigUChar *end)
#define ONIGENC_MBC_TO_CODE(enc, p, end)
#define STACK_PUSH_RETURN
#define ONIGENC_IS_MBC_NEWLINE_EX(enc, p, start, end, option, check_prev)
#define ONIGENC_IS_SINGLEBYTE(enc)
#define STK_NULL_CHECK_END
#define STRING_CMP_VALUE(s1, s2, len, is_fail)
#define STACK_NULL_CHECK(isnull, id, s)
#define ANCHOR_SEMI_END_BUF
#define ONIG_OPTIMIZE_NONE
#define ONIGERR_STACK_BUG
#define rb_enc_asciicompat(enc)
int memcmp(const void *s1, const void *s2, size_t len)
#define STACK_PUSH_POS(s, sprev, keep)
OnigOptionType onig_get_options(const regex_t *reg)
register unsigned int len
#define ANCHOR_ANYCHAR_STAR
struct OnigCaptureTreeNodeStruct ** childs
#define CHECK_NULL_RETURN(p)
unsigned char * exact_end
OnigPosition onig_search(regex_t *reg, const UChar *str, const UChar *end, const UChar *start, const UChar *range, OnigRegion *region, OnigOptionType option)
#define STACK_PUSH_NULL_CHECK_START(cnum, s)
#define SIZE_OP_SET_OPTION
OnigPosition onig_match(regex_t *reg, const UChar *str, const UChar *end, const UChar *at, OnigRegion *region, OnigOptionType option)
#define GET_RELADDR_INC(addr, p)
void onig_copy_encoding(OnigEncodingType *to, OnigEncoding from)
OnigCaseFoldType onig_get_case_fold_flag(const regex_t *reg)
#define ANCHOR_PREC_READ_NOT
#define STACK_PUSH_MEM_START(mnum, s)
#define IS_NEWLINE_CRLF(option)
unsigned int capture_history
#define IS_FIND_CONDITION(option)
const OnigSyntaxType * syntax
#define STRING_CMP_VALUE_IC(case_fold_flag, s1, ps2, len, text_end, is_fail)
#define STACK_PUSH_ALT(pat, s, sprev, keep)
#define ONIGERR_UNEXPECTED_BYTECODE
#define IS_NOTBOL(option)
#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV
#define ONIGENC_IS_MBC_WORD(enc, s, end)
#define STACK_INIT(alloc_addr, heap_addr, ptr_num, stack_num)
#define USE_CRNL_AS_LINE_TERMINATOR
OnigRegion * onig_region_new(void)
#define ANCHOR_LOOK_BEHIND
#define STACK_PUSH_REPEAT_INC(sindex)
#define STK_STATE_CHECK_MARK
#define BM_BACKWARD_SEARCH_LENGTH_THRESHOLD
#define ONIGENC_STEP_BACK(enc, start, s, end, n)
#define ONIG_OPTIMIZE_EXACT_BM
ONIG_EXTERN OnigCaptureTreeNode * onig_get_capture_tree(OnigRegion *region)
#define STACK_POP_TIL_LOOK_BEHIND_NOT
#define INVALID_STACK_INDEX
stack
#define STACK_NULL_CHECK_REC(isnull, id, s)
#define IS_FIND_NOT_EMPTY(option)
#define GET_ABSADDR_INC(addr, p)
#define enclen(enc, p, e)
#define STACK_PUSH_REPEAT(id, pat)
#define STACK_POP_TIL_ABSENT
#define STACK_NULL_CHECK_MEMST_REC(isnull, id, s, reg)