Lines Matching defs:mctx
25 static void match_ctx_clean (re_match_context_t *mctx) internal_function;
30 static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
32 static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
60 static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
62 static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
64 static Idx check_halt_state_context (const re_match_context_t *mctx,
76 const re_match_context_t *mctx,
83 static int sift_states_iter_mb (const re_match_context_t *mctx,
88 static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
91 static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
95 static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
104 static bool check_dst_limits (const re_match_context_t *mctx,
108 static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
112 static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
122 static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
131 re_match_context_t *mctx) internal_function;
133 re_match_context_t *mctx,
136 re_match_context_t *mctx,
139 static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
144 re_match_context_t *mctx,
149 static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
153 static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
156 static reg_errcode_t get_subexp (re_match_context_t *mctx,
159 static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
166 static reg_errcode_t check_arrival (re_match_context_t *mctx,
170 static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
183 static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
203 static bool check_node_accept (const re_match_context_t *mctx,
206 static reg_errcode_t extend_buffers (re_match_context_t *mctx)
664 re_match_context_t mctx = { .dfa = dfa };
666 re_match_context_t mctx;
674 memset (&mctx, '\0', sizeof (re_match_context_t));
675 mctx.dfa = dfa;
708 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
713 mctx.input.stop = stop;
714 mctx.input.raw_stop = stop;
715 mctx.input.newline_anchor = preg->newline_anchor;
717 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
728 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= mctx.input.bufs_len, 0))
734 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
735 if (BE (mctx.state_log == NULL, 0))
742 mctx.state_log = NULL;
745 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
823 __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
824 if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0))
826 err = re_string_reconstruct (&mctx.input, match_first,
831 offset = match_first - mctx.input.raw_mbs_idx;
836 ? 0 : re_string_byte_at (&mctx.input, offset));
851 err = re_string_reconstruct (&mctx.input, match_first, eflags);
858 if (!sb && !re_string_first_byte (&mctx.input, 0))
864 mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
865 match_last = check_matching (&mctx, fl_longest_match,
876 mctx.match_last = match_last;
879 re_dfastate_t *pstate = mctx.state_log[match_last];
880 mctx.last_node = check_halt_state_context (&mctx, pstate,
886 err = prune_impossible_nodes (&mctx);
898 match_ctx_clean (&mctx);
917 pmatch[0].rm_eo = mctx.match_last;
918 /* FIXME: This function should fail if mctx.match_last exceeds
924 err = set_regs (preg, &mctx, nmatch, pmatch,
937 if (BE (mctx.input.offsets_needed != 0, 0))
940 (pmatch[reg_idx].rm_so == mctx.input.valid_len
941 ? mctx.input.valid_raw_len
942 : mctx.input.offsets[pmatch[reg_idx].rm_so]);
944 (pmatch[reg_idx].rm_eo == mctx.input.valid_len
945 ? mctx.input.valid_raw_len
946 : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
949 assert (mctx.input.offsets_needed == 0);
972 re_free (mctx.state_log);
974 match_ctx_free (&mctx);
975 re_string_destruct (&mctx.input);
981 prune_impossible_nodes (re_match_context_t *mctx)
983 const re_dfa_t *const dfa = mctx->dfa;
990 assert (mctx->state_log != NULL);
992 match_last = mctx->match_last;
993 halt_node = mctx->last_node;
1019 ret = sift_states_backward (mctx, &sctx);
1033 } while (mctx->state_log[match_last] == NULL
1034 || !mctx->state_log[match_last]->halt);
1035 halt_node = check_halt_state_context (mctx,
1036 mctx->state_log[match_last],
1049 ret = sift_states_backward (mctx, &sctx);
1059 re_free (mctx->state_log);
1060 mctx->state_log = sifted_states;
1062 mctx->last_node = halt_node;
1063 mctx->match_last = match_last;
1077 acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1080 const re_dfa_t *const dfa = mctx->dfa;
1084 context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
1119 check_matching (re_match_context_t *mctx, bool fl_longest_match,
1122 const re_dfa_t *const dfa = mctx->dfa;
1126 Idx cur_str_idx = re_string_cur_idx (&mctx->input);
1132 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
1140 if (mctx->state_log != NULL)
1142 mctx->state_log[cur_str_idx] = cur_state;
1149 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
1155 err = transit_state_bkref (mctx, &cur_state->nodes);
1166 || check_halt_state_context (mctx, cur_state, cur_str_idx))
1178 while (!re_string_eoi (&mctx->input))
1181 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
1183 if (BE (next_char_idx >= mctx->input.bufs_len, 0)
1184 || (BE (next_char_idx >= mctx->input.valid_len, 0)
1185 && mctx->input.valid_len < mctx->input.len))
1187 err = extend_buffers (mctx);
1195 cur_state = transit_state (&err, mctx, cur_state);
1196 if (mctx->state_log != NULL)
1197 cur_state = merge_state_with_log (&err, mctx, cur_state);
1207 if (mctx->state_log == NULL
1209 || (cur_state = find_recover_state (&err, mctx)) == NULL)
1226 || check_halt_state_context (mctx, cur_state,
1227 re_string_cur_idx (&mctx->input)))
1230 match_last = re_string_cur_idx (&mctx->input);
1270 check_halt_state_context (const re_match_context_t *mctx,
1278 context = re_string_context_at (&mctx->input, idx, mctx->eflags);
1280 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
1292 proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1296 const re_dfa_t *const dfa = mctx->dfa;
1301 re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
1343 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
1356 char *buf = (char *) re_string_get_buffer (&mctx->input);
1370 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
1377 || check_node_accept (mctx, dfa->nodes + node, *pidx))
1381 if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
1382 || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
1441 set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1454 assert (mctx->state_log != NULL);
1487 if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
1515 cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
1637 sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1645 assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1653 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1662 if (null_cnt > mctx->max_mb_elem_len)
1672 if (mctx->state_log[str_idx])
1674 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
1683 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1695 build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1698 const re_dfa_t *const dfa = mctx->dfa;
1699 const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
1722 naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
1729 && check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
1740 if (check_dst_limits (mctx, &sctx->limits,
1757 clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1759 Idx top = mctx->state_log_top;
1761 if (next_state_log_idx >= mctx->input.bufs_len
1762 || (next_state_log_idx >= mctx->input.valid_len
1763 && mctx->input.valid_len < mctx->input.len))
1766 err = extend_buffers (mctx);
1773 memset (mctx->state_log + top + 1, '\0',
1775 mctx->state_log_top = next_state_log_idx;
1809 update_cur_sifted_state (const re_match_context_t *mctx,
1813 const re_dfa_t *const dfa = mctx->dfa;
1816 candidates = ((mctx->state_log[str_idx] == NULL) ? NULL
1817 : &mctx->state_log[str_idx]->nodes);
1835 mctx->bkref_ents, str_idx);
1846 if (candidates && mctx->state_log[str_idx]->has_backref)
1848 err = sift_states_bkref (mctx, sctx, str_idx, candidates);
1931 check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
1934 const re_dfa_t *const dfa = mctx->dfa;
1937 Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx);
1938 Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx);
1943 ent = mctx->bkref_ents + limits->elems[lim_idx];
1946 dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
1949 src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
1967 check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
1970 const re_dfa_t *const dfa = mctx->dfa;
1984 struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
2014 check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
2049 check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
2053 struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
2070 return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
2167 sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2170 const re_dfa_t *const dfa = mctx->dfa;
2174 Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
2194 entry = mctx->bkref_ents + first_idx;
2214 || check_dst_limits (mctx, &sctx->limits, node,
2234 err = sift_states_backward (mctx, &local_sctx);
2248 /* mctx->bkref_ents may have changed, reload the pointer. */
2249 entry = mctx->bkref_ents + enabled_idx;
2267 sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2270 const re_dfa_t *const dfa = mctx->dfa;
2273 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
2298 transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2308 *err = transit_state_mb (mctx, state);
2318 return transit_state_sb (err, mctx, state);
2322 ch = re_string_fetch_byte (&mctx->input);
2334 = re_string_context_at (&mctx->input,
2335 re_string_cur_idx (&mctx->input) - 1,
2336 mctx->eflags);
2343 if (!build_trtable (mctx->dfa, state))
2356 merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2359 const re_dfa_t *const dfa = mctx->dfa;
2360 Idx cur_idx = re_string_cur_idx (&mctx->input);
2362 if (cur_idx > mctx->state_log_top)
2364 mctx->state_log[cur_idx] = next_state;
2365 mctx->state_log_top = cur_idx;
2367 else if (mctx->state_log[cur_idx] == 0)
2369 mctx->state_log[cur_idx] = next_state;
2380 pstate = mctx->state_log[cur_idx];
2395 context = re_string_context_at (&mctx->input,
2396 re_string_cur_idx (&mctx->input) - 1,
2397 mctx->eflags);
2398 next_state = mctx->state_log[cur_idx]
2412 *err = check_subexp_matching_top (mctx, &next_state->nodes,
2420 *err = transit_state_bkref (mctx, &next_state->nodes);
2423 next_state = mctx->state_log[cur_idx];
2435 find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
2440 Idx max = mctx->state_log_top;
2441 Idx cur_str_idx = re_string_cur_idx (&mctx->input);
2447 re_string_skip_bytes (&mctx->input, 1);
2449 while (mctx->state_log[cur_str_idx] == NULL);
2451 cur_state = merge_state_with_log (err, mctx, NULL);
2466 check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2469 const re_dfa_t *const dfa = mctx->dfa;
2486 err = match_ctx_add_subtop (mctx, node, str_idx);
2499 transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2502 const re_dfa_t *const dfa = mctx->dfa;
2505 Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
2514 if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx))
2525 context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
2531 re_string_skip_bytes (&mctx->input, 1);
2539 transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2541 const re_dfa_t *const dfa = mctx->dfa;
2559 context = re_string_context_at (&mctx->input,
2560 re_string_cur_idx (&mctx->input),
2561 mctx->eflags);
2568 naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input,
2569 re_string_cur_idx (&mctx->input));
2574 dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
2575 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
2576 : mctx->max_mb_elem_len);
2577 err = clean_state_log_if_needed (mctx, dest_idx);
2585 dest_state = mctx->state_log[dest_idx];
2595 context = re_string_context_at (&mctx->input, dest_idx - 1,
2596 mctx->eflags);
2597 mctx->state_log[dest_idx]
2601 if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0))
2610 transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2612 const re_dfa_t *const dfa = mctx->dfa;
2615 Idx cur_str_idx = re_string_cur_idx (&mctx->input);
2631 context = re_string_context_at (&mctx->input, cur_str_idx,
2632 mctx->eflags);
2639 bkc_idx = mctx->nbkref_ents;
2640 err = get_subexp (mctx, node_idx, cur_str_idx);
2649 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
2654 bkref_ent = mctx->bkref_ents + bkc_idx;
2663 context = re_string_context_at (&mctx->input, dest_str_idx - 1,
2664 mctx->eflags);
2665 dest_state = mctx->state_log[dest_str_idx];
2666 prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
2667 : mctx->state_log[cur_str_idx]->nodes.nelem);
2671 mctx->state_log[dest_str_idx]
2674 if (BE (mctx->state_log[dest_str_idx] == NULL
2689 mctx->state_log[dest_str_idx]
2692 if (BE (mctx->state_log[dest_str_idx] == NULL
2699 && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
2701 err = check_subexp_matching_top (mctx, new_dest_nodes,
2705 err = transit_state_bkref (mctx, new_dest_nodes);
2724 get_subexp (re_match_context_t *mctx
2726 const re_dfa_t *const dfa = mctx->dfa;
2728 const char *buf = (const char *) re_string_get_buffer (&mctx->input);
2730 Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
2734 = mctx->bkref_ents + cache_idx;
2744 for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
2747 re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
2767 if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0))
2770 if (bkref_str_off + sl_str_diff > mctx->input.len)
2773 err = clean_state_log_if_needed (mctx,
2778 buf = (const char *) re_string_get_buffer (&mctx->input);
2786 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
2791 buf = (const char *) re_string_get_buffer (&mctx->input);
2814 if (BE (bkref_str_off >= mctx->input.valid_len, 0))
2817 if (bkref_str_off >= mctx->input.len)
2820 err = extend_buffers (mctx);
2824 buf = (const char *) re_string_get_buffer (&mctx->input);
2830 if (mctx->state_log[sl_str] == NULL)
2833 nodes = &mctx->state_log[sl_str]->nodes;
2847 err = check_arrival (mctx, sub_top->path, sub_top->node,
2857 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
2874 get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2880 err = check_arrival (mctx, &sub_last->path, sub_last->node,
2885 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
2890 return clean_state_log_if_needed (mctx, to_idx);
2925 check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2928 const re_dfa_t *const dfa = mctx->dfa;
2938 if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0))
2942 Idx new_alloc = old_alloc + last_str + mctx->max_mb_elem_len + 1;
2957 /* Temporary modify MCTX. */
2958 backup_state_log = mctx->state_log;
2959 backup_cur_idx = mctx->input.cur_idx;
2960 mctx->state_log = path->array;
2961 mctx->input.cur_idx = str_idx;
2964 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
2979 cur_state = mctx->state_log[str_idx];
2993 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
3007 mctx->state_log[str_idx] = cur_state;
3010 for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
3013 if (mctx->state_log[str_idx + 1])
3016 &mctx->state_log[str_idx + 1]->nodes);
3025 err = check_arrival_add_next_nodes (mctx, str_idx,
3043 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
3051 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
3058 mctx->state_log[str_idx] = cur_state;
3062 cur_nodes = (mctx->state_log[last_str] == NULL ? NULL
3063 : &mctx->state_log[last_str]->nodes);
3066 /* Fix MCTX. */
3067 mctx->state_log = backup_state_log;
3068 mctx->input.cur_idx = backup_cur_idx;
3087 check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3090 const re_dfa_t *const dfa = mctx->dfa;
3110 naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
3117 dest_state = mctx->state_log[next_idx];
3134 mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
3136 if (BE (mctx->state_log[next_idx] == NULL
3146 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
3262 in MCTX->BKREF_ENTS. */
3266 expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3269 const re_dfa_t *const dfa = mctx->dfa;
3271 mctx, cur_str);
3278 ent = mctx->bkref_ents + cache_idx_start;
3289 to MCTX->STATE_LOG. */
3317 if (mctx->state_log[to_idx])
3320 if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
3324 &mctx->state_log[to_idx]->nodes);
3339 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
3341 if (BE (mctx->state_log[to_idx] == NULL
4083 check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4087 ch = re_string_byte_at (&mctx->input, idx);
4107 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
4108 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
4120 unsigned int context = re_string_context_at (&mctx->input, idx,
4121 mctx->eflags);
4133 extend_buffers (re_match_context_t *mctx)
4136 re_string_t *pstr = &mctx->input;
4147 if (mctx->state_log != NULL)
4153 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
4157 mctx->state_log = new_array;
4193 /* Initialize MCTX. */
4197 match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4199 mctx->eflags = eflags;
4200 mctx->match_last = REG_MISSING;
4210 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
4211 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
4212 if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0))
4217 mctx->bkref_ents = NULL;
4218 mctx->nbkref_ents = 0;
4219 mctx->nsub_tops = 0; */
4220 mctx->abkref_ents = n;
4221 mctx->max_mb_elem_len = 1;
4222 mctx->asub_tops = n;
4226 /* Clean the entries which depend on the current input in MCTX.
4232 match_ctx_clean (re_match_context_t *mctx)
4235 for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
4238 re_sub_match_top_t *top = mctx->sub_tops[st_idx];
4254 mctx->nsub_tops = 0;
4255 mctx->nbkref_ents = 0;
4258 /* Free all the memory associated with MCTX. */
4262 match_ctx_free (re_match_context_t *mctx)
4264 /* First, free all the memory associated with MCTX->SUB_TOPS. */
4265 match_ctx_clean (mctx);
4266 re_free (mctx->sub_tops);
4267 re_free (mctx->bkref_ents);
4270 /* Add a new backreference entry to MCTX.
4277 match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4280 if (mctx->nbkref_ents >= mctx->abkref_ents)
4283 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
4284 mctx->abkref_ents * 2);
4287 re_free (mctx->bkref_ents);
4290 mctx->bkref_ents = new_entry;
4291 memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
4292 sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
4293 mctx->abkref_ents *= 2;
4295 if (mctx->nbkref_ents > 0
4296 && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx)
4297 mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1;
4299 mctx->bkref_ents[mctx->nbkref_ents].node = node;
4300 mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
4301 mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
4302 mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
4312 mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map
4315 mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
4316 if (mctx->max_mb_elem_len < to - from)
4317 mctx->max_mb_elem_len = to - from;
4322 found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
4326 search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
4329 last = right = mctx->nbkref_ents;
4333 if (mctx->bkref_ents[mid].str_idx < str_idx)
4338 if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
4349 match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4352 assert (mctx->sub_tops != NULL);
4353 assert (mctx->asub_tops > 0);
4355 if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
4357 Idx new_asub_tops = mctx->asub_tops * 2;
4358 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
4363 mctx->sub_tops = new_array;
4364 mctx->asub_tops = new_asub_tops;
4366 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
4367 if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0))
4369 mctx->sub_tops[mctx->nsub_tops]->node = node;
4370 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;