| 1644 | return REG_ESPACE; |
| 1645 | } |
| 1646 | } |
| 1647 | |
| 1648 | return REG_NOERROR; |
| 1649 | } |
| 1650 | |
| 1651 | /* Calculate "eclosure" for all the node in DFA. */ |
| 1652 | |
| 1653 | static reg_errcode_t |
| 1654 | calc_eclosure (re_dfa_t *dfa) |
| 1655 | { |
| 1656 | int node_idx, incomplete; |
| 1657 | #ifdef DEBUG |
| 1658 | assert (dfa->nodes_len > 0); |
| 1659 | #endif |
| 1660 | incomplete = 0; |
| 1661 | /* For each nodes, calculate epsilon closure. */ |
| 1662 | for (node_idx = 0; ; ++node_idx) |
| 1663 | { |
| 1664 | reg_errcode_t err; |
| 1665 | re_node_set eclosure_elem; |
| 1666 | if (node_idx == dfa->nodes_len) |
| 1667 | { |
| 1668 | if (!incomplete) |
| 1669 | break; |
| 1670 | incomplete = 0; |
| 1671 | node_idx = 0; |
| 1672 | } |
| 1673 | |
| 1674 | #ifdef DEBUG |
| 1675 | assert (dfa->eclosures[node_idx].nelem != -1); |
| 1676 | #endif |
| 1677 | |
| 1678 | /* If we have already calculated, skip it. */ |
| 1679 | if (dfa->eclosures[node_idx].nelem != 0) |
| 1680 | continue; |
| 1681 | /* Calculate epsilon closure of `node_idx'. */ |
| 1682 | err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, 1); |
| 1683 | if (BE (err != REG_NOERROR, 0)) |
| 1684 | return err; |
| 1685 | |
| 1686 | if (dfa->eclosures[node_idx].nelem == 0) |
| 1687 | { |
| 1688 | incomplete = 1; |
| 1689 | re_node_set_free (&eclosure_elem); |
no test coverage detected