MCPcopy Create free account
hub / github.com/git/git / transit_state_bkref

Function transit_state_bkref

compat/regex/regexec.c:2568–2674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2566 return err;
2567 }
2568 return REG_NOERROR;
2569}
2570#endif /* RE_ENABLE_I18N */
2571
2572static reg_errcode_t
2573internal_function
2574transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2575{
2576 const re_dfa_t *const dfa = mctx->dfa;
2577 reg_errcode_t err;
2578 int i;
2579 int cur_str_idx = re_string_cur_idx (&mctx->input);
2580
2581 for (i = 0; i < nodes->nelem; ++i)
2582 {
2583 int dest_str_idx, prev_nelem, bkc_idx;
2584 int node_idx = nodes->elems[i];
2585 unsigned int context;
2586 const re_token_t *node = dfa->nodes + node_idx;
2587 re_node_set *new_dest_nodes;
2588
2589 /* Check whether `node' is a backreference or not. */
2590 if (node->type != OP_BACK_REF)
2591 continue;
2592
2593 if (node->constraint)
2594 {
2595 context = re_string_context_at (&mctx->input, cur_str_idx,
2596 mctx->eflags);
2597 if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
2598 continue;
2599 }
2600
2601 /* `node' is a backreference.
2602 Check the substring which the substring matched. */
2603 bkc_idx = mctx->nbkref_ents;
2604 err = get_subexp (mctx, node_idx, cur_str_idx);
2605 if (BE (err != REG_NOERROR, 0))
2606 goto free_return;
2607
2608 /* And add the epsilon closures (which is `new_dest_nodes') of
2609 the backreference to appropriate state_log. */
2610#ifdef DEBUG
2611 assert (dfa->nexts[node_idx] != -1);
2612#endif
2613 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
2614 {
2615 int subexp_len;
2616 re_dfastate_t *dest_state;
2617 struct re_backref_cache_entry *bkref_ent;
2618 bkref_ent = mctx->bkref_ents + bkc_idx;
2619 if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
2620 continue;
2621 subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
2622 new_dest_nodes = (subexp_len == 0
2623 ? dfa->eclosures + dfa->edests[node_idx].elems[0]
2624 : dfa->eclosures + dfa->nexts[node_idx]);
2625 dest_str_idx = (cur_str_idx + bkref_ent->subexp_to

Callers 2

internal_functionFunction · 0.85
merge_state_with_logFunction · 0.85

Calls 4

re_string_context_atFunction · 0.85
re_acquire_state_contextFunction · 0.85
re_node_set_init_unionFunction · 0.85

Tested by

no test coverage detected