summaryrefslogtreecommitdiff
path: root/posix/regex_internal.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-10-12 08:34:26 +0000
committerUlrich Drepper <drepper@redhat.com>2002-10-12 08:34:26 +0000
commit485d775dd578f2c2528d10d7618f09c45ffe6840 (patch)
treedde239879b15fbec3536cede5e8019211495f84b /posix/regex_internal.c
parentcc12f2a442d1d971d6ec0c21bdfa578299601fc7 (diff)
downloadglibc-485d775dd578f2c2528d10d7618f09c45ffe6840.tar.gz
Update.
2002-10-11 Isamu Hasegawa <isamu@yamato.ibm.com> * posix/regcomp.c (re_compile_fastmap_iter): Remove the handling OP_CONTEXT_NODE. (regfree): Likewise. (create_initial_state): Likewise. (analyze): Remove the substitutions which became useless. (calc_first): Likewise. (calc_epsdest): Use edests of OP_BACK_REF in case that it has epsilon destination. (duplicate_node_closure): New function. (duplicate_node): Remove the handling OP_CONTEXT_NODE. (calc_inveclosure): Likewise. (calc_eclosure): Likewise. (calc_eclosure_iter): Invoke duplicate_node_closure instead of direct invocation of duplicate_node. (parse): Don't use comma operator in the return to avoid compiler warning. (parse_reg_exp): Likewise. (parse_branch): Likewise. (parse_expression): Likewise. (parse_sub_exp): Likewise. (parse_dup_op): Likewise. * posix/regex_internal.c (re_dfa_add_node): Remove the substitutions which became useless. (create_ci_newstate): Remove the handling OP_CONTEXT_NODE. (create_cd_newstate): Likewise. * posix/regex_internal.h (re_token_type_t): Remove the obsolete type. (re_token_t): Likewise. (re_dfa_t): Likewise. (re_node_set_remove): New macro. * posix/regexec.c (check_matching): Remove the handling OP_CONTEXT_NODE. (check_halt_node_context): Likewise. (proceed_next_node): Likewise. (pop_fail_stack): Fix the memory leak. (set_regs): Likewise. (free_fail_stack_return): New function. (sift_states_backward): Fix the memory leak. Remove the handling OP_CONTEXT_NODE. (update_cur_sifted_state): Append some if clause to avoid redundant call. (sub_epsilon_src_nodes): Use IS_EPSILON_NODE since it might be a back reference. (check_dst_limits): Remove the handling OP_CONTEXT_NODE. (check_subexp_limits): Likewise. (search_subexp): Likewise. (sift_states_bkref): Likewise. (transit_state_mb): Likewise. (transit_state_bkref_loop): Likewise. (transit_state_bkref_loop): Likewise. (group_nodes_into_DFAstates): Likewise. (check_node_accept): Likewise. (sift_ctx_init): Add initializing. 2002-10-12 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/i386/sysdep.h (INLINE_SYSCALL): Use __builtin_expect.
Diffstat (limited to 'posix/regex_internal.c')
-rw-r--r--posix/regex_internal.c38
1 files changed, 10 insertions, 28 deletions
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index 92f59b4c9d..69fb9a65f5 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -929,20 +929,18 @@ re_dfa_add_node (dfa, token, mode)
dfa->nodes = new_array;
if (mode)
{
- int *new_firsts, *new_nexts;
+ int *new_nexts;
re_node_set *new_edests, *new_eclosures, *new_inveclosures;
- new_firsts = re_realloc (dfa->firsts, int, dfa->nodes_alloc);
new_nexts = re_realloc (dfa->nexts, int, dfa->nodes_alloc);
new_edests = re_realloc (dfa->edests, re_node_set, dfa->nodes_alloc);
new_eclosures = re_realloc (dfa->eclosures, re_node_set,
dfa->nodes_alloc);
new_inveclosures = re_realloc (dfa->inveclosures, re_node_set,
dfa->nodes_alloc);
- if (BE (new_firsts == NULL || new_nexts == NULL || new_edests == NULL
+ if (BE (new_nexts == NULL || new_edests == NULL
|| new_eclosures == NULL || new_inveclosures == NULL, 0))
return -1;
- dfa->firsts = new_firsts;
dfa->nexts = new_nexts;
dfa->edests = new_edests;
dfa->eclosures = new_eclosures;
@@ -951,6 +949,7 @@ re_dfa_add_node (dfa, token, mode)
}
dfa->nodes[dfa->nodes_len] = token;
dfa->nodes[dfa->nodes_len].duplicated = 0;
+ dfa->nodes[dfa->nodes_len].constraint = 0;
return dfa->nodes_len++;
}
@@ -1126,7 +1125,7 @@ create_ci_newstate (dfa, nodes, hash)
{
re_token_t *node = dfa->nodes + nodes->elems[i];
re_token_type_t type = node->type;
- if (type == CHARACTER)
+ if (type == CHARACTER && !node->constraint)
continue;
/* If the state has the halt node, the state is a halt state. */
@@ -1139,13 +1138,8 @@ create_ci_newstate (dfa, nodes, hash)
#endif /* RE_ENABLE_I18N */
else if (type == OP_BACK_REF)
newstate->has_backref = 1;
- else if (type == ANCHOR || OP_CONTEXT_NODE)
- {
- newstate->has_constraint = 1;
- if (type == OP_CONTEXT_NODE
- && dfa->nodes[node->opr.ctx_info->entity].type == END_OF_RE)
- newstate->halt = 1;
- }
+ else if (type == ANCHOR || node->constraint)
+ newstate->has_constraint = 1;
}
err = register_state (dfa, newstate, hash);
return (err != REG_NOERROR) ? NULL : newstate;
@@ -1175,9 +1169,11 @@ create_cd_newstate (dfa, nodes, context, hash)
unsigned int constraint = 0;
re_token_t *node = dfa->nodes + nodes->elems[i];
re_token_type_t type = node->type;
- if (type == CHARACTER)
- continue;
+ if (node->constraint)
+ constraint = node->constraint;
+ if (type == CHARACTER && !constraint)
+ continue;
/* If the state has the halt node, the state is a halt state. */
else if (type == END_OF_RE)
newstate->halt = 1;
@@ -1190,20 +1186,6 @@ create_cd_newstate (dfa, nodes, context, hash)
newstate->has_backref = 1;
else if (type == ANCHOR)
constraint = node->opr.ctx_type;
- else if (type == OP_CONTEXT_NODE)
- {
- re_token_type_t ctype = dfa->nodes[node->opr.ctx_info->entity].type;
- constraint = node->constraint;
- if (ctype == END_OF_RE)
- newstate->halt = 1;
- else if (ctype == OP_BACK_REF)
- newstate->has_backref = 1;
-#ifdef RE_ENABLE_I18N
- else if (ctype == COMPLEX_BRACKET
- || (type == OP_PERIOD && MB_CUR_MAX > 1))
- newstate->accept_mb = 1;
-#endif /* RE_ENABLE_I18N */
- }
if (constraint)
{