| 1623 | } |
| 1624 | |
| 1625 | /* Create the new state which is independent of contexts. |
| 1626 | Return the new state if succeeded, otherwise return NULL. */ |
| 1627 | |
| 1628 | static re_dfastate_t * |
| 1629 | internal_function |
| 1630 | create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, |
| 1631 | unsigned int hash) |
| 1632 | { |
| 1633 | int i; |
| 1634 | reg_errcode_t err; |
| 1635 | re_dfastate_t *newstate; |
| 1636 | |
| 1637 | newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t)); |
| 1638 | if (BE (newstate == NULL, 0)) |
| 1639 | return NULL; |
| 1640 | err = re_node_set_init_copy (&newstate->nodes, nodes); |
| 1641 | if (BE (err != REG_NOERROR, 0)) |
| 1642 | { |
| 1643 | re_free (newstate); |
| 1644 | return NULL; |
| 1645 | } |
| 1646 | |
| 1647 | newstate->entrance_nodes = &newstate->nodes; |
| 1648 | for (i = 0 ; i < nodes->nelem ; i++) |
| 1649 | { |
| 1650 | re_token_t *node = dfa->nodes + nodes->elems[i]; |
| 1651 | re_token_type_t type = node->type; |
| 1652 | if (type == CHARACTER && !node->constraint) |
| 1653 | continue; |
| 1654 | #ifdef RE_ENABLE_I18N |
| 1655 | newstate->accept_mb |= node->accept_mb; |
| 1656 | #endif /* RE_ENABLE_I18N */ |
| 1657 | |
| 1658 | /* If the state has the halt node, the state is a halt state. */ |
| 1659 | if (type == END_OF_RE) |
| 1660 | newstate->halt = 1; |
| 1661 | else if (type == OP_BACK_REF) |
| 1662 | newstate->has_backref = 1; |
| 1663 | else if (type == ANCHOR || node->constraint) |
| 1664 | newstate->has_constraint = 1; |
| 1665 | } |
| 1666 | err = register_state (dfa, newstate, hash); |
| 1667 | if (BE (err != REG_NOERROR, 0)) |
| 1668 | { |
| 1669 | free_state (newstate); |
| 1670 | newstate = NULL; |
| 1671 | } |
| 1672 | return newstate; |
| 1673 | } |
no test coverage detected