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

Function re_acquire_state_context

compat/regex/regex_internal.c:1534–1565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1532 Note: - We assume NULL as the invalid state, then it is possible that
1533 return value is NULL and ERR is REG_NOERROR.
1534 - We never return non-NULL value in case of any errors, it is for
1535 optimization. */
1536
1537static re_dfastate_t *
1538internal_function
1539re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1540 const re_node_set *nodes, unsigned int context)
1541{
1542 unsigned int hash;
1543 re_dfastate_t *new_state;
1544 struct re_state_table_entry *spot;
1545 int i;
1546 if (nodes->nelem == 0)
1547 {
1548 *err = REG_NOERROR;
1549 return NULL;
1550 }
1551 hash = calc_state_hash (nodes, context);
1552 spot = dfa->state_table + (hash & dfa->state_hash_mask);
1553
1554 for (i = 0 ; i < spot->num ; i++)
1555 {
1556 re_dfastate_t *state = spot->array[i];
1557 if (state->hash == hash
1558 && state->context == context
1559 && re_node_set_compare (state->entrance_nodes, nodes))
1560 return state;
1561 }
1562 /* There are no appropriate state in `dfa', create the new one. */
1563 new_state = create_cd_newstate (dfa, nodes, context, hash);
1564 if (BE (new_state == NULL, 0))
1565 *err = REG_ESPACE;
1566
1567 return new_state;
1568}

Callers 6

__attributeFunction · 0.85
merge_state_with_logFunction · 0.85
transit_state_sbFunction · 0.85
internal_functionFunction · 0.85
transit_state_bkrefFunction · 0.85
create_initial_stateFunction · 0.85

Calls 1

create_cd_newstateFunction · 0.85

Tested by

no test coverage detected