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

Function calc_eclosure_iter

compat/regex/regcomp.c:1690–1764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1688 incomplete = 1;
1689 re_node_set_free (&eclosure_elem);
1690 }
1691 }
1692 return REG_NOERROR;
1693}
1694
1695/* Calculate epsilon closure of NODE. */
1696
1697static reg_errcode_t
1698calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root)
1699{
1700 reg_errcode_t err;
1701 int i;
1702 re_node_set eclosure;
1703 int ret;
1704 int incomplete = 0;
1705 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
1706 if (BE (err != REG_NOERROR, 0))
1707 return err;
1708
1709 /* This indicates that we are calculating this node now.
1710 We reference this value to avoid infinite loop. */
1711 dfa->eclosures[node].nelem = -1;
1712
1713 /* If the current node has constraints, duplicate all nodes
1714 since they must inherit the constraints. */
1715 if (dfa->nodes[node].constraint
1716 && dfa->edests[node].nelem
1717 && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
1718 {
1719 err = duplicate_node_closure (dfa, node, node, node,
1720 dfa->nodes[node].constraint);
1721 if (BE (err != REG_NOERROR, 0))
1722 return err;
1723 }
1724
1725 /* Expand each epsilon destination nodes. */
1726 if (IS_EPSILON_NODE(dfa->nodes[node].type))
1727 for (i = 0; i < dfa->edests[node].nelem; ++i)
1728 {
1729 re_node_set eclosure_elem;
1730 int edest = dfa->edests[node].elems[i];
1731 /* If calculating the epsilon closure of `edest' is in progress,
1732 return intermediate result. */
1733 if (dfa->eclosures[edest].nelem == -1)
1734 {
1735 incomplete = 1;
1736 continue;
1737 }
1738 /* If we haven't calculated the epsilon closure of `edest' yet,
1739 calculate now. Otherwise use calculated epsilon closure. */
1740 if (dfa->eclosures[edest].nelem == 0)
1741 {
1742 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, 0);
1743 if (BE (err != REG_NOERROR, 0))
1744 return err;
1745 }
1746 else
1747 eclosure_elem = dfa->eclosures[edest];

Callers 1

calc_eclosureFunction · 0.85

Calls 4

re_node_set_allocFunction · 0.85
duplicate_node_closureFunction · 0.85
re_node_set_mergeFunction · 0.85
re_node_set_insertFunction · 0.85

Tested by

no test coverage detected