mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
2004-12-01 Paolo Bonzini <bonzini@gnu.org> * posix/regcomp.c (free_dfa_content, init_dfa): Remove references to re_dfa_t's subexps field. (parse_sub_exp, parse_expression): Do not use it. Use completed_bkref_map instead. (create_initial_state, peek_token): Store a backreference \N with opr.idx = N-1. * posix/regexec.c (proceed_next_node, check_dst_limits, get_subexp): Likewise. (check_subexp_limits): Remove useless condition. * posix/regex_internal.h (re_subexp_t): Remove. (re_dfa_t): Remove subexps and subexps_alloc field, add completed_bkref_map.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
2004-12-01 Paolo Bonzini <bonzini@gnu.org>
|
||||||
|
|
||||||
|
* posix/regcomp.c (free_dfa_content, init_dfa): Remove
|
||||||
|
references to re_dfa_t's subexps field.
|
||||||
|
(parse_sub_exp, parse_expression): Do not use it. Use
|
||||||
|
completed_bkref_map instead.
|
||||||
|
(create_initial_state, peek_token): Store a backreference \N
|
||||||
|
with opr.idx = N-1.
|
||||||
|
* posix/regexec.c (proceed_next_node, check_dst_limits, get_subexp):
|
||||||
|
Likewise.
|
||||||
|
(check_subexp_limits): Remove useless condition.
|
||||||
|
* posix/regex_internal.h (re_subexp_t): Remove.
|
||||||
|
(re_dfa_t): Remove subexps and subexps_alloc field, add
|
||||||
|
completed_bkref_map.
|
||||||
|
|
||||||
2004-12-05 Roland McGrath <roland@frob.com>
|
2004-12-05 Roland McGrath <roland@frob.com>
|
||||||
|
|
||||||
* Makeconfig: Comment typo fix.
|
* Makeconfig: Comment typo fix.
|
||||||
|
@ -496,13 +496,6 @@ struct re_dfastate_t
|
|||||||
};
|
};
|
||||||
typedef struct re_dfastate_t re_dfastate_t;
|
typedef struct re_dfastate_t re_dfastate_t;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/* start <= node < end */
|
|
||||||
int start;
|
|
||||||
int end;
|
|
||||||
} re_subexp_t;
|
|
||||||
|
|
||||||
struct re_state_table_entry
|
struct re_state_table_entry
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
@ -607,7 +600,6 @@ struct re_fail_stack_t
|
|||||||
|
|
||||||
struct re_dfa_t
|
struct re_dfa_t
|
||||||
{
|
{
|
||||||
re_subexp_t *subexps;
|
|
||||||
re_token_t *nodes;
|
re_token_t *nodes;
|
||||||
int nodes_alloc;
|
int nodes_alloc;
|
||||||
int nodes_len;
|
int nodes_len;
|
||||||
@ -627,13 +619,15 @@ struct re_dfa_t
|
|||||||
int str_tree_storage_idx;
|
int str_tree_storage_idx;
|
||||||
|
|
||||||
/* number of subexpressions `re_nsub' is in regex_t. */
|
/* number of subexpressions `re_nsub' is in regex_t. */
|
||||||
int subexps_alloc;
|
|
||||||
unsigned int state_hash_mask;
|
unsigned int state_hash_mask;
|
||||||
int states_alloc;
|
int states_alloc;
|
||||||
int init_node;
|
int init_node;
|
||||||
int nbackref; /* The number of backreference in this dfa. */
|
int nbackref; /* The number of backreference in this dfa. */
|
||||||
|
|
||||||
/* Bitmap expressing which backreference is used. */
|
/* Bitmap expressing which backreference is used. */
|
||||||
unsigned int used_bkref_map;
|
unsigned int used_bkref_map;
|
||||||
|
unsigned int completed_bkref_map;
|
||||||
|
|
||||||
unsigned int has_plural_match : 1;
|
unsigned int has_plural_match : 1;
|
||||||
/* If this dfa has "multibyte node", which is a backreference or
|
/* If this dfa has "multibyte node", which is a backreference or
|
||||||
a node which can accept multibyte character or multi character
|
a node which can accept multibyte character or multi character
|
||||||
|
@ -1260,7 +1260,7 @@ proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs)
|
|||||||
#endif /* RE_ENABLE_I18N */
|
#endif /* RE_ENABLE_I18N */
|
||||||
if (type == OP_BACK_REF)
|
if (type == OP_BACK_REF)
|
||||||
{
|
{
|
||||||
int subexp_idx = dfa->nodes[node].opr.idx;
|
int subexp_idx = dfa->nodes[node].opr.idx + 1;
|
||||||
naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
|
naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
|
||||||
if (fs != NULL)
|
if (fs != NULL)
|
||||||
{
|
{
|
||||||
@ -1853,7 +1853,7 @@ check_dst_limits (mctx, limits, dst_node, dst_idx, src_node, src_idx)
|
|||||||
int subexp_idx;
|
int subexp_idx;
|
||||||
struct re_backref_cache_entry *ent;
|
struct re_backref_cache_entry *ent;
|
||||||
ent = mctx->bkref_ents + limits->elems[lim_idx];
|
ent = mctx->bkref_ents + limits->elems[lim_idx];
|
||||||
subexp_idx = dfa->nodes[ent->node].opr.idx - 1;
|
subexp_idx = dfa->nodes[ent->node].opr.idx;
|
||||||
|
|
||||||
dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
|
dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
|
||||||
subexp_idx, dst_node, dst_idx,
|
subexp_idx, dst_node, dst_idx,
|
||||||
@ -1891,49 +1891,48 @@ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx)
|
|||||||
switch (dfa->nodes[node].type)
|
switch (dfa->nodes[node].type)
|
||||||
{
|
{
|
||||||
case OP_BACK_REF:
|
case OP_BACK_REF:
|
||||||
{
|
if (bkref_idx != -1)
|
||||||
struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
|
{
|
||||||
do
|
struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
|
||||||
{
|
do
|
||||||
int dst, cpos;
|
{
|
||||||
|
int dst, cpos;
|
||||||
|
|
||||||
if (ent->node != node)
|
if (ent->node != node)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (subexp_idx <= 8 * sizeof (ent->eps_reachable_subexps_map)
|
if (subexp_idx <= 8 * sizeof (ent->eps_reachable_subexps_map)
|
||||||
&& (ent->eps_reachable_subexps_map
|
&& !(ent->eps_reachable_subexps_map & (1 << subexp_idx)))
|
||||||
& (1 << (subexp_idx - 1))) == 0)
|
continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Recurse trying to reach the OP_OPEN_SUBEXP and
|
/* Recurse trying to reach the OP_OPEN_SUBEXP and
|
||||||
OP_CLOSE_SUBEXP cases below. But, if the
|
OP_CLOSE_SUBEXP cases below. But, if the
|
||||||
destination node is the same node as the source
|
destination node is the same node as the source
|
||||||
node, don't recurse because it would cause an
|
node, don't recurse because it would cause an
|
||||||
infinite loop: a regex that exhibits this behavior
|
infinite loop: a regex that exhibits this behavior
|
||||||
is ()\1*\1* */
|
is ()\1*\1* */
|
||||||
dst = dfa->edests[node].elems[0];
|
dst = dfa->edests[node].elems[0];
|
||||||
if (dst == from_node)
|
if (dst == from_node)
|
||||||
{
|
{
|
||||||
if (boundaries & 1)
|
if (boundaries & 1)
|
||||||
return -1;
|
return -1;
|
||||||
else /* if (boundaries & 2) */
|
else /* if (boundaries & 2) */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpos = check_dst_limits_calc_pos_1 (mctx, boundaries,
|
cpos =
|
||||||
subexp_idx, dst, bkref_idx);
|
check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
|
||||||
|
dst, bkref_idx);
|
||||||
|
if (cpos == -1 /* && (boundaries & 1) */)
|
||||||
|
return -1;
|
||||||
|
if (cpos == 0 && (boundaries & 2))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (cpos == -1 /* && (boundaries & 1) */)
|
ent->eps_reachable_subexps_map &= ~(1 << subexp_idx);
|
||||||
return -1;
|
}
|
||||||
|
while (ent++->more);
|
||||||
if (cpos == 0 && (boundaries & 2))
|
}
|
||||||
return 0;
|
break;
|
||||||
|
|
||||||
ent->eps_reachable_subexps_map &= ~(1 << (subexp_idx - 1));
|
|
||||||
}
|
|
||||||
while (ent++->more);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case OP_OPEN_SUBEXP:
|
case OP_OPEN_SUBEXP:
|
||||||
if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
|
if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
|
||||||
@ -2003,7 +2002,7 @@ check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx)
|
|||||||
if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
|
if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
|
||||||
continue; /* This is unrelated limitation. */
|
continue; /* This is unrelated limitation. */
|
||||||
|
|
||||||
subexp_idx = dfa->nodes[ent->node].opr.idx - 1;
|
subexp_idx = dfa->nodes[ent->node].opr.idx;
|
||||||
if (ent->subexp_to == str_idx)
|
if (ent->subexp_to == str_idx)
|
||||||
{
|
{
|
||||||
int ops_node = -1;
|
int ops_node = -1;
|
||||||
@ -2060,16 +2059,12 @@ check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx)
|
|||||||
{
|
{
|
||||||
if (subexp_idx != dfa->nodes[node].opr.idx)
|
if (subexp_idx != dfa->nodes[node].opr.idx)
|
||||||
continue;
|
continue;
|
||||||
if ((type == OP_CLOSE_SUBEXP && ent->subexp_to != str_idx)
|
/* It is against this limitation.
|
||||||
|| (type == OP_OPEN_SUBEXP))
|
Remove it form the current sifted state. */
|
||||||
{
|
err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
|
||||||
/* It is against this limitation.
|
candidates);
|
||||||
Remove it form the current sifted state. */
|
if (BE (err != REG_NOERROR, 0))
|
||||||
err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
|
return err;
|
||||||
candidates);
|
|
||||||
if (BE (err != REG_NOERROR, 0))
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2656,7 +2651,7 @@ get_subexp (mctx, bkref_node, bkref_str_idx)
|
|||||||
while (entry++->more);
|
while (entry++->more);
|
||||||
}
|
}
|
||||||
|
|
||||||
subexp_num = dfa->nodes[bkref_node].opr.idx - 1;
|
subexp_num = dfa->nodes[bkref_node].opr.idx;
|
||||||
|
|
||||||
/* For each sub expression */
|
/* For each sub expression */
|
||||||
for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
|
for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
|
||||||
|
Reference in New Issue
Block a user