Lines Matching refs:r
58 UChar* r = (UChar* )xmalloc(len + 1); in str_dup() local
59 CHECK_NULL_RETURN(r); in str_dup()
60 xmemcpy(r, s, len); in str_dup()
61 r[len] = (UChar )0; in str_dup()
62 return r; in str_dup()
273 int r; in add_opcode_rel_addr() local
275 r = add_opcode(reg, opcode); in add_opcode_rel_addr()
276 if (r) return r; in add_opcode_rel_addr()
277 r = add_rel_addr(reg, addr); in add_opcode_rel_addr()
278 return r; in add_opcode_rel_addr()
298 int r; in add_opcode_option() local
300 r = add_opcode(reg, opcode); in add_opcode_option()
301 if (r) return r; in add_opcode_option()
302 r = add_option(reg, option); in add_opcode_option()
303 return r; in add_opcode_option()
362 int r; in compile_tree_empty_check() local
366 r = add_opcode(reg, OP_NULL_CHECK_START); in compile_tree_empty_check()
367 if (r) return r; in compile_tree_empty_check()
368 r = add_mem_num(reg, reg->num_null_check); /* NULL CHECK ID */ in compile_tree_empty_check()
369 if (r) return r; in compile_tree_empty_check()
373 r = compile_tree(node, reg); in compile_tree_empty_check()
374 if (r) return r; in compile_tree_empty_check()
378 r = add_opcode(reg, OP_NULL_CHECK_END); in compile_tree_empty_check()
380 r = add_opcode(reg, OP_NULL_CHECK_END_MEMST); in compile_tree_empty_check()
382 r = add_opcode(reg, OP_NULL_CHECK_END_MEMST_PUSH); in compile_tree_empty_check()
384 if (r) return r; in compile_tree_empty_check()
385 r = add_mem_num(reg, saved_num_null_check); /* NULL CHECK ID */ in compile_tree_empty_check()
387 return r; in compile_tree_empty_check()
394 int r; in compile_call() local
396 r = add_opcode(reg, OP_CALL); in compile_call()
397 if (r) return r; in compile_call()
398 r = unset_addr_list_add(node->unset_addr_list, BBUF_GET_OFFSET_POS(reg), in compile_call()
400 if (r) return r; in compile_call()
401 r = add_abs_addr(reg, 0 /*dummy addr.*/); in compile_call()
402 return r; in compile_call()
409 int i, r; in compile_tree_n_times() local
412 r = compile_tree(node, reg); in compile_tree_n_times()
413 if (r) return r; in compile_tree_n_times()
460 int rlen, r, len, prev_len, slen, ambig; in compile_length_string_node() local
483 r = add_compile_string_length(prev, prev_len, slen, reg, ambig); in compile_length_string_node()
484 rlen += r; in compile_length_string_node()
491 r = add_compile_string_length(prev, prev_len, slen, reg, ambig); in compile_length_string_node()
492 rlen += r; in compile_length_string_node()
508 int r, len, prev_len, slen, ambig; in compile_string_node() local
531 r = add_compile_string(prev, prev_len, slen, reg, ambig); in compile_string_node()
532 if (r) return r; in compile_string_node()
560 int r, pad_size; in add_multi_byte_cclass()
567 r = add_bytes(reg, mbuf->p, mbuf->used); in add_multi_byte_cclass()
572 return r; in add_multi_byte_cclass()
609 int r; in compile_cclass_node() local
613 r = add_pointer(reg, cc); in compile_cclass_node()
614 return r; in compile_cclass_node()
623 r = add_bitset(reg, cc->bs); in compile_cclass_node()
632 r = add_multi_byte_cclass(cc->mbuf, reg); in compile_cclass_node()
640 r = add_bitset(reg, cc->bs); in compile_cclass_node()
641 if (r) return r; in compile_cclass_node()
642 r = add_multi_byte_cclass(cc->mbuf, reg); in compile_cclass_node()
646 return r; in compile_cclass_node()
684 int r; in compile_range_repeat_node() local
687 r = add_opcode(reg, qn->greedy ? OP_REPEAT : OP_REPEAT_NG); in compile_range_repeat_node()
688 if (r) return r; in compile_range_repeat_node()
689 r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */ in compile_range_repeat_node()
691 if (r) return r; in compile_range_repeat_node()
692 r = add_rel_addr(reg, target_len + SIZE_OP_REPEAT_INC); in compile_range_repeat_node()
693 if (r) return r; in compile_range_repeat_node()
695 r = entry_repeat_range(reg, num_repeat, qn->lower, qn->upper); in compile_range_repeat_node()
696 if (r) return r; in compile_range_repeat_node()
698 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_range_repeat_node()
699 if (r) return r; in compile_range_repeat_node()
706 r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC_SG : OP_REPEAT_INC_NG_SG); in compile_range_repeat_node()
709 r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC : OP_REPEAT_INC_NG); in compile_range_repeat_node()
711 if (r) return r; in compile_range_repeat_node()
712 r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */ in compile_range_repeat_node()
713 return r; in compile_range_repeat_node()
814 int r, mod_tlen; in compile_quantifier_node() local
825 r = compile_tree_n_times(qn->target, qn->lower, reg); in compile_quantifier_node()
826 if (r) return r; in compile_quantifier_node()
829 r = add_opcode(reg, OP_ANYCHAR_ML_STAR_PEEK_NEXT); in compile_quantifier_node()
831 r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT); in compile_quantifier_node()
832 if (r) return r; in compile_quantifier_node()
834 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
835 if (r) return r; in compile_quantifier_node()
842 r = add_opcode(reg, (CKN_ON ? in compile_quantifier_node()
847 r = add_opcode(reg, (CKN_ON ? in compile_quantifier_node()
851 if (r) return r; in compile_quantifier_node()
853 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
855 return r; in compile_quantifier_node()
867 r = add_opcode_rel_addr(reg, OP_JUMP, in compile_quantifier_node()
869 if (r) return r; in compile_quantifier_node()
873 r = add_opcode(reg, OP_STATE_CHECK_PUSH); in compile_quantifier_node()
874 if (r) return r; in compile_quantifier_node()
875 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
876 if (r) return r; in compile_quantifier_node()
877 r = add_rel_addr(reg, mod_tlen + SIZE_OP_JUMP); in compile_quantifier_node()
880 r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP); in compile_quantifier_node()
882 if (r) return r; in compile_quantifier_node()
883 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_quantifier_node()
884 if (r) return r; in compile_quantifier_node()
885 r = add_opcode_rel_addr(reg, OP_JUMP, in compile_quantifier_node()
891 r = add_opcode_rel_addr(reg, OP_JUMP, mod_tlen); in compile_quantifier_node()
892 if (r) return r; in compile_quantifier_node()
894 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_quantifier_node()
895 if (r) return r; in compile_quantifier_node()
897 r = add_opcode(reg, OP_STATE_CHECK_PUSH_OR_JUMP); in compile_quantifier_node()
898 if (r) return r; in compile_quantifier_node()
899 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
900 if (r) return r; in compile_quantifier_node()
901 r = add_rel_addr(reg, in compile_quantifier_node()
905 r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH)); in compile_quantifier_node()
910 r = add_opcode_rel_addr(reg, OP_JUMP, tlen); in compile_quantifier_node()
911 if (r) return r; in compile_quantifier_node()
912 r = compile_tree(qn->target, reg); in compile_quantifier_node()
915 r = 0; in compile_quantifier_node()
920 r = add_opcode(reg, OP_STATE_CHECK_PUSH); in compile_quantifier_node()
921 if (r) return r; in compile_quantifier_node()
922 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
923 if (r) return r; in compile_quantifier_node()
924 r = add_rel_addr(reg, tlen); in compile_quantifier_node()
927 r = add_opcode_rel_addr(reg, OP_PUSH, tlen); in compile_quantifier_node()
929 if (r) return r; in compile_quantifier_node()
932 r = compile_tree(qn->target, reg); in compile_quantifier_node()
936 r = add_opcode(reg, OP_STATE_CHECK_PUSH); in compile_quantifier_node()
937 if (r) return r; in compile_quantifier_node()
938 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
939 if (r) return r; in compile_quantifier_node()
940 r = add_rel_addr(reg, SIZE_OP_JUMP); in compile_quantifier_node()
943 r = add_opcode_rel_addr(reg, OP_PUSH, SIZE_OP_JUMP); in compile_quantifier_node()
946 if (r) return r; in compile_quantifier_node()
947 r = add_opcode_rel_addr(reg, OP_JUMP, tlen); in compile_quantifier_node()
948 if (r) return r; in compile_quantifier_node()
949 r = compile_tree(qn->target, reg); in compile_quantifier_node()
952 r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg); in compile_quantifier_node()
954 if (r) return r; in compile_quantifier_node()
955 r = add_opcode(reg, OP_STATE_CHECK); in compile_quantifier_node()
956 if (r) return r; in compile_quantifier_node()
957 r = add_state_check_num(reg, ckn); in compile_quantifier_node()
960 return r; in compile_quantifier_node()
1033 int i, r, mod_tlen; in compile_quantifier_node() local
1041 r = compile_tree_n_times(qn->target, qn->lower, reg); in compile_quantifier_node()
1042 if (r) return r; in compile_quantifier_node()
1045 r = add_opcode(reg, OP_ANYCHAR_ML_STAR_PEEK_NEXT); in compile_quantifier_node()
1047 r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT); in compile_quantifier_node()
1048 if (r) return r; in compile_quantifier_node()
1069 r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH_OR_JUMP_EXACT1); in compile_quantifier_node()
1071 r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH_IF_PEEK_NEXT); in compile_quantifier_node()
1073 r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH); in compile_quantifier_node()
1076 r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_JUMP); in compile_quantifier_node()
1078 if (r) return r; in compile_quantifier_node()
1081 r = compile_tree_n_times(qn->target, qn->lower, reg); in compile_quantifier_node()
1082 if (r) return r; in compile_quantifier_node()
1087 r = add_opcode_rel_addr(reg, OP_PUSH_OR_JUMP_EXACT1, in compile_quantifier_node()
1089 if (r) return r; in compile_quantifier_node()
1091 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_quantifier_node()
1092 if (r) return r; in compile_quantifier_node()
1093 r = add_opcode_rel_addr(reg, OP_JUMP, in compile_quantifier_node()
1097 r = add_opcode_rel_addr(reg, OP_PUSH_IF_PEEK_NEXT, in compile_quantifier_node()
1099 if (r) return r; in compile_quantifier_node()
1101 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_quantifier_node()
1102 if (r) return r; in compile_quantifier_node()
1103 r = add_opcode_rel_addr(reg, OP_JUMP, in compile_quantifier_node()
1107 r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP); in compile_quantifier_node()
1108 if (r) return r; in compile_quantifier_node()
1109 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_quantifier_node()
1110 if (r) return r; in compile_quantifier_node()
1111 r = add_opcode_rel_addr(reg, OP_JUMP, in compile_quantifier_node()
1116 r = add_opcode_rel_addr(reg, OP_JUMP, mod_tlen); in compile_quantifier_node()
1117 if (r) return r; in compile_quantifier_node()
1118 r = compile_tree_empty_check(qn->target, reg, empty_info); in compile_quantifier_node()
1119 if (r) return r; in compile_quantifier_node()
1120 r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH)); in compile_quantifier_node()
1124 r = add_opcode_rel_addr(reg, OP_JUMP, tlen); in compile_quantifier_node()
1125 if (r) return r; in compile_quantifier_node()
1126 r = compile_tree(qn->target, reg); in compile_quantifier_node()
1133 r = compile_tree_n_times(qn->target, qn->lower, reg); in compile_quantifier_node()
1134 if (r) return r; in compile_quantifier_node()
1137 r = add_opcode_rel_addr(reg, OP_PUSH, in compile_quantifier_node()
1139 if (r) return r; in compile_quantifier_node()
1140 r = compile_tree(qn->target, reg); in compile_quantifier_node()
1141 if (r) return r; in compile_quantifier_node()
1145 r = add_opcode_rel_addr(reg, OP_PUSH, SIZE_OP_JUMP); in compile_quantifier_node()
1146 if (r) return r; in compile_quantifier_node()
1147 r = add_opcode_rel_addr(reg, OP_JUMP, tlen); in compile_quantifier_node()
1148 if (r) return r; in compile_quantifier_node()
1149 r = compile_tree(qn->target, reg); in compile_quantifier_node()
1152 r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg); in compile_quantifier_node()
1154 return r; in compile_quantifier_node()
1181 int r; in compile_option_node() local
1185 r = add_opcode_option(reg, OP_SET_OPTION_PUSH, node->option); in compile_option_node()
1186 if (r) return r; in compile_option_node()
1187 r = add_opcode_option(reg, OP_SET_OPTION, prev); in compile_option_node()
1188 if (r) return r; in compile_option_node()
1189 r = add_opcode(reg, OP_FAIL); in compile_option_node()
1190 if (r) return r; in compile_option_node()
1194 r = compile_tree(node->target, reg); in compile_option_node()
1198 if (r) return r; in compile_option_node()
1199 r = add_opcode_option(reg, OP_SET_OPTION, prev); in compile_option_node()
1201 return r; in compile_option_node()
1278 int r, len; in compile_enclose_node() local
1287 r = add_opcode(reg, OP_CALL); in compile_enclose_node()
1288 if (r) return r; in compile_enclose_node()
1291 r = add_abs_addr(reg, (int )node->call_addr); in compile_enclose_node()
1292 if (r) return r; in compile_enclose_node()
1302 r = add_opcode_rel_addr(reg, OP_JUMP, len); in compile_enclose_node()
1303 if (r) return r; in compile_enclose_node()
1307 r = add_opcode(reg, OP_MEMORY_START_PUSH); in compile_enclose_node()
1309 r = add_opcode(reg, OP_MEMORY_START); in compile_enclose_node()
1310 if (r) return r; in compile_enclose_node()
1311 r = add_mem_num(reg, node->regnum); in compile_enclose_node()
1312 if (r) return r; in compile_enclose_node()
1313 r = compile_tree(node->target, reg); in compile_enclose_node()
1314 if (r) return r; in compile_enclose_node()
1318 r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node) in compile_enclose_node()
1321 r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node) in compile_enclose_node()
1324 if (r) return r; in compile_enclose_node()
1325 r = add_mem_num(reg, node->regnum); in compile_enclose_node()
1326 if (r) return r; in compile_enclose_node()
1327 r = add_opcode(reg, OP_RETURN); in compile_enclose_node()
1331 r = add_opcode(reg, OP_MEMORY_END_PUSH_REC); in compile_enclose_node()
1333 r = add_opcode(reg, OP_MEMORY_END_REC); in compile_enclose_node()
1334 if (r) return r; in compile_enclose_node()
1335 r = add_mem_num(reg, node->regnum); in compile_enclose_node()
1341 r = add_opcode(reg, OP_MEMORY_END_PUSH); in compile_enclose_node()
1343 r = add_opcode(reg, OP_MEMORY_END); in compile_enclose_node()
1344 if (r) return r; in compile_enclose_node()
1345 r = add_mem_num(reg, node->regnum); in compile_enclose_node()
1352 r = compile_tree_n_times(qn->target, qn->lower, reg); in compile_enclose_node()
1353 if (r) return r; in compile_enclose_node()
1358 r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_POP + SIZE_OP_JUMP); in compile_enclose_node()
1359 if (r) return r; in compile_enclose_node()
1360 r = compile_tree(qn->target, reg); in compile_enclose_node()
1361 if (r) return r; in compile_enclose_node()
1362 r = add_opcode(reg, OP_POP); in compile_enclose_node()
1363 if (r) return r; in compile_enclose_node()
1364 r = add_opcode_rel_addr(reg, OP_JUMP, in compile_enclose_node()
1368 r = add_opcode(reg, OP_PUSH_STOP_BT); in compile_enclose_node()
1369 if (r) return r; in compile_enclose_node()
1370 r = compile_tree(node->target, reg); in compile_enclose_node()
1371 if (r) return r; in compile_enclose_node()
1372 r = add_opcode(reg, OP_POP_STOP_BT); in compile_enclose_node()
1381 return r; in compile_enclose_node()
1420 int r, len; in compile_anchor_node() local
1423 case ANCHOR_BEGIN_BUF: r = add_opcode(reg, OP_BEGIN_BUF); break; in compile_anchor_node()
1424 case ANCHOR_END_BUF: r = add_opcode(reg, OP_END_BUF); break; in compile_anchor_node()
1425 case ANCHOR_BEGIN_LINE: r = add_opcode(reg, OP_BEGIN_LINE); break; in compile_anchor_node()
1426 case ANCHOR_END_LINE: r = add_opcode(reg, OP_END_LINE); break; in compile_anchor_node()
1427 case ANCHOR_SEMI_END_BUF: r = add_opcode(reg, OP_SEMI_END_BUF); break; in compile_anchor_node()
1428 case ANCHOR_BEGIN_POSITION: r = add_opcode(reg, OP_BEGIN_POSITION); break; in compile_anchor_node()
1430 case ANCHOR_WORD_BOUND: r = add_opcode(reg, OP_WORD_BOUND); break; in compile_anchor_node()
1431 case ANCHOR_NOT_WORD_BOUND: r = add_opcode(reg, OP_NOT_WORD_BOUND); break; in compile_anchor_node()
1433 case ANCHOR_WORD_BEGIN: r = add_opcode(reg, OP_WORD_BEGIN); break; in compile_anchor_node()
1434 case ANCHOR_WORD_END: r = add_opcode(reg, OP_WORD_END); break; in compile_anchor_node()
1438 r = add_opcode(reg, OP_PUSH_POS); in compile_anchor_node()
1439 if (r) return r; in compile_anchor_node()
1440 r = compile_tree(node->target, reg); in compile_anchor_node()
1441 if (r) return r; in compile_anchor_node()
1442 r = add_opcode(reg, OP_POP_POS); in compile_anchor_node()
1448 r = add_opcode_rel_addr(reg, OP_PUSH_POS_NOT, len + SIZE_OP_FAIL_POS); in compile_anchor_node()
1449 if (r) return r; in compile_anchor_node()
1450 r = compile_tree(node->target, reg); in compile_anchor_node()
1451 if (r) return r; in compile_anchor_node()
1452 r = add_opcode(reg, OP_FAIL_POS); in compile_anchor_node()
1458 r = add_opcode(reg, OP_LOOK_BEHIND); in compile_anchor_node()
1459 if (r) return r; in compile_anchor_node()
1461 r = get_char_length_tree(node->target, reg, &n); in compile_anchor_node()
1462 if (r) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; in compile_anchor_node()
1467 r = add_length(reg, n); in compile_anchor_node()
1468 if (r) return r; in compile_anchor_node()
1469 r = compile_tree(node->target, reg); in compile_anchor_node()
1477 r = add_opcode_rel_addr(reg, OP_PUSH_LOOK_BEHIND_NOT, in compile_anchor_node()
1479 if (r) return r; in compile_anchor_node()
1481 r = get_char_length_tree(node->target, reg, &n); in compile_anchor_node()
1482 if (r) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; in compile_anchor_node()
1486 r = add_length(reg, n); in compile_anchor_node()
1487 if (r) return r; in compile_anchor_node()
1488 r = compile_tree(node->target, reg); in compile_anchor_node()
1489 if (r) return r; in compile_anchor_node()
1490 r = add_opcode(reg, OP_FAIL_LOOK_BEHIND_NOT); in compile_anchor_node()
1499 return r; in compile_anchor_node()
1505 int len, type, r; in compile_length_tree() local
1512 r = compile_length_tree(NCAR(node), reg); in compile_length_tree()
1513 if (r < 0) return r; in compile_length_tree()
1514 len += r; in compile_length_tree()
1516 r = len; in compile_length_tree()
1523 n = r = 0; in compile_length_tree()
1525 r += compile_length_tree(NCAR(node), reg); in compile_length_tree()
1528 r += (SIZE_OP_PUSH + SIZE_OP_JUMP) * (n - 1); in compile_length_tree()
1534 r = compile_length_string_raw_node(NSTR(node), reg); in compile_length_tree()
1536 r = compile_length_string_node(node, reg); in compile_length_tree()
1540 r = compile_length_cclass_node(NCCLASS(node), reg); in compile_length_tree()
1545 r = SIZE_OPCODE; in compile_length_tree()
1554 r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH + in compile_length_tree()
1560 r = ((!IS_IGNORECASE(reg->options) && br->back_static[0] <= 2) in compile_length_tree()
1564 r = SIZE_OPCODE + SIZE_LENGTH + (SIZE_MEMNUM * br->back_num); in compile_length_tree()
1571 r = SIZE_OP_CALL; in compile_length_tree()
1576 r = compile_length_quantifier_node(NQTFR(node), reg); in compile_length_tree()
1580 r = compile_length_enclose_node(NENCLOSE(node), reg); in compile_length_tree()
1584 r = compile_length_anchor_node(NANCHOR(node), reg); in compile_length_tree()
1592 return r; in compile_length_tree()
1598 int n, type, len, pos, r = 0; in compile_tree() local
1604 r = compile_tree(NCAR(node), reg); in compile_tree()
1605 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in compile_tree()
1623 r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_JUMP); in compile_tree()
1624 if (r) break; in compile_tree()
1626 r = compile_tree(NCAR(node), reg); in compile_tree()
1627 if (r) break; in compile_tree()
1630 r = add_opcode_rel_addr(reg, OP_JUMP, len); in compile_tree()
1631 if (r) break; in compile_tree()
1639 r = compile_string_raw_node(NSTR(node), reg); in compile_tree()
1641 r = compile_string_node(node, reg); in compile_tree()
1645 r = compile_cclass_node(NCCLASS(node), reg); in compile_tree()
1661 r = add_opcode(reg, op); in compile_tree()
1667 r = add_opcode(reg, OP_ANYCHAR_ML); in compile_tree()
1669 r = add_opcode(reg, OP_ANYCHAR); in compile_tree()
1678 r = add_opcode(reg, OP_BACKREF_WITH_LEVEL); in compile_tree()
1679 if (r) return r; in compile_tree()
1680 r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE)); in compile_tree()
1681 if (r) return r; in compile_tree()
1682 r = add_length(reg, br->nest_level); in compile_tree()
1683 if (r) return r; in compile_tree()
1692 r = add_opcode(reg, OP_BACKREFN_IC); in compile_tree()
1693 if (r) return r; in compile_tree()
1694 r = add_mem_num(reg, n); in compile_tree()
1698 case 1: r = add_opcode(reg, OP_BACKREF1); break; in compile_tree()
1699 case 2: r = add_opcode(reg, OP_BACKREF2); break; in compile_tree()
1701 r = add_opcode(reg, OP_BACKREFN); in compile_tree()
1702 if (r) return r; in compile_tree()
1703 r = add_mem_num(reg, n); in compile_tree()
1713 r = add_opcode(reg, OP_BACKREF_MULTI_IC); in compile_tree()
1716 r = add_opcode(reg, OP_BACKREF_MULTI); in compile_tree()
1718 if (r) return r; in compile_tree()
1723 r = add_length(reg, br->back_num); in compile_tree()
1724 if (r) return r; in compile_tree()
1727 r = add_mem_num(reg, p[i]); in compile_tree()
1728 if (r) return r; in compile_tree()
1736 r = compile_call(NCALL(node), reg); in compile_tree()
1741 r = compile_quantifier_node(NQTFR(node), reg); in compile_tree()
1745 r = compile_enclose_node(NENCLOSE(node), reg); in compile_tree()
1749 r = compile_anchor_node(NANCHOR(node), reg); in compile_tree()
1759 return r; in compile_tree()
1767 int r = 0; in noname_disable_map() local
1774 r = noname_disable_map(&(NCAR(node)), map, counter); in noname_disable_map()
1775 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in noname_disable_map()
1782 r = noname_disable_map(ptarget, map, counter); in noname_disable_map()
1797 r = noname_disable_map(&(en->target), map, counter); in noname_disable_map()
1803 r = noname_disable_map(plink, map, counter); in noname_disable_map()
1807 r = noname_disable_map(&(en->target), map, counter); in noname_disable_map()
1813 r = noname_disable_map(&(NANCHOR(node)->target), map, counter); in noname_disable_map()
1820 return r; in noname_disable_map()
1854 int r = 0; in renumber_by_map() local
1860 r = renumber_by_map(NCAR(node), map); in renumber_by_map()
1861 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in renumber_by_map()
1864 r = renumber_by_map(NQTFR(node)->target, map); in renumber_by_map()
1867 r = renumber_by_map(NENCLOSE(node)->target, map); in renumber_by_map()
1871 r = renumber_node_backref(node, map); in renumber_by_map()
1876 r = renumber_by_map(NANCHOR(node)->target, map); in renumber_by_map()
1883 return r; in renumber_by_map()
1889 int r = 0; in numbered_ref_check() local
1895 r = numbered_ref_check(NCAR(node)); in numbered_ref_check()
1896 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in numbered_ref_check()
1899 r = numbered_ref_check(NQTFR(node)->target); in numbered_ref_check()
1902 r = numbered_ref_check(NENCLOSE(node)->target); in numbered_ref_check()
1912 r = numbered_ref_check(NANCHOR(node)->target); in numbered_ref_check()
1919 return r; in numbered_ref_check()
1925 int r, i, pos, counter; in disable_noname_group_capture() local
1935 r = noname_disable_map(root, map, &counter); in disable_noname_group_capture()
1936 if (r != 0) return r; in disable_noname_group_capture()
1938 r = renumber_by_map(*root, map); in disable_noname_group_capture()
1939 if (r != 0) return r; in disable_noname_group_capture()
1987 int r = 0; in quantifiers_memory_node_info() local
1996 if (v > r) r = v; in quantifiers_memory_node_info()
2007 r = quantifiers_memory_node_info(NCALL(node)->target); in quantifiers_memory_node_info()
2015 r = quantifiers_memory_node_info(qn->target); in quantifiers_memory_node_info()
2030 r = quantifiers_memory_node_info(en->target); in quantifiers_memory_node_info()
2048 return r; in quantifiers_memory_node_info()
2061 int r = 0; in get_char_length_tree1() local
2068 r = get_char_length_tree1(NCAR(node), reg, &tlen, level); in get_char_length_tree1()
2069 if (r == 0) in get_char_length_tree1()
2071 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in get_char_length_tree1()
2079 r = get_char_length_tree1(NCAR(node), reg, &tlen, level); in get_char_length_tree1()
2080 while (r == 0 && IS_NOT_NULL(node = NCDR(node))) { in get_char_length_tree1()
2081 r = get_char_length_tree1(NCAR(node), reg, &tlen2, level); in get_char_length_tree1()
2082 if (r == 0) { in get_char_length_tree1()
2087 if (r == 0) { in get_char_length_tree1()
2090 r = GET_CHAR_LEN_TOP_ALT_VARLEN; in get_char_length_tree1()
2092 r = GET_CHAR_LEN_VARLEN; in get_char_length_tree1()
2115 r = get_char_length_tree1(qn->target, reg, &tlen, level); in get_char_length_tree1()
2116 if (r == 0) in get_char_length_tree1()
2120 r = GET_CHAR_LEN_VARLEN; in get_char_length_tree1()
2127 r = get_char_length_tree1(NCALL(node)->target, reg, len, level); in get_char_length_tree1()
2129 r = GET_CHAR_LEN_VARLEN; in get_char_length_tree1()
2151 r = get_char_length_tree1(en->target, reg, len, level); in get_char_length_tree1()
2152 if (r == 0) { in get_char_length_tree1()
2161 r = get_char_length_tree1(en->target, reg, len, level); in get_char_length_tree1()
2173 r = GET_CHAR_LEN_VARLEN; in get_char_length_tree1()
2177 return r; in get_char_length_tree1()
2453 int type, r = 0; in check_type_tree() local
2463 r = check_type_tree(NCAR(node), type_mask, enclose_mask, in check_type_tree()
2465 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in check_type_tree()
2469 r = check_type_tree(NQTFR(node)->target, type_mask, enclose_mask, in check_type_tree()
2479 r = check_type_tree(en->target, type_mask, enclose_mask, anchor_mask); in check_type_tree()
2489 r = check_type_tree(NANCHOR(node)->target, in check_type_tree()
2496 return r; in check_type_tree()
2503 int r = 0; in get_min_len() local
2517 r = get_min_len(nodes[backs[0]], min, env); in get_min_len()
2518 if (r != 0) break; in get_min_len()
2521 r = get_min_len(nodes[backs[i]], &tmin, env); in get_min_len()
2522 if (r != 0) break; in get_min_len()
2536 r = get_min_len(NCALL(node)->target, min, env); in get_min_len()
2542 r = get_min_len(NCAR(node), &tmin, env); in get_min_len()
2543 if (r == 0) *min += tmin; in get_min_len()
2544 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in get_min_len()
2553 r = get_min_len(x, &tmin, env); in get_min_len()
2554 if (r != 0) break; in get_min_len()
2557 } while (r == 0 && IS_NOT_NULL(y = NCDR(y))); in get_min_len()
2582 r = get_min_len(qn->target, min, env); in get_min_len()
2583 if (r == 0) in get_min_len()
2601 r = get_min_len(en->target, min, env); in get_min_len()
2603 if (r == 0) { in get_min_len()
2613 r = get_min_len(en->target, min, env); in get_min_len()
2624 return r; in get_min_len()
2631 int r = 0; in get_max_len() local
2637 r = get_max_len(NCAR(node), &tmax, env); in get_max_len()
2638 if (r == 0) in get_max_len()
2640 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in get_max_len()
2645 r = get_max_len(NCAR(node), &tmax, env); in get_max_len()
2646 if (r == 0 && *max < tmax) *max = tmax; in get_max_len()
2647 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in get_max_len()
2679 r = get_max_len(nodes[backs[i]], &tmax, env); in get_max_len()
2680 if (r != 0) break; in get_max_len()
2689 r = get_max_len(NCALL(node)->target, max, env); in get_max_len()
2700 r = get_max_len(qn->target, max, env); in get_max_len()
2701 if (r == 0 && *max != 0) { in get_max_len()
2723 r = get_max_len(en->target, max, env); in get_max_len()
2725 if (r == 0) { in get_max_len()
2735 r = get_max_len(en->target, max, env); in get_max_len()
2746 return r; in get_max_len()
2759 int r = 0; in subexp_inf_recursive_check() local
2773 r |= ret; in subexp_inf_recursive_check()
2786 r = RECURSION_EXIST; in subexp_inf_recursive_check()
2790 r &= ret; in subexp_inf_recursive_check()
2796 r = subexp_inf_recursive_check(NQTFR(node)->target, env, head); in subexp_inf_recursive_check()
2797 if (r == RECURSION_EXIST) { in subexp_inf_recursive_check()
2798 if (NQTFR(node)->lower == 0) r = 0; in subexp_inf_recursive_check()
2810 r = subexp_inf_recursive_check(an->target, env, head); in subexp_inf_recursive_check()
2817 r = subexp_inf_recursive_check(NCALL(node)->target, env, head); in subexp_inf_recursive_check()
2827 r = subexp_inf_recursive_check(NENCLOSE(node)->target, env, head); in subexp_inf_recursive_check()
2836 return r; in subexp_inf_recursive_check()
2843 int r = 0; in subexp_inf_recursive_check_trav() local
2850 r = subexp_inf_recursive_check_trav(NCAR(node), env); in subexp_inf_recursive_check_trav()
2851 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in subexp_inf_recursive_check_trav()
2855 r = subexp_inf_recursive_check_trav(NQTFR(node)->target, env); in subexp_inf_recursive_check_trav()
2866 r = subexp_inf_recursive_check_trav(an->target, env); in subexp_inf_recursive_check_trav()
2878 r = subexp_inf_recursive_check(en->target, env, 1); in subexp_inf_recursive_check_trav()
2879 if (r > 0) return ONIGERR_NEVER_ENDING_RECURSION; in subexp_inf_recursive_check_trav()
2882 r = subexp_inf_recursive_check_trav(en->target, env); in subexp_inf_recursive_check_trav()
2890 return r; in subexp_inf_recursive_check_trav()
2896 int r = 0; in subexp_recursive_check() local
2902 r |= subexp_recursive_check(NCAR(node)); in subexp_recursive_check()
2907 r = subexp_recursive_check(NQTFR(node)->target); in subexp_recursive_check()
2918 r = subexp_recursive_check(an->target); in subexp_recursive_check()
2925 r = subexp_recursive_check(NCALL(node)->target); in subexp_recursive_check()
2926 if (r != 0) SET_CALL_RECURSION(node); in subexp_recursive_check()
2936 r = subexp_recursive_check(NENCLOSE(node)->target); in subexp_recursive_check()
2945 return r; in subexp_recursive_check()
2955 int r = 0; in subexp_recursive_check_trav() local
2965 if (ret == FOUND_CALLED_NODE) r = FOUND_CALLED_NODE; in subexp_recursive_check_trav()
2972 r = subexp_recursive_check_trav(NQTFR(node)->target, env); in subexp_recursive_check_trav()
2974 if (r == FOUND_CALLED_NODE) in subexp_recursive_check_trav()
2987 r = subexp_recursive_check_trav(an->target, env); in subexp_recursive_check_trav()
3000 r = subexp_recursive_check(en->target); in subexp_recursive_check_trav()
3001 if (r != 0) SET_ENCLOSE_STATUS(node, NST_RECURSION); in subexp_recursive_check_trav()
3005 r = subexp_recursive_check_trav(en->target, env); in subexp_recursive_check_trav()
3007 r |= FOUND_CALLED_NODE; in subexp_recursive_check_trav()
3015 return r; in subexp_recursive_check_trav()
3022 int r = 0; in setup_subexp_call() local
3028 r = setup_subexp_call(NCAR(node), env); in setup_subexp_call()
3029 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in setup_subexp_call()
3034 r = setup_subexp_call(NCAR(node), env); in setup_subexp_call()
3035 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in setup_subexp_call()
3039 r = setup_subexp_call(NQTFR(node)->target, env); in setup_subexp_call()
3042 r = setup_subexp_call(NENCLOSE(node)->target, env); in setup_subexp_call()
3113 r = setup_subexp_call(an->target, env); in setup_subexp_call()
3123 return r; in setup_subexp_call()
3166 int r, len; in setup_look_behind() local
3171 r = get_char_length_tree(an->target, reg, &len); in setup_look_behind()
3172 if (r == 0) in setup_look_behind()
3174 else if (r == GET_CHAR_LEN_VARLEN) in setup_look_behind()
3175 r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN; in setup_look_behind()
3176 else if (r == GET_CHAR_LEN_TOP_ALT_VARLEN) { in setup_look_behind()
3178 r = divide_look_behind_alternatives(node); in setup_look_behind()
3180 r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN; in setup_look_behind()
3183 return r; in setup_look_behind()
3239 int r, i, len, sbuf_size; in update_string_node_case_fold() local
3265 r = onig_node_str_set(node, sbuf, sp); in update_string_node_case_fold()
3266 if (r != 0) { in update_string_node_case_fold()
3268 return r; in update_string_node_case_fold()
3279 int r; in expand_case_fold_make_rem_string() local
3285 r = update_string_node_case_fold(reg, node); in expand_case_fold_make_rem_string()
3286 if (r != 0) { in expand_case_fold_make_rem_string()
3288 return r; in expand_case_fold_make_rem_string()
3302 int r, i, j, len, varlen; in expand_case_fold_string_alt() local
3345 r = len; in expand_case_fold_string_alt()
3349 r = onig_node_str_cat(snode, buf, buf + len); in expand_case_fold_string_alt()
3350 if (r != 0) goto mem_err2; in expand_case_fold_string_alt()
3363 r = expand_case_fold_make_rem_string(&rem, q, end, reg); in expand_case_fold_string_alt()
3364 if (r != 0) { in expand_case_fold_string_alt()
3414 int r, n, len, alt_num; in expand_case_fold_string() local
3426 r = 0; in expand_case_fold_string()
3434 r = n; in expand_case_fold_string()
3460 r = onig_node_str_cat(snode, p, p + len); in expand_case_fold_string()
3461 if (r != 0) goto err; in expand_case_fold_string()
3475 r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node); in expand_case_fold_string()
3476 if (r < 0) goto mem_err; in expand_case_fold_string()
3477 if (r == 1) { in expand_case_fold_string()
3508 r = expand_case_fold_make_rem_string(&srem, p, end, reg); in expand_case_fold_string()
3509 if (r != 0) goto mem_err; in expand_case_fold_string()
3538 r = ONIGERR_MEMORY; in expand_case_fold_string()
3542 return r; in expand_case_fold_string()
3559 int r = state; in setup_comb_exp_check() local
3567 r = setup_comb_exp_check(NCAR(node), r, env); in setup_comb_exp_check()
3569 } while (r >= 0 && IS_NOT_NULL(node = NCDR(node))); in setup_comb_exp_check()
3578 r |= ret; in setup_comb_exp_check()
3643 r = setup_comb_exp_check(target, child_state, env); in setup_comb_exp_check()
3644 r |= add_state; in setup_comb_exp_check()
3658 r = setup_comb_exp_check(en->target, state, env); in setup_comb_exp_check()
3663 r = setup_comb_exp_check(en->target, state, env); in setup_comb_exp_check()
3674 r = setup_comb_exp_check(NCALL(node)->target, state, env); in setup_comb_exp_check()
3682 return r; in setup_comb_exp_check()
3705 int r = 0; in setup_tree() local
3713 r = setup_tree(NCAR(node), reg, state, env); in setup_tree()
3714 if (IS_NOT_NULL(prev) && r == 0) { in setup_tree()
3715 r = next_setup(prev, NCAR(node), reg); in setup_tree()
3718 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in setup_tree()
3724 r = setup_tree(NCAR(node), reg, (state | IN_ALT), env); in setup_tree()
3725 } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); in setup_tree()
3733 r = expand_case_fold_string(node, reg); in setup_tree()
3778 r = get_min_len(target, &d, env); in setup_tree()
3779 if (r) break; in setup_tree()
3783 r = quantifiers_memory_node_info(target); in setup_tree()
3784 if (r < 0) break; in setup_tree()
3785 if (r > 0) { in setup_tree()
3786 qn->target_empty_info = r; in setup_tree()
3790 r = get_max_len(target, &d, env); in setup_tree()
3791 if (r == 0 && d == 0) { in setup_tree()
3806 r = setup_tree(target, reg, state, env); in setup_tree()
3807 if (r) break; in setup_tree()
3821 r = onig_node_str_cat(node, sn->s, sn->end); in setup_tree()
3822 if (r) break; in setup_tree()
3856 r = setup_tree(NENCLOSE(node)->target, reg, state, env); in setup_tree()
3872 r = setup_tree(en->target, reg, state, env); in setup_tree()
3878 r = setup_tree(target, reg, state, env); in setup_tree()
3900 r = setup_tree(an->target, reg, state, env); in setup_tree()
3903 r = setup_tree(an->target, reg, (state | IN_NOT), env); in setup_tree()
3922 r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB, in setup_tree()
3924 if (r < 0) return r; in setup_tree()
3925 if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; in setup_tree()
3926 r = setup_tree(an->target, reg, state, env); in setup_tree()
3927 if (r != 0) return r; in setup_tree()
3928 r = setup_look_behind(node, reg, env); in setup_tree()
3934 r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB, in setup_tree()
3936 if (r < 0) return r; in setup_tree()
3937 if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; in setup_tree()
3938 r = setup_tree(an->target, reg, (state | IN_NOT), env); in setup_tree()
3939 if (r != 0) return r; in setup_tree()
3940 r = setup_look_behind(node, reg, env); in setup_tree()
3951 return r; in setup_tree()
4598 int r = 0; in optimize_node_left() local
4613 r = optimize_node_left(NCAR(nd), &nopt, &nenv); in optimize_node_left()
4614 if (r == 0) { in optimize_node_left()
4618 } while (r == 0 && IS_NOT_NULL(nd = NCDR(nd))); in optimize_node_left()
4628 r = optimize_node_left(NCAR(nd), &nopt, env); in optimize_node_left()
4629 if (r == 0) { in optimize_node_left()
4633 } while ((r == 0) && IS_NOT_NULL(nd = NCDR(nd))); in optimize_node_left()
4664 r = add_char_amb_opt_map_info(&opt->map, sn->s, sn->end, in optimize_node_left()
4666 if (r != 0) break; in optimize_node_left()
4765 r = optimize_node_left(NANCHOR(node)->target, &nopt, env); in optimize_node_left()
4766 if (r == 0) { in optimize_node_left()
4798 r = get_min_len(nodes[backs[0]], &min, env->scan_env); in optimize_node_left()
4799 if (r != 0) break; in optimize_node_left()
4800 r = get_max_len(nodes[backs[0]], &max, env->scan_env); in optimize_node_left()
4801 if (r != 0) break; in optimize_node_left()
4803 r = get_min_len(nodes[backs[i]], &tmin, env->scan_env); in optimize_node_left()
4804 if (r != 0) break; in optimize_node_left()
4805 r = get_max_len(nodes[backs[i]], &tmax, env->scan_env); in optimize_node_left()
4806 if (r != 0) break; in optimize_node_left()
4810 if (r == 0) set_mml(&opt->len, min, max); in optimize_node_left()
4821 r = optimize_node_left(NCALL(node)->target, opt, env); in optimize_node_left()
4834 r = optimize_node_left(qn->target, &nopt, env); in optimize_node_left()
4835 if (r) break; in optimize_node_left()
4890 r = optimize_node_left(en->target, opt, env); in optimize_node_left()
4910 r = optimize_node_left(en->target, opt, env); in optimize_node_left()
4920 r = optimize_node_left(en->target, opt, env); in optimize_node_left()
4931 r = ONIGERR_TYPE_BUG; in optimize_node_left()
4935 return r; in optimize_node_left()
4941 int r; in set_optimize_exact_info() local
4963 r = set_bm_skip(reg->exact, reg->exact_end, reg->enc, in set_optimize_exact_info()
4965 if (r) return r; in set_optimize_exact_info()
5017 int r; in set_optimize_info_from_tree() local
5027 r = optimize_node_left(node, &opt, &env); in set_optimize_info_from_tree()
5028 if (r) return r; in set_optimize_info_from_tree()
5052 r = set_optimize_exact_info(reg, &opt.exb); in set_optimize_info_from_tree()
5070 return r; in set_optimize_info_from_tree()
5294 int r, init_size; in onig_compile() local
5311 r = BBUF_INIT(reg, init_size); in onig_compile()
5312 if (r != 0) goto end; in onig_compile()
5326 r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env); in onig_compile()
5327 if (r != 0) goto err; in onig_compile()
5335 r = disable_noname_group_capture(&root, reg, &scan_env); in onig_compile()
5337 r = numbered_ref_check(root); in onig_compile()
5339 if (r != 0) goto err; in onig_compile()
5345 r = unset_addr_list_init(&uslist, scan_env.num_call); in onig_compile()
5346 if (r != 0) goto err; in onig_compile()
5348 r = setup_subexp_call(root, &scan_env); in onig_compile()
5349 if (r != 0) goto err_unset; in onig_compile()
5350 r = subexp_recursive_check_trav(root, &scan_env); in onig_compile()
5351 if (r < 0) goto err_unset; in onig_compile()
5352 r = subexp_inf_recursive_check_trav(root, &scan_env); in onig_compile()
5353 if (r != 0) goto err_unset; in onig_compile()
5361 r = setup_tree(root, reg, 0, &scan_env); in onig_compile()
5362 if (r != 0) goto err_unset; in onig_compile()
5407 r = set_optimize_info_from_tree(root, reg, &scan_env); in onig_compile()
5408 if (r != 0) goto err_unset; in onig_compile()
5416 r = compile_tree(root, reg); in onig_compile()
5417 if (r == 0) { in onig_compile()
5418 r = add_opcode(reg, OP_END); in onig_compile()
5421 r = unset_addr_list_fix(&uslist, reg); in onig_compile()
5423 if (r) goto err; in onig_compile()
5451 return r; in onig_compile()
5471 return r; in onig_compile()
5482 int r; in onig_reg_init() local
5490 r = onig_initialize(NULL, 0); in onig_reg_init()
5491 if (r != 0) in onig_reg_init()
5494 r = onig_initialize_encoding(enc); in onig_reg_init()
5495 if (r != 0) in onig_reg_init()
5543 int r; in onig_new_without_alloc() local
5545 r = onig_reg_init(reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax); in onig_new_without_alloc()
5546 if (r) return r; in onig_new_without_alloc()
5548 r = onig_compile(reg, pattern, pattern_end, einfo); in onig_new_without_alloc()
5549 return r; in onig_new_without_alloc()
5557 int r; in onig_new() local
5562 r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax); in onig_new()
5563 if (r) goto err; in onig_new()
5565 r = onig_compile(*reg, pattern, pattern_end, einfo); in onig_new()
5566 if (r) { in onig_new()
5571 return r; in onig_new()
5578 int r; in onig_initialize() local
5589 r = onig_initialize_encoding(enc); in onig_initialize()
5590 if (r != 0) in onig_initialize()
5591 return r; in onig_initialize()