49 #ifndef PLATFORM_UNALIGNED_WORD_ACCESS 57 ptrdiff_t
len = end - s;
74 c = *a; *a = *b; *b = c;
109 if (m == 0)
return 0;
122 if (bs[i] != 0)
return 0;
153 buf->
alloc = (
unsigned int )size;
159 #ifdef USE_SUBEXP_CALL 188 size = uslist->
alloc * 2;
204 add_opcode(
regex_t* reg,
int opcode)
210 #ifdef USE_COMBINATION_EXPLOSION_CHECK 212 add_state_check_num(
regex_t* reg,
int num)
222 add_rel_addr(
regex_t* reg,
int addr)
231 add_abs_addr(
regex_t* reg,
int addr)
249 add_mem_num(
regex_t* reg,
int num)
259 add_pointer(
regex_t* reg,
void* addr)
276 add_opcode_rel_addr(
regex_t* reg,
int opcode,
int addr)
280 r = add_opcode(reg, opcode);
282 r = add_rel_addr(reg, addr);
305 r = add_opcode(reg, opcode);
307 r = add_option(reg, option);
311 static int compile_length_tree(
Node* node,
regex_t* reg);
315 #define IS_NEED_STR_LEN_OP_EXACT(op) \ 316 ((op) == OP_EXACTN || (op) == OP_EXACTMB2N ||\ 317 (op) == OP_EXACTMB3N || (op) == OP_EXACTMBN || (op) == OP_EXACTN_IC) 320 select_str_opcode(
int mb_len,
OnigDistance byte_len,
int ignore_case)
323 OnigDistance str_len = (byte_len + mb_len - 1) / mb_len;
366 compile_tree_empty_check(
Node* node,
regex_t* reg,
int empty_info)
371 if (empty_info != 0) {
379 r = compile_tree(node, reg);
382 if (empty_info != 0) {
391 r = add_mem_num(reg, saved_num_null_check);
396 #ifdef USE_SUBEXP_CALL 407 r = add_abs_addr(reg, 0 );
413 compile_tree_n_times(
Node* node,
int n,
regex_t* reg)
417 for (i = 0; i < n; i++) {
418 r = compile_tree(node, reg);
429 int op = select_str_opcode(mb_len, byte_len, ignore_case);
437 len += (int )byte_len;
445 int op = select_str_opcode(mb_len, byte_len, ignore_case);
449 add_length(reg, mb_len);
453 add_length(reg, byte_len);
455 add_length(reg, byte_len / mb_len);
458 add_bytes(reg, s, byte_len);
464 compile_length_string_node(
Node* node,
regex_t* reg)
466 int rlen, r,
len, prev_len, blen, ambig;
472 if (sn->
end <= sn->
s)
483 for (; p < sn->
end; ) {
485 if (len == prev_len || ambig) {
489 r = add_compile_string_length(prev, prev_len, blen, reg, ambig);
497 r = add_compile_string_length(prev, prev_len, blen, reg, ambig);
505 if (sn->
end <= sn->
s)
508 return add_compile_string_length(sn->
s, 1 , sn->
end - sn->
s, reg, 0);
514 int r,
len, prev_len, blen, ambig;
520 if (sn->
end <= sn->
s)
527 prev_len =
enclen(enc, p, end);
532 len =
enclen(enc, p, end);
533 if (len == prev_len || ambig) {
537 r = add_compile_string(prev, prev_len, blen, reg, ambig);
547 return add_compile_string(prev, prev_len, blen, reg, ambig);
553 if (sn->
end <= sn->
s)
556 return add_compile_string(sn->
s, 1 , sn->
end - sn->
s, reg, 0);
562 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS 563 add_length(reg, mbuf->
used);
564 return add_bytes(reg, mbuf->
p, mbuf->
used);
571 if (pad_size != 0) add_bytes(reg, PadBuf, pad_size);
573 r = add_bytes(reg, mbuf->
p, mbuf->
used);
577 if (pad_size != 0) add_bytes(reg, PadBuf, pad_size);
597 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS 618 r = add_bitset(reg, cc->
bs);
627 r = add_multi_byte_cclass(cc->
mbuf, reg);
635 r = add_bitset(reg, cc->
bs);
637 r = add_multi_byte_cclass(cc->
mbuf, reg);
645 entry_repeat_range(
regex_t* reg,
int id,
int lower,
int upper)
647 #define REPEAT_RANGE_ALLOC 4 676 compile_range_repeat_node(
QtfrNode* qn,
int target_len,
int empty_info,
684 r = add_mem_num(reg, num_repeat);
690 r = entry_repeat_range(reg, num_repeat, qn->
lower, qn->
upper);
693 r = compile_tree_empty_check(qn->
target, reg, empty_info);
707 r = add_mem_num(reg, num_repeat);
712 is_anychar_star_quantifier(
QtfrNode* qn)
721 #define QUANTIFIER_EXPAND_LIMIT_SIZE 50 722 #define CKN_ON (ckn > 0) 724 #ifdef USE_COMBINATION_EXPLOSION_CHECK 729 int len, mod_tlen, cklen;
733 int tlen = compile_length_tree(qn->
target, reg);
735 if (tlen < 0)
return tlen;
743 if (qn->
greedy && infinite) {
756 if (infinite && qn->
lower <= 1) {
774 else if (qn->
upper == 0) {
781 if (qn->
lower == 0) {
783 len = SIZE_OP_STATE_CHECK_PUSH + tlen;
800 len += SIZE_OP_STATE_CHECK;
813 int tlen = compile_length_tree(qn->
target, reg);
815 if (tlen < 0)
return tlen;
819 if (is_anychar_star_quantifier(qn)) {
820 r = compile_tree_n_times(qn->
target, qn->
lower, reg);
829 r = add_state_check_num(reg, ckn);
837 r = add_opcode(reg, (
CKN_ON ?
842 r = add_opcode(reg, (
CKN_ON ?
848 r = add_state_check_num(reg, ckn);
859 if (infinite && qn->
lower <= 1) {
861 if (qn->
lower == 1) {
862 r = add_opcode_rel_addr(reg,
OP_JUMP,
870 r = add_state_check_num(reg, ckn);
878 r = compile_tree_empty_check(qn->
target, reg, empty_info);
880 r = add_opcode_rel_addr(reg,
OP_JUMP,
885 if (qn->
lower == 0) {
886 r = add_opcode_rel_addr(reg,
OP_JUMP, mod_tlen);
889 r = compile_tree_empty_check(qn->
target, reg, empty_info);
894 r = add_state_check_num(reg, ckn);
896 r = add_rel_addr(reg,
897 -(mod_tlen + (
int )SIZE_OP_STATE_CHECK_PUSH_OR_JUMP));
903 else if (qn->
upper == 0) {
905 r = add_opcode_rel_addr(reg,
OP_JUMP, tlen);
907 r = compile_tree(qn->
target, reg);
913 if (qn->
lower == 0) {
917 r = add_state_check_num(reg, ckn);
919 r = add_rel_addr(reg, tlen);
922 r = add_opcode_rel_addr(reg,
OP_PUSH, tlen);
927 r = compile_tree(qn->
target, reg);
933 r = add_state_check_num(reg, ckn);
942 r = add_opcode_rel_addr(reg,
OP_JUMP, tlen);
944 r = compile_tree(qn->
target, reg);
947 r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg);
952 r = add_state_check_num(reg, ckn);
966 int tlen = compile_length_tree(qn->
target, reg);
968 if (tlen < 0)
return tlen;
972 if (qn->
greedy && infinite) {
991 len = tlen * qn->
lower;
995 #ifdef USE_OP_PUSH_OR_JUMP_EXACT 1011 else if (!infinite && qn->
greedy &&
1014 len = tlen * qn->
lower;
1034 int tlen = compile_length_tree(qn->
target, reg);
1036 if (tlen < 0)
return tlen;
1038 if (is_anychar_star_quantifier(qn)) {
1039 r = compile_tree_n_times(qn->
target, qn->
lower, reg);
1057 if (empty_info != 0)
1066 #ifdef USE_OP_PUSH_OR_JUMP_EXACT 1082 r = compile_tree_n_times(qn->
target, qn->
lower, reg);
1087 #ifdef USE_OP_PUSH_OR_JUMP_EXACT 1093 r = compile_tree_empty_check(qn->
target, reg, empty_info);
1095 r = add_opcode_rel_addr(reg,
OP_JUMP,
1105 r = compile_tree_empty_check(qn->
target, reg, empty_info);
1107 r = add_opcode_rel_addr(reg,
OP_JUMP,
1113 r = compile_tree_empty_check(qn->
target, reg, empty_info);
1115 r = add_opcode_rel_addr(reg,
OP_JUMP,
1120 r = add_opcode_rel_addr(reg,
OP_JUMP, mod_tlen);
1122 r = compile_tree_empty_check(qn->
target, reg, empty_info);
1128 r = add_opcode_rel_addr(reg,
OP_JUMP, tlen);
1130 r = compile_tree(qn->
target, reg);
1132 else if (!infinite && qn->
greedy &&
1137 r = compile_tree_n_times(qn->
target, qn->
lower, reg);
1140 for (i = 0; i < n; i++) {
1141 r = add_opcode_rel_addr(reg,
OP_PUSH,
1144 r = compile_tree(qn->
target, reg);
1151 r = add_opcode_rel_addr(reg,
OP_JUMP, tlen);
1153 r = compile_tree(qn->
target, reg);
1156 r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg);
1169 tlen = compile_length_tree(node->
target, reg);
1172 if (tlen < 0)
return tlen;
1198 r = compile_tree(node->
target, reg);
1215 return compile_length_option_node(node, reg);
1218 tlen = compile_length_tree(node->
target, reg);
1219 if (tlen < 0)
return tlen;
1224 switch (node->
type) {
1226 #ifdef USE_SUBEXP_CALL 1258 tlen = compile_length_tree(qn->
target, reg);
1259 if (tlen < 0)
return tlen;
1261 len = tlen * qn->
lower 1274 tlen = compile_length_tree(
NCAR(x), reg);
1275 if (tlen < 0)
return tlen;
1279 tlen = compile_length_tree(
NCAR(x), reg);
1280 if (tlen < 0)
return tlen;
1301 static int get_char_length_tree(
Node* node,
regex_t* reg,
int*
len);
1309 return compile_option_node(node, reg);
1311 switch (node->
type) {
1313 #ifdef USE_SUBEXP_CALL 1319 r = add_abs_addr(reg, (
int )node->
call_addr);
1321 len = compile_length_tree(node->
target, reg);
1330 r = add_opcode_rel_addr(reg,
OP_JUMP, len);
1339 r = add_mem_num(reg, node->
regnum);
1341 r = compile_tree(node->
target, reg);
1343 #ifdef USE_SUBEXP_CALL 1353 r = add_mem_num(reg, node->
regnum);
1363 r = add_mem_num(reg, node->
regnum);
1373 r = add_mem_num(reg, node->
regnum);
1380 r = compile_tree_n_times(qn->
target, qn->
lower, reg);
1383 len = compile_length_tree(qn->
target, reg);
1384 if (len < 0)
return len;
1388 r = compile_tree(qn->
target, reg);
1390 r = add_opcode(reg,
OP_POP);
1392 r = add_opcode_rel_addr(reg,
OP_JUMP,
1398 r = compile_tree(node->
target, reg);
1407 r = add_mem_num(reg, node->
regnum);
1414 len = compile_length_tree(
NCAR(x), reg);
1415 if (len < 0)
return len;
1418 len2 = compile_length_tree(
NCAR(x), reg);
1419 if (len2 < 0)
return len2;
1425 r = compile_tree(
NCAR(x), reg);
1427 r = add_opcode_rel_addr(reg,
OP_JUMP, len2);
1430 r = compile_tree(
NCAR(x), reg);
1438 len = compile_length_tree(node->
target, reg);
1439 if (len < 0)
return len;
1445 r = compile_tree(node->
target, reg);
1465 tlen = compile_length_tree(node->
target, reg);
1466 if (tlen < 0)
return tlen;
1469 switch (node->
type) {
1496 switch (node->
type) {
1512 #ifdef USE_WORD_BEGIN_END 1527 r = compile_tree(node->
target, reg);
1533 len = compile_length_tree(node->
target, reg);
1534 if (len < 0)
return len;
1537 r = compile_tree(node->
target, reg);
1548 r = get_char_length_tree(node->
target, reg, &n);
1553 r = add_length(reg, n);
1555 r = compile_tree(node->
target, reg);
1562 len = compile_length_tree(node->
target, reg);
1567 r = get_char_length_tree(node->
target, reg, &n);
1572 r = add_length(reg, n);
1574 r = compile_tree(node->
target, reg);
1598 r = compile_length_tree(
NCAR(node), reg);
1599 if (r < 0)
return r;
1610 r = compile_length_tree(
NCAR(node), reg);
1611 if (r < 0)
return r;
1622 r = compile_length_string_raw_node(
NSTR(node), reg);
1624 r = compile_length_string_node(node, reg);
1628 r = compile_length_cclass_node(
NCCLASS(node), reg);
1640 #ifdef USE_BACKREF_WITH_LEVEL 1657 #ifdef USE_SUBEXP_CALL 1664 r = compile_length_quantifier_node(
NQTFR(node), reg);
1668 r = compile_length_enclose_node(
NENCLOSE(node), reg);
1672 r = compile_length_anchor_node(
NANCHOR(node), reg);
1686 int n, type,
len, pos, r = 0;
1692 r = compile_tree(
NCAR(node), reg);
1701 len += compile_length_tree(
NCAR(x), reg);
1709 len = compile_length_tree(
NCAR(node), reg);
1714 r = compile_tree(
NCAR(node), reg);
1718 r = add_opcode_rel_addr(reg,
OP_JUMP, len);
1727 r = compile_string_raw_node(
NSTR(node), reg);
1729 r = compile_string_node(node, reg);
1733 r = compile_cclass_node(
NCCLASS(node), reg);
1740 switch (
NCTYPE(node)->ctype) {
1742 if (
NCTYPE(node)->ascii_range != 0) {
1755 r = add_opcode(reg, op);
1770 #ifdef USE_BACKREF_WITH_LEVEL 1779 goto add_bacref_mems;
1788 r = add_mem_num(reg, n);
1797 r = add_mem_num(reg, n);
1814 #ifdef USE_BACKREF_WITH_LEVEL 1820 for (i = br->
back_num - 1; i >= 0; i--) {
1821 r = add_mem_num(reg, p[i]);
1828 #ifdef USE_SUBEXP_CALL 1830 r = compile_call(
NCALL(node), reg);
1835 r = compile_quantifier_node(
NQTFR(node), reg);
1839 r = compile_enclose_node(
NENCLOSE(node), reg);
1843 r = compile_anchor_node(
NANCHOR(node), reg);
1848 fprintf(stderr,
"compile_tree: undefined node type %d\n",
NTYPE(node));
1856 #ifdef USE_NAMED_GROUP 1862 Node* node = *plink;
1864 switch (
NTYPE(node)) {
1868 r = noname_disable_map(&(
NCAR(node)), map, counter);
1874 Node** ptarget = &(
NQTFR(node)->target);
1875 Node* old = *ptarget;
1876 r = noname_disable_map(ptarget, map, counter);
1892 else if (en->
regnum != 0) {
1896 r = noname_disable_map(plink, map, counter);
1900 r = noname_disable_map(&(en->
target), map, counter);
1906 r = noname_disable_map(&(
NANCHOR(node)->target), map, counter);
1919 int i, pos, n, old_num;
1932 for (i = 0, pos = 0; i < old_num; i++) {
1949 switch (
NTYPE(node)) {
1953 r = renumber_by_map(
NCAR(node), map);
1957 r = renumber_by_map(
NQTFR(node)->target, map);
1964 r = renumber_by_map(en->
target, map);
1969 r = renumber_node_backref(node, map);
1974 r = renumber_by_map(
NANCHOR(node)->target, map);
1985 numbered_ref_check(
Node* node)
1989 switch (
NTYPE(node)) {
1993 r = numbered_ref_check(
NCAR(node));
1997 r = numbered_ref_check(
NQTFR(node)->target);
2000 r = numbered_ref_check(
NENCLOSE(node)->target);
2010 r = numbered_ref_check(
NANCHOR(node)->target);
2023 int r, i, pos, counter;
2029 for (i = 1; i <= env->
num_mem; i++) {
2033 r = noname_disable_map(root, map, &counter);
2034 if (r != 0)
return r;
2036 r = renumber_by_map(*root, map);
2037 if (r != 0)
return r;
2039 for (i = 1, pos = 1; i <= env->
num_mem; i++) {
2040 if (map[i].new_val > 0) {
2061 #ifdef USE_SUBEXP_CALL 2069 for (i = 0; i < uslist->
num; i++) {
2081 #ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT 2083 quantifiers_memory_node_info(
Node* node)
2087 switch (
NTYPE(node)) {
2093 v = quantifiers_memory_node_info(
NCAR(node));
2099 # ifdef USE_SUBEXP_CALL 2105 r = quantifiers_memory_node_info(
NCALL(node)->target);
2112 if (qn->
upper != 0) {
2113 r = quantifiers_memory_node_info(qn->
target);
2130 r = quantifiers_memory_node_info(en->
target);
2159 switch (
NTYPE(node)) {
2170 r = get_min_match_length(nodes[backs[0]], min, env);
2172 for (i = 1; i < br->
back_num; i++) {
2174 r = get_min_match_length(nodes[backs[i]], &tmin, env);
2176 if (*min > tmin) *min = tmin;
2181 #ifdef USE_SUBEXP_CALL 2189 r = get_min_match_length(
NCALL(node)->target, min, env);
2195 r = get_min_match_length(
NCAR(node), &tmin, env);
2196 if (r == 0) *min += tmin;
2206 r = get_min_match_length(x, &tmin, env);
2208 if (y == node) *min = tmin;
2209 else if (*min > tmin) *min = tmin;
2217 *min = sn->
end - sn->
s;
2234 if (qn->
lower > 0) {
2235 r = get_min_match_length(qn->
target, min, env);
2237 *min = distance_multiply(*min, qn->
lower);
2254 r = get_min_match_length(en->
target, min, env);
2267 r = get_min_match_length(en->
target, min, env);
2291 switch (
NTYPE(node)) {
2294 r = get_max_match_length(
NCAR(node), &tmax, env);
2296 *max = distance_add(*max, tmax);
2302 r = get_max_match_length(
NCAR(node), &tmax, env);
2303 if (r == 0 && *max < tmax) *max = tmax;
2310 *max = sn->
end - sn->
s;
2334 for (i = 0; i < br->
back_num; i++) {
2336 r = get_max_match_length(nodes[backs[i]], &tmax, env);
2338 if (*max < tmax) *max = tmax;
2343 #ifdef USE_SUBEXP_CALL 2346 r = get_max_match_length(
NCALL(node)->target, max, env);
2356 if (qn->
upper != 0) {
2357 r = get_max_match_length(qn->
target, max, env);
2358 if (r == 0 && *max != 0) {
2360 *max = distance_multiply(*max, qn->
upper);
2380 r = get_max_match_length(en->
target, max, env);
2393 r = get_max_match_length(en->
target, max, env);
2410 #define GET_CHAR_LEN_VARLEN -1 2411 #define GET_CHAR_LEN_TOP_ALT_VARLEN -2 2422 switch (
NTYPE(node)) {
2425 r = get_char_length_tree1(
NCAR(node), reg, &tlen, level);
2427 *len = (int )distance_add(*len, tlen);
2436 r = get_char_length_tree1(
NCAR(node), reg, &tlen, level);
2438 r = get_char_length_tree1(
NCAR(node), reg, &tlen2, level);
2461 while (s < sn->
end) {
2472 r = get_char_length_tree1(qn->
target, reg, &tlen, level);
2474 *len = (int )distance_multiply(tlen, qn->
lower);
2481 #ifdef USE_SUBEXP_CALL 2484 r = get_char_length_tree1(
NCALL(node)->target, reg,
len,
level);
2504 #ifdef USE_SUBEXP_CALL 2508 r = get_char_length_tree1(en->
target, reg, len, level);
2519 r = get_char_length_tree1(en->
target, reg, len, level);
2542 return get_char_length_tree1(node, reg, len, 0);
2574 tmp = x; x = y; y = tmp;
2594 switch (
NCTYPE(y)->ctype) {
2596 if (
NCTYPE(y)->not == 0) {
2600 if (
NCTYPE(y)->ascii_range) {
2616 if (
NCTYPE(y)->ascii_range)
2680 switch (
NCTYPE(y)->ctype) {
2682 if (
NCTYPE(y)->ascii_range) {
2686 return !(
NCTYPE(y)->not);
2692 return !(
NCTYPE(y)->not);
2721 for (i = 0, p = ys->
s, q = xs->
s; (
OnigDistance )i < len; i++, p++, q++) {
2722 if (*p != *q)
return 1;
2742 get_head_value_node(
Node* node,
int exact,
regex_t* reg)
2746 switch (
NTYPE(node)) {
2750 #ifdef USE_SUBEXP_CALL 2763 n = get_head_value_node(
NCAR(node), exact, reg);
2770 if (sn->
end <= sn->
s)
2785 if (qn->
lower > 0) {
2786 #ifdef USE_OP_PUSH_OR_JUMP_EXACT 2791 n = get_head_value_node(qn->
target, exact, reg);
2805 n = get_head_value_node(
NENCLOSE(node)->target, exact, reg);
2813 n = get_head_value_node(en->
target, exact, reg);
2824 n = get_head_value_node(
NANCHOR(node)->target, exact, reg);
2835 check_type_tree(
Node* node,
int type_mask,
int enclose_mask,
int anchor_mask)
2847 r = check_type_tree(
NCAR(node), type_mask, enclose_mask,
2853 r = check_type_tree(
NQTFR(node)->target, type_mask, enclose_mask,
2860 if ((en->
type & enclose_mask) == 0)
2863 r = check_type_tree(en->
target, type_mask, enclose_mask, anchor_mask);
2869 if ((type & anchor_mask) == 0)
2873 r = check_type_tree(
NANCHOR(node)->target,
2874 type_mask, enclose_mask, anchor_mask);
2883 #ifdef USE_SUBEXP_CALL 2885 # define RECURSION_EXIST 1 2886 # define RECURSION_INFINITE 2 2889 subexp_inf_recursive_check(
Node* node,
ScanEnv* env,
int head)
2904 ret = subexp_inf_recursive_check(
NCAR(x), env, head);
2908 ret = get_min_match_length(
NCAR(x), &min, env);
2909 if (ret != 0)
return ret;
2910 if (min != 0) head = 0;
2921 ret = subexp_inf_recursive_check(
NCAR(node), env, head);
2929 r = subexp_inf_recursive_check(
NQTFR(node)->target, env, head);
2931 if (
NQTFR(node)->lower == 0) r = 0;
2943 r = subexp_inf_recursive_check(an->
target, env, head);
2950 r = subexp_inf_recursive_check(
NCALL(node)->target, env, head);
2960 r = subexp_inf_recursive_check(
NENCLOSE(node)->target, env, head);
2973 subexp_inf_recursive_check_trav(
Node* node,
ScanEnv* env)
2983 r = subexp_inf_recursive_check_trav(
NCAR(node), env);
2988 r = subexp_inf_recursive_check_trav(
NQTFR(node)->target, env);
2999 r = subexp_inf_recursive_check_trav(an->
target, env);
3011 r = subexp_inf_recursive_check(en->
target, env, 1);
3015 r = subexp_inf_recursive_check_trav(en->
target, env);
3028 subexp_recursive_check(
Node* node)
3032 switch (
NTYPE(node)) {
3036 r |= subexp_recursive_check(
NCAR(node));
3041 r = subexp_recursive_check(
NQTFR(node)->target);
3052 r = subexp_recursive_check(an->
target);
3059 r = subexp_recursive_check(
NCALL(node)->target);
3070 r = subexp_recursive_check(
NENCLOSE(node)->target);
3084 subexp_recursive_check_trav(
Node* node,
ScanEnv* env)
3086 # define FOUND_CALLED_NODE 1 3098 ret = subexp_recursive_check_trav(
NCAR(node), env);
3100 else if (ret < 0)
return ret;
3106 r = subexp_recursive_check_trav(
NQTFR(node)->target, env);
3107 if (
NQTFR(node)->upper == 0) {
3109 NQTFR(node)->is_refered = 1;
3121 r = subexp_recursive_check_trav(an->
target, env);
3134 r = subexp_recursive_check(en->
target);
3139 r = subexp_recursive_check_trav(en->
target, env);
3162 r = setup_subexp_call(
NCAR(node), env);
3168 r = setup_subexp_call(
NCAR(node), env);
3173 r = setup_subexp_call(
NQTFR(node)->target, env);
3176 r = setup_subexp_call(
NENCLOSE(node)->target, env);
3187 # ifdef USE_NAMED_GROUP 3200 # ifdef USE_NAMED_GROUP 3213 # ifdef USE_NAMED_GROUP 3214 # ifdef USE_PERL_SUBEXP_CALL 3253 r = setup_subexp_call(an->
target, env);
3272 divide_look_behind_alternatives(
Node* node)
3274 Node *head, *np, *insert_node;
3276 int anc_type = an->
type;
3280 swap_node(node, head);
3289 NCAR(np) = insert_node;
3307 r = get_char_length_tree(an->
target, reg, &len);
3314 r = divide_look_behind_alternatives(node);
3332 #ifdef USE_QTFR_PEEK_NEXT 3333 Node* n = get_head_value_node(next_node, 1, reg);
3340 if (qn->
lower <= 1) {
3344 x = get_head_value_node(qn->
target, 0, reg);
3346 y = get_head_value_node(next_node, 0, reg);
3347 if (
IS_NOT_NULL(y) && is_not_included(x, y, reg)) {
3351 swap_node(node, en);
3371 update_string_node_case_fold(
regex_t* reg,
Node *node)
3374 UChar *sbuf, *ebuf, *sp;
3380 sbuf_size = (end - sn->
s) * 2;
3383 ebuf = sbuf + sbuf_size;
3389 for (i = 0; i <
len; i++) {
3397 sp = sbuf + sbuf_size;
3399 ebuf = sbuf + sbuf_size;
3422 r = update_string_node_case_fold(reg, node);
3440 for (i = 0; i < item_num; i++) {
3441 if (items[i].byte_len != slen) {
3444 if (items[i].code_len != 1) {
3456 int r, i, j,
len, varlen;
3457 Node *anode, *var_anode, *snode, *xnode, *an;
3463 for (i = 0; i < item_num; i++) {
3464 if (items[i].byte_len != slen) {
3475 if (
IS_NULL(xnode))
goto mem_err;
3476 NCAR(var_anode) = xnode;
3479 if (
IS_NULL(anode))
goto mem_err;
3480 NCAR(xnode) = anode;
3488 if (
IS_NULL(snode))
goto mem_err;
3490 NCAR(anode) = snode;
3492 for (i = 0; i < item_num; i++) {
3494 if (
IS_NULL(snode))
goto mem_err;
3496 for (j = 0; j < items[i].
code_len; j++) {
3504 if (r != 0)
goto mem_err2;
3512 if (items[i].byte_len != slen) {
3517 r = expand_case_fold_make_rem_string(&rem, q,
end, reg);
3542 NCDR(var_anode) = an;
3566 #define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION 8 3568 int r, n,
len, alt_num;
3571 Node *top_root, *root, *snode, *prev_node;
3579 if (start >= end)
return 0;
3582 top_root = root = prev_node = snode =
NULL_NODE;
3595 varlen = is_case_fold_variable_len(n, items, len);
3596 if (n == 0 || varlen == 0) {
3607 if (
IS_NULL(snode))
goto mem_err;
3617 if (r != 0)
goto err;
3624 r = update_string_node_case_fold(reg, snode);
3637 r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node);
3638 if (r < 0)
goto mem_err;
3641 top_root = prev_node;
3650 root =
NCAR(prev_node);
3667 r = update_string_node_case_fold(reg, snode);
3676 r = expand_case_fold_make_rem_string(&srem, p, end, reg);
3677 if (r != 0)
goto mem_err;
3700 top_root = (
IS_NOT_NULL(top_root) ? top_root : prev_node);
3701 swap_node(node, top_root);
3714 #ifdef USE_COMBINATION_EXPLOSION_CHECK 3716 # define CEC_THRES_NUM_BIG_REPEAT 512 3717 # define CEC_INFINITE_NUM 0x7fffffff 3719 # define CEC_IN_INFINITE_REPEAT (1<<0) 3720 # define CEC_IN_FINITE_REPEAT (1<<1) 3721 # define CEC_CONT_BIG_REPEAT (1<<2) 3724 setup_comb_exp_check(
Node* node,
int state,
ScanEnv* env)
3735 r = setup_comb_exp_check(
NCAR(node), r, env);
3745 ret = setup_comb_exp_check(
NCAR(node), state, env);
3753 int child_state = state;
3760 if (qn->
upper > 1) {
3762 child_state |= CEC_IN_FINITE_REPEAT;
3775 child_state = state;
3784 if (state & CEC_IN_FINITE_REPEAT) {
3785 qn->comb_exp_check_num = -1;
3789 var_num = CEC_INFINITE_NUM;
3790 child_state |= CEC_IN_INFINITE_REPEAT;
3796 if (var_num >= CEC_THRES_NUM_BIG_REPEAT)
3797 add_state |= CEC_CONT_BIG_REPEAT;
3799 if (((state & CEC_IN_INFINITE_REPEAT) != 0 && var_num != 0) ||
3800 ((state & CEC_CONT_BIG_REPEAT) != 0 &&
3801 var_num >= CEC_THRES_NUM_BIG_REPEAT)) {
3802 if (qn->comb_exp_check_num == 0) {
3803 env->num_comb_exp_check++;
3804 qn->comb_exp_check_num = env->num_comb_exp_check;
3805 if (env->curr_max_regnum > env->comb_exp_max_regnum)
3806 env->comb_exp_max_regnum = env->curr_max_regnum;
3811 r = setup_comb_exp_check(target, child_state, env);
3823 if (env->curr_max_regnum < en->
regnum)
3824 env->curr_max_regnum = en->
regnum;
3826 r = setup_comb_exp_check(en->
target, state, env);
3831 r = setup_comb_exp_check(en->
target, state, env);
3837 # ifdef USE_SUBEXP_CALL 3840 env->has_recursion = 1;
3842 r = setup_comb_exp_check(
NCALL(node)->target, state, env);
3854 #define IN_ALT (1<<0) 3855 #define IN_NOT (1<<1) 3856 #define IN_REPEAT (1<<2) 3857 #define IN_VAR_REPEAT (1<<3) 3858 #define IN_CALL (1<<4) 3859 #define IN_RECCALL (1<<5) 3882 r = setup_tree(
NCAR(node), reg, state, env);
3884 r = next_setup(prev,
NCAR(node), reg);
3893 r = setup_tree(
NCAR(node), reg, (state |
IN_ALT), env);
3902 r = expand_case_fold_string(node, reg);
3910 #ifdef USE_SUBEXP_CALL 3922 for (i = 0; i < br->
back_num; i++) {
3926 #ifdef USE_BACKREF_WITH_LEVEL 3947 r = get_min_match_length(target, &d, env);
3951 #ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT 3952 r = quantifiers_memory_node_info(target);
3959 r = get_max_match_length(target, &d, env);
3960 if (r == 0 && d == 0) {
3975 r = setup_tree(target, reg, state, env);
3979 #define EXPAND_STRING_MAX_LENGTH 100 3981 if (qn->
lower > 1) {
3982 int i, n = qn->
lower;
4010 swap_node(np1, node);
4018 swap_node(np, node);
4025 #ifdef USE_OP_PUSH_OR_JUMP_EXACT 4051 r = setup_tree(
NENCLOSE(node)->target, reg, state, env);
4067 r = setup_tree(en->
target, reg, state, env);
4073 r = setup_tree(target, reg, state, env);
4087 #ifdef USE_NAMED_GROUP 4097 r = setup_tree(
NENCLOSE(node)->target, reg, state, env);
4101 r = setup_tree(
NENCLOSE(node)->target, reg, state, env);
4113 r = setup_tree(an->
target, reg, state, env);
4116 r = setup_tree(an->
target, reg, (state |
IN_NOT), env);
4120 #define ALLOWED_TYPE_IN_LB \ 4121 ( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \ 4122 BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL ) 4124 #define ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY | ENCLOSE_OPTION ) 4125 #define ALLOWED_ENCLOSE_IN_LB_NOT ENCLOSE_OPTION 4127 #define ALLOWED_ANCHOR_IN_LB \ 4128 ( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \ 4129 ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_KEEP | \ 4130 ANCHOR_WORD_BOUND | ANCHOR_NOT_WORD_BOUND | \ 4131 ANCHOR_WORD_BEGIN | ANCHOR_WORD_END ) 4132 #define ALLOWED_ANCHOR_IN_LB_NOT \ 4133 ( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \ 4134 ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_KEEP | \ 4135 ANCHOR_WORD_BOUND | ANCHOR_NOT_WORD_BOUND | \ 4136 ANCHOR_WORD_BEGIN | ANCHOR_WORD_END ) 4142 if (r < 0)
return r;
4145 r = setup_tree(an->
target, reg, state, env);
4146 if (r != 0)
return r;
4147 r = setup_look_behind(node, reg, env);
4155 if (r < 0)
return r;
4158 r = setup_tree(an->
target, reg, (state |
IN_NOT), env);
4159 if (r != 0)
return r;
4160 r = setup_look_behind(node, reg, env);
4174 #ifndef USE_SUNDAY_QUICK_SEARCH 4178 UChar skip[],
int** int_skip,
int ignore_case)
4181 int clen, flen, n, j, k;
4191 for (i = 0; i < len - 1; i += clen) {
4198 clen = (int )(
end - p);
4200 for (j = 0; j < n; j++) {
4201 if ((items[j].code_len != 1) || (items[j].
byte_len != clen))
4207 for (j = 0; j < clen; j++) {
4208 skip[s[i + j]] = (
UChar )(len - 1 - i - j);
4209 for (k = 0; k < n; k++) {
4210 skip[buf[k][j]] = (
UChar )(len - 1 - i - j);
4216 # if OPT_EXACT_MAXLEN < ONIG_CHAR_TABLE_SIZE 4227 for (i = 0; i < len - 1; i += clen) {
4234 clen = (int )(
end - p);
4236 for (j = 0; j < n; j++) {
4237 if ((items[j].code_len != 1) || (items[j].
byte_len != clen))
4243 for (j = 0; j < clen; j++) {
4244 (*int_skip)[s[i + j]] = (int )(len - 1 - i - j);
4245 for (k = 0; k < n; k++) {
4246 (*int_skip)[buf[k][j]] = (int )(len - 1 - i - j);
4260 UChar skip[],
int** int_skip,
int ignore_case)
4263 int clen, flen, n, j, k;
4273 for (i = 0; i <
len; i += clen) {
4280 clen = (int )(
end - p);
4282 for (j = 0; j < n; j++) {
4283 if ((items[j].code_len != 1) || (items[j].
byte_len != clen))
4289 for (j = 0; j < clen; j++) {
4290 skip[s[i + j]] = (
UChar )(len - i - j);
4291 for (k = 0; k < n; k++) {
4292 skip[buf[k][j]] = (
UChar )(len - i - j);
4298 # if OPT_EXACT_MAXLEN < ONIG_CHAR_TABLE_SIZE 4309 for (i = 0; i <
len; i += clen) {
4316 clen = (int )(
end - p);
4318 for (j = 0; j < n; j++) {
4319 if ((items[j].code_len != 1) || (items[j].
byte_len != clen))
4325 for (j = 0; j < clen; j++) {
4326 (*int_skip)[s[i + j]] = (int )(len - i - j);
4327 for (k = 0; k < n; k++) {
4328 (*int_skip)[buf[k][j]] = (int )(len - i - j);
4389 static const short int ByteValTable[] = {
4390 5, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 1, 1, 10, 1, 1,
4391 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4392 12, 4, 7, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
4393 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5,
4394 5, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
4395 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 5, 5, 5,
4396 5, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
4397 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 1
4404 return (
int )ByteValTable[i];
4414 static const short int dist_vals[] = {
4415 1000, 500, 333, 250, 200, 167, 143, 125, 111, 100,
4416 91, 83, 77, 71, 67, 63, 59, 56, 53, 50,
4417 48, 45, 43, 42, 40, 38, 37, 36, 34, 33,
4418 32, 31, 30, 29, 29, 28, 27, 26, 26, 25,
4419 24, 24, 23, 23, 22, 22, 21, 21, 20, 20,
4420 20, 19, 19, 19, 18, 18, 18, 17, 17, 17,
4421 16, 16, 16, 16, 15, 15, 15, 15, 14, 14,
4422 14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
4423 12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
4424 11, 11, 11, 11, 11, 10, 10, 10, 10, 10
4434 return (
int )dist_vals[d];
4442 if (v2 <= 0)
return -1;
4443 if (v1 <= 0)
return 1;
4445 v1 *= distance_value(d1);
4446 v2 *= distance_value(d2);
4448 if (v2 > v1)
return 1;
4449 if (v2 < v1)
return -1;
4451 if (d2->
min < d1->
min)
return 1;
4452 if (d2->
min > d1->
min)
return -1;
4486 to->
min = distance_add(to->
min, from->
min);
4487 to->
max = distance_add(to->
max, from->
max);
4494 to->
min = distance_add(to->
min, len);
4495 to->
max = distance_add(to->
max, len);
4529 clear_opt_anc_info(to);
4532 if (left_len == 0) {
4537 if (right_len == 0) {
4546 is_left_anchor(
int anc)
4567 if (is_left_anchor(anc))
4576 if (is_left_anchor(anc))
4598 clear_mml(&ex->
mmd);
4599 clear_opt_anc_info(&ex->
anc);
4626 for (i = to->
len; p < end; ) {
4627 len =
enclen(enc, p, end);
4629 for (j = 0; j < len && p <
end; j++)
4636 concat_opt_anc_info(&tanc, &to->
anc, &add->
anc, 1, 1);
4638 copy_opt_anc_info(&to->
anc, &tanc);
4651 for (j = 0; j < len && p <
end; j++)
4663 if (add->
len == 0 || to->
len == 0) {
4664 clear_opt_exact_info(to);
4668 if (! is_equal_mml(&to->
mmd, &add->
mmd)) {
4669 clear_opt_exact_info(to);
4673 for (i = 0; i < to->
len && i < add->
len; ) {
4674 if (to->
s[i] != add->
s[i])
break;
4677 for (j = 1; j <
len; j++) {
4678 if (to->
s[i+j] != add->
s[i+j])
break;
4684 if (! add->
reach_end || i < add->len || i < to->len) {
4693 alt_merge_opt_anc_info(&to->
anc, &add->
anc);
4709 copy_opt_exact_info(now, alt);
4712 else if (v1 <= 2 && v2 <= 2) {
4714 v2 = map_position_value(enc, now->
s[0]);
4715 v1 = map_position_value(enc, alt->
s[0]);
4717 if (now->
len > 1) v1 += 5;
4718 if (alt->
len > 1) v2 += 5;
4724 if (comp_distance_value(&now->
mmd, &alt->
mmd, v1, v2) > 0)
4725 copy_opt_exact_info(now, alt);
4734 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4735 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4736 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4737 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4738 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4739 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4740 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4741 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4742 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4743 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4744 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4745 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4746 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4747 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4748 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4749 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
4765 if (map->
map[c] == 0) {
4767 map->
value += map_position_value(enc, c);
4779 add_char_opt_map_info(map, p[0], enc);
4783 if (n < 0)
return n;
4785 for (i = 0; i < n; i++) {
4787 add_char_opt_map_info(map, buf[0], enc);
4796 const int z = 1<<15;
4801 if (now->
value == 0) {
4802 copy_opt_map_info(now, alt);
4806 v1 = z / now->
value;
4807 v2 = z / alt->
value;
4808 if (comp_distance_value(&now->
mmd, &alt->
mmd, v1, v2) > 0)
4809 copy_opt_map_info(now, alt);
4815 #define COMP_EM_BASE 20 4818 if (m->
value <= 0)
return -1;
4822 return comp_distance_value(&e->
mmd, &m->
mmd, ve, vm);
4833 clear_opt_map_info(to);
4837 alt_merge_mml(&to->
mmd, &add->
mmd);
4845 val += map_position_value(enc, i);
4849 alt_merge_opt_anc_info(&to->
anc, &add->
anc);
4855 copy_mml(&(opt->
exb.
mmd), mmd);
4856 copy_mml(&(opt->
expr.
mmd), mmd);
4857 copy_mml(&(opt->
map.
mmd), mmd);
4863 clear_mml(&opt->
len);
4864 clear_opt_anc_info(&opt->
anc);
4865 clear_opt_exact_info(&opt->
exb);
4866 clear_opt_exact_info(&opt->
exm);
4867 clear_opt_exact_info(&opt->
expr);
4868 clear_opt_map_info(&opt->
map);
4880 int exb_reach, exm_reach;
4884 copy_opt_anc_info(&to->
anc, &tanc);
4887 concat_opt_anc_info(&tanc, &to->
anc, &add->
exb.
anc,
4889 copy_opt_anc_info(&add->
exb.
anc, &tanc);
4905 concat_opt_exact_info(&to->
exb, &add->
exb, enc);
4906 clear_opt_exact_info(&add->
exb);
4908 else if (exm_reach) {
4909 concat_opt_exact_info(&to->
exm, &add->
exb, enc);
4910 clear_opt_exact_info(&add->
exb);
4913 select_opt_exact_info(enc, &to->
exm, &add->
exb);
4914 select_opt_exact_info(enc, &to->
exm, &add->
exm);
4922 select_opt_exact_info(enc, &to->
exb, &to->
expr);
4924 select_opt_exact_info(enc, &to->
exm, &to->
expr);
4928 copy_opt_exact_info(&to->
expr, &add->
expr);
4931 select_opt_map_info(&to->
map, &add->
map);
4933 add_mml(&to->
len, &add->
len);
4939 alt_merge_opt_anc_info (&to->
anc, &add->
anc);
4940 alt_merge_opt_exact_info(&to->
exb, &add->
exb, env);
4941 alt_merge_opt_exact_info(&to->
exm, &add->
exm, env);
4942 alt_merge_opt_exact_info(&to->
expr, &add->
expr, env);
4943 alt_merge_opt_map_info(env->
enc, &to->
map, &add->
map);
4945 alt_merge_mml(&to->
len, &add->
len);
4949 #define MAX_NODE_OPT_INFO_REF_COUNT 5 4957 clear_node_opt_info(opt);
4958 set_bound_node_opt_info(opt, &env->
mmd);
4968 copy_opt_env(&nenv, env);
4970 r = optimize_node_left(
NCAR(nd), &nopt, &nenv);
4972 add_mml(&nenv.
mmd, &nopt.
len);
4973 concat_left_node_opt_info(env->
enc, opt, &nopt);
4985 r = optimize_node_left(
NCAR(nd), &nopt, env);
4987 if (nd == node) copy_node_opt_info(opt, &nopt);
4988 else alt_merge_node_opt_info(opt, &nopt, env);
5001 concat_opt_exact_info_str(&opt->
exb, sn->
s, sn->
end,
5005 add_char_opt_map_info(&opt->
map, *(sn->
s), env->
enc);
5007 set_mml(&opt->
len, slen, slen);
5017 concat_opt_exact_info_str(&opt->
exb, sn->
s, sn->
end,
5022 r = add_char_amb_opt_map_info(&opt->
map, sn->
s, sn->
end,
5030 set_mml(&opt->
len, slen, max);
5049 set_mml(&opt->
len, min, max);
5055 add_char_opt_map_info(&opt->
map, (
UChar )i, env->
enc);
5058 set_mml(&opt->
len, 1, 1);
5074 switch (
NCTYPE(node)->ctype) {
5076 if (
NCTYPE(node)->not != 0) {
5079 add_char_opt_map_info(&opt->
map, (
UChar )i, env->
enc);
5084 for (i = 0; i < maxcode; i++) {
5086 add_char_opt_map_info(&opt->
map, (
UChar )i, env->
enc);
5096 set_mml(&opt->
len, min, max);
5104 set_mml(&opt->
len, min, max);
5109 switch (
NANCHOR(node)->type) {
5118 add_opt_anc_info(&opt->
anc,
NANCHOR(node)->type);
5125 r = optimize_node_left(
NANCHOR(node)->target, &nopt, env);
5128 copy_opt_exact_info(&opt->
expr, &nopt.
exb);
5129 else if (nopt.
exm.
len > 0)
5130 copy_opt_exact_info(&opt->
expr, &nopt.
exm);
5135 copy_opt_map_info(&opt->
map, &nopt.
map);
5158 r = get_min_match_length(nodes[backs[0]], &min, env->
scan_env);
5160 r = get_max_match_length(nodes[backs[0]], &max, env->
scan_env);
5162 for (i = 1; i < br->
back_num; i++) {
5163 r = get_min_match_length(nodes[backs[i]], &tmin, env->
scan_env);
5165 r = get_max_match_length(nodes[backs[i]], &tmax, env->
scan_env);
5167 if (min > tmin) min = tmin;
5168 if (max < tmax) max = tmax;
5170 if (r == 0) set_mml(&opt->
len, min, max);
5174 #ifdef USE_SUBEXP_CALL 5181 r = optimize_node_left(
NCALL(node)->target, opt, env);
5194 r = optimize_node_left(qn->
target, &nopt, env);
5208 if (qn->
lower > 0) {
5209 copy_node_opt_info(opt, &nopt);
5212 for (i = 2; i <= qn->
lower &&
5213 ! is_full_opt_exact_info(&opt->
exb); i++) {
5214 concat_opt_exact_info(&opt->
exb, &nopt.
exb, env->
enc);
5216 if (i < qn->lower) {
5237 set_mml(&opt->
len, min, max);
5251 r = optimize_node_left(en->
target, opt, env);
5257 #ifdef USE_SUBEXP_CALL 5266 set_mml(&opt->
len, min, max);
5271 r = optimize_node_left(en->
target, opt, env);
5282 r = optimize_node_left(en->
target, opt, env);
5294 fprintf(stderr,
"optimize_node_left: undefined node type %d\n",
5310 if (e->
len == 0)
return 0;
5321 if (e->
len >= 3 || (e->
len >= 2 && allow_reverse)) {
5325 reg->
optimize = (allow_reverse != 0
5337 if (e->
len >= 3 || (e->
len >= 2 && allow_reverse)) {
5341 reg->
optimize = (allow_reverse != 0
5387 #if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH) 5388 static void print_optimize_info(
FILE*
f,
regex_t* reg);
5403 clear_mml(&env.
mmd);
5405 r = optimize_node_left(node, &opt, &env);
5424 select_opt_exact_info(reg->
enc, &opt.
exb, &opt.
exm);
5426 comp_opt_exact_or_map_info(&opt.
exb, &opt.
map) > 0) {
5430 r = set_optimize_exact_info(reg, &opt.
exb);
5431 set_sub_anchor(reg, &opt.
exb.
anc);
5436 set_optimize_map_info(reg, &opt.
map);
5437 set_sub_anchor(reg, &opt.
map.
anc);
5445 #if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH) 5446 print_optimize_info(stderr, reg);
5452 clear_optimize_info(
regex_t* reg)
5472 fprintf(fp,
"\nPATTERN: /");
5482 fprintf(fp,
" 0x%04x ", (
int )code);
5485 fputc((
int )code, fp);
5488 p +=
enclen(enc, p, end);
5493 fputc((
int )*s, fp);
5498 fprintf(fp,
"/ (%s)\n", enc->
name);
5502 #if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH) 5509 fprintf(f,
"(%"PRIuPTR")", a);
5516 fprintf(f,
"(%"PRIuPTR")", b);
5520 print_anchor(
FILE* f,
int anchor)
5527 fprintf(f,
"begin-buf");
5531 if (q) fprintf(f,
", ");
5533 fprintf(f,
"begin-line");
5536 if (q) fprintf(f,
", ");
5538 fprintf(f,
"begin-pos");
5541 if (q) fprintf(f,
", ");
5543 fprintf(f,
"end-buf");
5546 if (q) fprintf(f,
", ");
5548 fprintf(f,
"semi-end-buf");
5551 if (q) fprintf(f,
", ");
5553 fprintf(f,
"end-line");
5556 if (q) fprintf(f,
", ");
5558 fprintf(f,
"anychar-star");
5561 if (q) fprintf(f,
", ");
5562 fprintf(f,
"anychar-star-ml");
5571 static const char* on[] = {
"NONE",
"EXACT",
"EXACT_BM",
"EXACT_BM_NOT_REV",
5573 "EXACT_BM_IC",
"EXACT_BM_NOT_REV_IC" };
5575 fprintf(f,
"optimize: %s\n", on[reg->
optimize]);
5576 fprintf(f,
" anchor: "); print_anchor(f, reg->
anchor);
5582 fprintf(f,
" sub anchor: "); print_anchor(f, reg->
sub_anchor);
5589 fprintf(f,
"exact: [");
5590 for (p = reg->
exact; p < reg->exact_end; p++) {
5599 if (reg->
map[i]) n++;
5601 fprintf(f,
"map: n=%d\n", n);
5606 if (reg->
map[i] != 0) {
5607 if (c > 0) fputs(
", ", f);
5613 fprintf(f,
"%d", i);
5634 #ifdef USE_NAMED_GROUP 5668 size_t size =
sizeof(*regs);
5675 #define REGEX_TRANSFER(to,from) do {\ 5676 onig_free_body(to);\ 5677 xmemcpy(to, from, sizeof(regex_t));\ 5689 #ifdef ONIG_DEBUG_COMPILE 5690 static void print_compiled_byte_code_list(
FILE* f,
regex_t* reg);
5692 #ifdef ONIG_DEBUG_PARSE_TREE 5693 static void print_tree(
FILE* f,
Node* node);
5708 OnigErrorInfo* einfo,
const char *sourcefile,
int sourceline)
5715 #define COMPILE_INIT_SIZE 20 5721 #ifdef USE_SUBEXP_CALL 5733 print_enc_string(stderr, reg->
enc, pattern, pattern_end);
5736 if (reg->
alloc == 0) {
5737 init_size = (pattern_end - pattern) * 2;
5740 if (r != 0)
goto end;
5750 #ifdef USE_COMBINATION_EXPLOSION_CHECK 5755 if (r != 0)
goto err;
5757 #ifdef ONIG_DEBUG_PARSE_TREE 5759 fprintf(stderr,
"ORIGINAL PARSE TREE:\n");
5760 print_tree(stderr, root);
5764 #ifdef USE_NAMED_GROUP 5770 r = disable_noname_group_capture(&root, reg, &scan_env);
5772 r = numbered_ref_check(root);
5774 if (r != 0)
goto err;
5778 #ifdef USE_SUBEXP_CALL 5780 r = unset_addr_list_init(&uslist, scan_env.
num_call);
5781 if (r != 0)
goto err;
5783 r = setup_subexp_call(root, &scan_env);
5784 if (r != 0)
goto err_unset;
5785 r = subexp_recursive_check_trav(root, &scan_env);
5786 if (r < 0)
goto err_unset;
5787 r = subexp_inf_recursive_check_trav(root, &scan_env);
5788 if (r != 0)
goto err_unset;
5796 r = setup_tree(root, reg, 0, &scan_env);
5797 if (r != 0)
goto err_unset;
5799 #ifdef ONIG_DEBUG_PARSE_TREE 5800 print_tree(stderr, root);
5813 #ifdef USE_COMBINATION_EXPLOSION_CHECK 5819 setup_comb_exp_check(root, 0, &scan_env);
5820 # ifdef USE_SUBEXP_CALL 5821 if (scan_env.has_recursion != 0) {
5822 scan_env.num_comb_exp_check = 0;
5826 if (scan_env.comb_exp_max_regnum > 0) {
5828 for (i = 1; i <= scan_env.comb_exp_max_regnum; i++) {
5830 scan_env.num_comb_exp_check = 0;
5840 clear_optimize_info(reg);
5841 #ifndef ONIG_DONT_OPTIMIZE 5842 r = set_optimize_info_from_tree(root, reg, &scan_env);
5843 if (r != 0)
goto err_unset;
5851 r = compile_tree(root, reg);
5853 r = add_opcode(reg,
OP_END);
5854 #ifdef USE_SUBEXP_CALL 5856 r = unset_addr_list_fix(&uslist, reg);
5857 unset_addr_list_end(&uslist);
5871 #ifdef USE_SUBEXP_CALL 5873 unset_addr_list_end(&uslist);
5878 #ifdef ONIG_DEBUG_COMPILE 5879 # ifdef USE_NAMED_GROUP 5880 onig_print_names(stderr, reg);
5882 print_compiled_byte_code_list(stderr, reg);
5889 #ifdef USE_SUBEXP_CALL 5891 unset_addr_list_end(&uslist);
5897 einfo->
enc = scan_env.
enc;
5909 static int onig_inited = 0;
5938 (reg)->options = option;
5939 (reg)->syntax = syntax;
5940 (reg)->optimize = 0;
5942 (reg)->int_map = (
int* )
NULL;
5943 (reg)->int_map_backward = (
int* )
NULL;
5949 (reg)->name_table = (
void* )
NULL;
5951 (reg)->case_fold_flag = case_fold_flag;
6000 if (onig_inited != 0)
6005 #if defined(ONIG_DEBUG_MEMLEAK) && defined(_MSC_VER) 6006 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
6012 #ifdef ONIG_DEBUG_STATISTICS 6013 onig_statistics_init();
6029 item->
next = EndCallTop;
6036 exec_end_call_list(
void)
6041 while (EndCallTop != 0) {
6042 func = EndCallTop->
func;
6046 EndCallTop = EndCallTop->
next;
6054 exec_end_call_list();
6056 #ifdef ONIG_DEBUG_STATISTICS 6057 onig_print_statistics(stderr);
6060 #if defined(ONIG_DEBUG_MEMLEAK) && defined(_MSC_VER) 6061 _CrtDumpMemoryLeaks();
6079 for (low = 0, high = n; low < high; ) {
6080 x = (low + high) >> 1;
6081 if (code > data[x * 2 + 1])
6087 return ((low < n && code >= data[low * 2]) ? 1 : 0);
6131 # define ARG_SPECIAL -1 6133 # define ARG_RELADDR 1 6134 # define ARG_ABSADDR 2 6135 # define ARG_LENGTH 3 6136 # define ARG_MEMNUM 4 6137 # define ARG_OPTION 5 6138 # define ARG_STATE_CHECK 6 6140 OnigOpInfoType OnigOpInfo[] = {
6142 {
OP_END,
"end", ARG_NON },
6204 {
OP_JUMP,
"jump", ARG_RELADDR },
6205 {
OP_PUSH,
"push", ARG_RELADDR },
6206 {
OP_POP,
"pop", ARG_NON },
6231 {
OP_CALL,
"call", ARG_ABSADDR },
6239 "state-check-anychar-ml*", ARG_STATE_CHECK },
6248 for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
6249 if (opcode == OnigOpInfo[i].opcode)
6250 return OnigOpInfo[i].name;
6256 op2arg_type(
int opcode)
6260 for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
6261 if (opcode == OnigOpInfo[i].opcode)
6262 return OnigOpInfo[i].arg_type;
6267 # ifdef ONIG_DEBUG_PARSE_TREE 6269 Indent(
FILE* f,
int indent)
6272 for (i = 0; i < indent; i++) putc(
' ', f);
6280 while (len-- > 0) { fputc(*s++, f); }
6286 int x = len * mb_len;
6288 fprintf(f,
":%d:", len);
6289 while (x-- > 0) { fputc(*s++, f); }
6304 fprintf(f,
"[%s", op2name(*bp));
6305 arg_type = op2arg_type(*bp);
6306 if (arg_type != ARG_SPECIAL) {
6313 fprintf(f,
":(%s%d)", (addr >= 0) ?
"+" :
"", addr);
6317 fprintf(f,
":(%d)", addr);
6321 fprintf(f,
":%d", len);
6326 fprintf(f,
":%d", mem);
6332 fprintf(f,
":%d", option);
6336 case ARG_STATE_CHECK:
6339 fprintf(f,
":%d", scn);
6348 p_string(f, 1, bp++);
break;
6350 p_string(f, 2, bp); bp += 2;
break;
6352 p_string(f, 3, bp); bp += 3;
break;
6354 p_string(f, 4, bp); bp += 4;
break;
6356 p_string(f, 5, bp); bp += 5;
break;
6359 p_len_string(f, len, 1, bp);
6364 p_string(f, 2, bp); bp += 2;
break;
6366 p_string(f, 4, bp); bp += 4;
break;
6368 p_string(f, 6, bp); bp += 6;
break;
6371 p_len_string(f, len, 2, bp);
6376 p_len_string(f, len, 3, bp);
6385 fprintf(f,
":%d:%d:", mb_len, len);
6387 while (n-- > 0) { fputc(*bp++, f); }
6392 len =
enclen(enc, bp, bpend);
6393 p_string(f, len, bp);
6398 p_len_string(f, len, 1, bp);
6405 fprintf(f,
":%d", n);
6411 fprintf(f,
":%d", n);
6418 # ifndef PLATFORM_UNALIGNED_WORD_ACCESS 6423 fprintf(f,
":%d:%d", (
int )code, len);
6432 # ifndef PLATFORM_UNALIGNED_WORD_ACCESS 6437 fprintf(f,
":%d:%d:%d", n, (
int )code, len);
6443 fprintf(f,
":%d", mem);
6450 for (i = 0; i <
len; i++) {
6452 if (i > 0) fputs(
", ", f);
6453 fprintf(f,
"%d", mem);
6463 fprintf(f,
":%d", option);
6465 fprintf(f,
":%d", level);
6469 for (i = 0; i <
len; i++) {
6471 if (i > 0) fputs(
", ", f);
6472 fprintf(f,
"%d", mem);
6484 fprintf(f,
":%d:%d", mem, addr);
6492 fprintf(f,
":(%s%d)", (addr >= 0) ?
"+" :
"", addr);
6499 fprintf(f,
":%d", len);
6505 fprintf(f,
":%d:(%s%d)", len, (addr >= 0) ?
"+" :
"", addr);
6514 fprintf(f,
":%d:(%s%d)", scn, (addr >= 0) ?
"+" :
"", addr);
6520 fprintf(f,
":%d:(%s%d)", mem, (addr >= 0) ?
"+" :
"", addr);
6524 fprintf(stderr,
"onig_print_compiled_byte_code: undefined code %d\n",
6529 if (nextp) *nextp =
bp;
6532 # ifdef ONIG_DEBUG_COMPILE 6534 print_compiled_byte_code_list(
FILE* f,
regex_t* reg)
6540 fprintf(f,
"code length: %d", reg->
used);
6546 fprintf(f,
"\n%ld:", bp - reg->
p);
6548 fprintf(f,
" %ld:", bp - reg->
p);
6549 onig_print_compiled_byte_code(f, bp, end, &bp, reg->
enc);
6556 # ifdef ONIG_DEBUG_PARSE_TREE 6558 print_indent_tree(
FILE* f,
Node* node,
int indent)
6560 int i, type, container_p = 0;
6566 fprintf(f,
"ERROR: null node!!!\n");
6579 print_indent_tree(f,
NCAR(node), indent + add);
6581 if (
NTYPE(node) != type) {
6582 fprintf(f,
"ERROR: list/alt right is not a cons. %d\n",
NTYPE(node));
6585 print_indent_tree(f,
NCAR(node), indent + add);
6590 fprintf(f,
"<string%s:%"PRIxPTR">",
6592 for (p =
NSTR(node)->s; p <
NSTR(node)->end; p++) {
6593 if (*p >= 0x20 && *p < 0x7f)
6596 fprintf(f,
" 0x%02x", *p);
6608 fprintf(f,
"%d", *data++);
6609 for (; data <
end; data+=2) {
6611 fprintf(f,
"%04x-%04x", data[0], data[1]);
6618 switch (
NCTYPE(node)->ctype) {
6620 if (
NCTYPE(node)->not != 0)
6621 fputs(
"not word", f);
6627 fprintf(f,
"ERROR: undefined ctype.\n");
6638 switch (
NANCHOR(node)->type) {
6648 # ifdef USE_WORD_BEGIN_END 6659 fprintf(f,
"ERROR: undefined anchor type.\n");
6670 for (i = 0; i < br->
back_num; i++) {
6671 if (i > 0) fputs(
", ", f);
6672 fprintf(f,
"%d", p[i]);
6677 # ifdef USE_SUBEXP_CALL 6690 (
NQTFR(node)->greedy ?
"" :
"?"));
6691 print_indent_tree(f,
NQTFR(node)->target, indent + add);
6698 fprintf(f,
"option:%d",
NENCLOSE(node)->option);
6701 fprintf(f,
"memory:%d",
NENCLOSE(node)->regnum);
6704 fprintf(f,
"stop-bt");
6707 fprintf(f,
"condition:%d",
NENCLOSE(node)->regnum);
6710 fprintf(f,
"absent");
6717 print_indent_tree(f,
NENCLOSE(node)->target, indent + add);
6721 fprintf(f,
"print_indent_tree: undefined node type %d\n",
NTYPE(node));
6729 if (container_p) print_indent_tree(f,
NANCHOR(node)->target, indent + add);
6737 print_indent_tree(f, node, 0);
unsigned int OnigOptionType
#define SIZE_OP_SET_OPTION_PUSH
#define ANCHOR_ANYCHAR_STAR_ML
#define SIZE_OP_MEMORY_END_PUSH_REC
#define IS_DYNAMIC_OPTION(option)
#define NSTRING_SET_AMBIG(node)
#define BIT_STATUS_AT(stats, n)
#define IS_ENCLOSE_CALLED(en)
void onig_scan_env_set_error_string(ScanEnv *env, int ecode ARG_UNUSED, UChar *arg, UChar *arg_end)
ONIG_EXTERN int onigenc_init(void)
#define ONIGENC_CODE_TO_MBCLEN(enc, code)
int onig_compile_ruby(regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
unsigned int OnigCodePoint
#define ONIGENC_MBC_MAXLEN(enc)
int onig_new(regex_t **reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo)
#define IS_REPEAT_INFINITE(n)
#define ALLOWED_ANCHOR_IN_LB_NOT
int onig_node_str_cat(Node *node, const UChar *s, const UChar *end)
Node * onig_node_list_add(Node *list, Node *x)
#define IS_SYNTAX_BV(syn, bvm)
#define NSTRING_IS_RAW(node)
#define WORD_ALIGNMENT_SIZE
#define BIT_STATUS_ON_AT(stats, n)
#define ONIG_OPTIMIZE_EXACT
#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION
#define ONIGERR_INVALID_COMBINATION_OF_OPTIONS
#define ONIGERR_INVALID_LOOK_BEHIND_PATTERN
#define BBUF_ADD1(buf, byte)
#define ONIGERR_INVALID_BACKREF
#define ANCHOR_WORD_BEGIN
#define IS_ENCLOSE_RECURSION(en)
#define SIZE_OP_REPEAT_INC
#define NSTRING_IS_AMBIG(node)
#define BBUF_WRITE(buf, pos, bytes, n)
#define IS_ENCLOSE_MAX_FIXED(en)
#define ONIGENC_IS_MBC_ASCII_WORD(enc, s, end)
#define SCANENV_MEM_NODES(senv)
size_t onig_memsize(const regex_t *reg)
#define IS_CODE_SB_WORD(enc, code)
#define ONIG_IS_OPTION_ON(options, option)
#define SIZE_OP_ABSENT_END
int onig_names_free(regex_t *reg)
#define ANCHOR_BEGIN_LINE
int onig_initialize(OnigEncoding encodings[] ARG_UNUSED, int n ARG_UNUSED)
#define ONIGENC_CASE_FOLD_DEFAULT
int onig_is_in_code_range(const UChar *p, OnigCodePoint code)
#define QUANTIFIER_EXPAND_LIMIT_SIZE
#define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc, s, end)
int onig_node_str_set(Node *node, const UChar *s, const UChar *end)
OnigCaseFoldType onig_get_default_case_fold_flag(void)
#define IS_NCCLASS_NOT(nd)
#define GET_CHAR_LEN_VARLEN
void onig_add_end_call(void(*func)(void))
#define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
#define IS_ENCLOSE_MIN_FIXED(en)
UnsetAddrList * unset_addr_list
#define IS_BACKREF_NEST_LEVEL(bn)
unsigned int OnigCaseFoldType
struct _Node * next_head_exact
#define GET_CODE_POINT(code, p)
Node * onig_node_new_alt(Node *left, Node *right)
#define NQ_TARGET_IS_EMPTY_MEM
unsigned char map[ONIG_CHAR_TABLE_SIZE]
#define IS_CALL_RECURSION(cn)
#define BIT_STATUS_ON_AT_SIMPLE(stats, n)
#define ALLOWED_ANCHOR_IN_LB
#define ONIG_OPTION_IGNORECASE
#define REPEAT_RANGE_ALLOC
#define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME_CALL
#define ONIG_OPTIMIZE_EXACT_IC
#define NST_MEM_BACKREFED
#define GET_OPTION_INC(option, p)
#define ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM
#define GET_LENGTH_INC(len, p)
#define ANCHOR_BEGIN_POSITION
OnigCaseFoldType case_fold_flag
#define RECURSION_INFINITE
#define ONIGENC_MBC_CASE_FOLD_MAXLEN
#define ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND
UChar buf[NODE_STR_BUF_SIZE]
ONIG_EXTERN int onigenc_strlen(OnigEncoding enc, const OnigUChar *p, const OnigUChar *end)
#define ANCHOR_NOT_WORD_BOUND
unsigned int bt_mem_start
unsigned int BitStatusType
#define BIT_STATUS_ON_ALL(stats)
#define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT
#define ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL
#define SIZE_STATE_CHECK_NUM
#define IS_ENCLOSE_CLEN_FIXED(en)
#define ALLOWED_ENCLOSE_IN_LB
void onig_free_body(regex_t *reg)
#define COMPILE_INIT_SIZE
#define BIT_STATUS_CLEAR(stats)
#define SIZE_OP_MEMORY_START
#define ONIGENC_CODE_TO_MBC_MAXLEN
UnsetAddrList * unset_addr_list
#define SIZE_OP_PUSH_STOP_BT
struct _Node * head_exact
#define ALLOWED_ENCLOSE_IN_LB_NOT
#define IS_IGNORECASE(option)
#define SIZE_OP_CONDITION
#define ONIG_OPTION_CAPTURE_GROUP
OnigRepeatRange * repeat_range
#define ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP
#define GET_MEMNUM_INC(num, p)
#define STACK_POP_LEVEL_MEM_START
#define STACK_POP_LEVEL_ALL
#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC
int onig_bbuf_init(BBuf *buf, OnigDistance size)
#define SIZE_OP_NULL_CHECK_START
#define GET_CHAR_LEN_TOP_ALT_VARLEN
OnigCaseFoldType case_fold_flag
#define MAX_NODE_OPT_INFO_REF_COUNT
#define ONIG_MAX_CAPTURE_HISTORY_GROUP
#define BBUF_INIT(buf, size)
#define ONIGENC_MBC_CASE_FOLD(enc, flag, pp, end, buf)
#define SET_ENCLOSE_STATUS(node, f)
const OnigSyntaxType * syntax
#define ONIGERR_INVALID_ARGUMENT
#define ONIGENC_IS_CODE_WORD(enc, code)
#define IS_MULTILINE(option)
#define ALIGNMENT_RIGHT(addr)
#define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag)
#define SIZE_OP_PUSH_LOOK_BEHIND_NOT
#define NQ_TARGET_IS_EMPTY_REC
#define BITSET_AT(bs, pos)
#define ONIGERR_UNDEFINED_NAME_REFERENCE
OnigCaseFoldType OnigDefaultCaseFoldFlag
#define CHECK_NULL_RETURN_MEMERR(p)
Node * onig_node_new_enclose(int type)
int onig_reg_init(regex_t *reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, const OnigSyntaxType *syntax)
#define ONIG_OPTIMIZE_MAP
#define ONIG_INFINITE_DISTANCE
#define SIZE_OP_MEMORY_END_PUSH
#define NQ_TARGET_IS_EMPTY
#define ONIGENC_MBC_MINLEN(enc)
size_t onig_region_memsize(const OnigRegion *regs)
#define ONIG_OPTION_DONT_CAPTURE_GROUP
int onig_compile(regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo)
short int StateCheckNumType
struct re_pattern_buffer * chain
#define ONIG_OPTION_NEGATE_SINGLELINE
#define FOUND_CALLED_NODE
#define SIZE_OP_ANYCHAR_STAR
#define ALLOWED_TYPE_IN_LB
#define ONIGERR_UNDEFINED_GROUP_REFERENCE
#define GET_ALIGNMENT_PAD_SIZE(addr, pad_size)
#define EXPAND_STRING_MAX_LENGTH
int onig_new_without_alloc(regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo)
#define ONIG_OPTION_SINGLELINE
#define ONIGENC_CTYPE_WORD
#define SIZE_OP_MEMORY_END
#define ONIG_OPTIMIZE_EXACT_BM_IC
#define SIZE_OP_MEMORY_START_PUSH
#define ONIG_CHAR_TABLE_SIZE
#define IS_ENCLOSE_NAME_REF(en)
#define SIZE_OP_PUSH_IF_PEEK_NEXT
#define ONIGENC_MBC_TO_CODE(enc, p, end)
#define ONIGENC_CASE_FOLD_MIN
#define ANCHOR_END_BUF_MASK
unsigned char buf[MIME_BUF_SIZE]
#define IS_QUANTIFIER_IN_REPEAT(qn)
int onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode *cc)
#define ANCHOR_LOOK_BEHIND_NOT
BitStatusType backrefed_mem
#define SIZE_OP_NULL_CHECK_END
void onig_transfer(regex_t *to, regex_t *from)
Node * onig_node_new_list(Node *left, Node *right)
#define NSTRING_IS_DONT_GET_OPT_INFO(node)
#define IS_ENCLOSE_ADDR_FIXED(en)
#define IS_BACKREF_NAME_REF(bn)
#define SIZE_OP_POP_STOP_BT
#define ANCHOR_SEMI_END_BUF
#define ONIG_OPTIMIZE_NONE
Node * onig_node_new_str(const UChar *s, const UChar *end)
#define IS_ENCLOSE_MARK1(en)
#define SIZE_OP_FAIL_LOOK_BEHIND_NOT
Node ** mem_nodes_dynamic
UChar s[OPT_EXACT_MAXLEN]
#define ENCLOSE_STOP_BACKTRACK
void onig_node_free(Node *node)
register unsigned int len
#define NST_STOP_BT_SIMPLE_REPEAT
#define ANCHOR_ANYCHAR_STAR
#define IS_NEED_STR_LEN_OP_EXACT(op)
#define STACK_POP_LEVEL_FREE
#define CHECK_NULL_RETURN(p)
unsigned char * exact_end
#define SIZE_OP_SET_OPTION
#define GET_RELADDR_INC(addr, p)
#define ANCHOR_PREC_READ_NOT
#define ENCLOSE_CONDITION
void onig_reduce_nested_quantifier(Node *pnode, Node *cnode)
#define ONIGENC_MBC_MAXLEN_DIST(enc)
unsigned int capture_history
#define IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(en)
#define IS_FIND_CONDITION(option)
#define ONIGENC_CODE_TO_MBC(enc, code, buf)
#define SIZE_OP_MEMORY_END_REC
OnigCodePoint code[ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN]
#define ANCHOR_ANYCHAR_STAR_MASK
#define ONIGERR_NEVER_ENDING_RECURSION
#define CLEAR_ENCLOSE_STATUS(node, f)
#define ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, case_fold_flag, p, end, acs)
int onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode *cc)
int onig_parse_make_tree(Node **root, const UChar *pattern, const UChar *end, regex_t *reg, ScanEnv *env)
#define SIZE_OP_PUSH_ABSENT_POS
#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV
#define ONIGENC_IS_MBC_WORD(enc, s, end)
#define SIZE_OP_PUSH_OR_JUMP_EXACT1
ONIG_EXTERN int onig_name_to_group_numbers(OnigRegex reg, const OnigUChar *name, const OnigUChar *name_end, int **nums)
#define ONIGENC_IS_UNDEF(enc)
#define IS_NODE_TYPE_SIMPLE(type)
#define ANCHOR_LOOK_BEHIND
#define IS_ENCLOSE_MARK2(en)
#define NSTRING_LEN(node)
#define IS_ENCLOSE_NAMED_GROUP(en)
UChar map[ONIG_CHAR_TABLE_SIZE]
BitStatusType bt_mem_start
#define NSTRING_SET_DONT_GET_OPT_INFO(node)
#define SIZE_OP_PUSH_POS_NOT
#define ONIGENC_IS_CODE_PRINT(enc, code)
#define ANCHOR_WORD_BOUND
#define ONIG_OPTIMIZE_EXACT_BM
int onig_renumber_name_table(regex_t *reg, GroupNumRemap *map)
#define ONIGERR_DEFAULT_ENCODING_IS_NOT_SET
void onig_free(regex_t *reg)
struct OnigEndCallListItem * next
#define GET_ABSADDR_INC(addr, p)
#define SET_CALL_RECURSION(node)
#define BBUF_GET_OFFSET_POS(buf)
#define SET_NTYPE(node, ntype)
#define ONIGERR_PARSER_BUG
#define REGEX_TRANSFER(to, from)
#define ONIGERR_INVALID_CONDITION_PATTERN
int onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag)
#define enclen(enc, p, e)
#define BBUF_GET_ADD_ADDRESS(buf)
#define SIZE_OP_LOOK_BEHIND
#define BBUF_ADD(buf, bytes, n)
BitStatusType capture_history
int back_static[NODE_BACKREFS_SIZE]
Node * onig_node_new_anchor(int type)