2002-02-26 19:06:03 +00:00
|
|
|
|
/* Extended regular expression matching and search library.
|
2018-01-01 00:32:25 +00:00
|
|
|
|
Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
|
License along with the GNU C Library; if not, see
|
2017-12-20 11:47:44 +00:00
|
|
|
|
<https://www.gnu.org/licenses/>. */
|
2013-05-01 15:46:34 +00:00
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx n);
|
2017-08-31 16:25:55 +00:00
|
|
|
|
static void match_ctx_clean (re_match_context_t *mctx);
|
|
|
|
|
static void match_ctx_free (re_match_context_t *cache);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node,
|
|
|
|
|
Idx str_idx, Idx from, Idx to);
|
|
|
|
|
static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx);
|
|
|
|
|
static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
|
|
|
|
|
Idx str_idx);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node, Idx str_idx);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfastate_t **limited_sts, Idx last_node,
|
|
|
|
|
Idx last_str_idx);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t re_search_internal (const regex_t *preg,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *string, Idx length,
|
|
|
|
|
Idx start, Idx last_start, Idx stop,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
size_t nmatch, regmatch_t pmatch[],
|
2017-08-31 16:25:55 +00:00
|
|
|
|
int eflags);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
|
|
|
|
|
const char *string1, Idx length1,
|
|
|
|
|
const char *string2, Idx length2,
|
|
|
|
|
Idx start, regoff_t range,
|
|
|
|
|
struct re_registers *regs,
|
|
|
|
|
Idx stop, bool ret_len);
|
|
|
|
|
static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
|
|
|
|
|
const char *string, Idx length, Idx start,
|
|
|
|
|
regoff_t range, Idx stop,
|
|
|
|
|
struct re_registers *regs,
|
|
|
|
|
bool ret_len);
|
2002-07-27 08:20:17 +00:00
|
|
|
|
static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nregs, int regs_allocated);
|
2017-08-31 16:25:55 +00:00
|
|
|
|
static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
|
|
|
|
|
Idx *p_match_first);
|
|
|
|
|
static Idx check_halt_state_context (const re_match_context_t *mctx,
|
|
|
|
|
const re_dfastate_t *state, Idx idx);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regmatch_t *prev_idx_match, Idx cur_node,
|
|
|
|
|
Idx cur_idx, Idx nmatch);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx, Idx dest_node, Idx nregs,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
regmatch_t *regs,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_node_set *eps_via_nodes);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
static reg_errcode_t set_regs (const regex_t *preg,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
const re_match_context_t *mctx,
|
|
|
|
|
size_t nmatch, regmatch_t *pmatch,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool fl_backtrack);
|
2017-08-31 16:25:55 +00:00
|
|
|
|
static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
|
2002-10-12 08:34:26 +00:00
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static int sift_states_iter_mb (const re_match_context_t *mctx,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_sift_context_t *sctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx, Idx str_idx, Idx max_str_idx);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_sift_context_t *sctx);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_sift_context_t *sctx, Idx str_idx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_node_set *cur_dest);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_sift_context_t *sctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_node_set *dest_nodes);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set *dest_nodes,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
const re_node_set *candidates);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static bool check_dst_limits (const re_match_context_t *mctx,
|
|
|
|
|
const re_node_set *limits,
|
|
|
|
|
Idx dst_node, Idx dst_idx, Idx src_node,
|
|
|
|
|
Idx src_idx);
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
int boundaries, Idx subexp_idx,
|
|
|
|
|
Idx from_node, Idx bkref_idx);
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx limit, Idx subexp_idx,
|
|
|
|
|
Idx node, Idx str_idx,
|
|
|
|
|
Idx bkref_idx);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set *dest_nodes,
|
|
|
|
|
const re_node_set *candidates,
|
|
|
|
|
re_node_set *limits,
|
|
|
|
|
struct re_backref_cache_entry *bkref_ents,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_sift_context_t *sctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx, const re_node_set *candidates);
|
2005-09-07 16:15:23 +00:00
|
|
|
|
static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
|
|
|
|
|
re_dfastate_t **dst,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfastate_t **src, Idx num);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
static re_dfastate_t *find_recover_state (reg_errcode_t *err,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_match_context_t *mctx);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static re_dfastate_t *transit_state (reg_errcode_t *err,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_match_context_t *mctx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_dfastate_t *state);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
|
|
|
|
|
re_match_context_t *mctx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_dfastate_t *next_state);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set *cur_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx);
|
2003-11-20 23:36:40 +00:00
|
|
|
|
#if 0
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
|
|
|
|
|
re_match_context_t *mctx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_dfastate_t *pstate);
|
2003-11-20 23:36:40 +00:00
|
|
|
|
#endif
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_dfastate_t *pstate);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
const re_node_set *nodes);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t get_subexp (re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx bkref_node, Idx bkref_str_idx);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
|
2003-11-23 09:46:38 +00:00
|
|
|
|
const re_sub_match_top_t *sub_top,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_sub_match_last_t *sub_last,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx bkref_node, Idx bkref_str);
|
|
|
|
|
static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
|
|
|
|
|
Idx subexp_idx, int type);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t check_arrival (re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
state_array_t *path, Idx top_node,
|
|
|
|
|
Idx top_str, Idx last_node, Idx last_str,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
int type);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set *cur_nodes,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
re_node_set *next_nodes);
|
2005-09-07 15:26:18 +00:00
|
|
|
|
static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set *cur_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx ex_subexp, int type);
|
2005-09-07 15:26:18 +00:00
|
|
|
|
static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set *dst_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx target, Idx ex_subexp,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
int type);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_node_set *cur_nodes, Idx cur_str,
|
|
|
|
|
Idx subexp_num, int type);
|
|
|
|
|
static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
|
|
|
|
|
const re_string_t *input, Idx idx);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# ifdef _LIBC
|
2002-09-10 18:40:35 +00:00
|
|
|
|
static unsigned int find_collation_sequence_value (const unsigned char *mbs,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
size_t name_len);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# endif /* _LIBC */
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
const re_dfastate_t *state,
|
|
|
|
|
re_node_set *states_node,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
bitset_t *states_ch);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static bool check_node_accept (const re_match_context_t *mctx,
|
|
|
|
|
const re_token_t *node, Idx idx);
|
2017-08-31 16:25:55 +00:00
|
|
|
|
static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Entry point for POSIX code. */
|
|
|
|
|
|
|
|
|
|
/* regexec searches for a given pattern, specified by PREG, in the
|
|
|
|
|
string STRING.
|
|
|
|
|
|
|
|
|
|
If NMATCH is zero or REG_NOSUB was set in the cflags argument to
|
2017-12-20 11:47:44 +00:00
|
|
|
|
'regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
|
2002-02-26 19:06:03 +00:00
|
|
|
|
least NMATCH elements, and we set them to the offsets of the
|
|
|
|
|
corresponding matched substrings.
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
EFLAGS specifies "execution flags" which affect matching: if
|
2002-02-26 19:06:03 +00:00
|
|
|
|
REG_NOTBOL is set, then ^ does not match at the beginning of the
|
|
|
|
|
string; if REG_NOTEOL is set, then $ does not match at the end.
|
|
|
|
|
|
|
|
|
|
We return 0 if we find a match and REG_NOMATCH if not. */
|
|
|
|
|
|
|
|
|
|
int
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
|
2015-10-20 11:54:09 +00:00
|
|
|
|
size_t nmatch, regmatch_t pmatch[], int eflags)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx start, length;
|
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2004-03-10 06:46:51 +00:00
|
|
|
|
|
|
|
|
|
if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
|
|
|
|
|
return REG_BADPAT;
|
|
|
|
|
|
2004-03-04 23:37:01 +00:00
|
|
|
|
if (eflags & REG_STARTEND)
|
|
|
|
|
{
|
|
|
|
|
start = pmatch[0].rm_so;
|
|
|
|
|
length = pmatch[0].rm_eo;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
start = 0;
|
|
|
|
|
length = strlen (string);
|
|
|
|
|
}
|
2005-05-06 23:34:44 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_lock (dfa->lock);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (preg->no_sub)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
err = re_search_internal (preg, string, length, start, length,
|
2004-03-04 23:37:01 +00:00
|
|
|
|
length, 0, NULL, eflags);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
err = re_search_internal (preg, string, length, start, length,
|
2004-03-04 23:37:01 +00:00
|
|
|
|
length, nmatch, pmatch, eflags);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_unlock (dfa->lock);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return err != REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2004-03-10 06:46:51 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef _LIBC
|
2017-10-01 22:52:56 +00:00
|
|
|
|
libc_hidden_def (__regexec)
|
|
|
|
|
|
2004-03-10 06:46:51 +00:00
|
|
|
|
# include <shlib-compat.h>
|
|
|
|
|
versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
|
|
|
|
|
|
|
|
|
|
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
|
|
|
|
|
__typeof__ (__regexec) __compat_regexec;
|
|
|
|
|
|
|
|
|
|
int
|
2004-03-10 10:04:19 +00:00
|
|
|
|
attribute_compat_text_section
|
2017-12-20 11:47:44 +00:00
|
|
|
|
__compat_regexec (const regex_t *_Restrict_ preg,
|
|
|
|
|
const char *_Restrict_ string, size_t nmatch,
|
2004-03-10 06:46:51 +00:00
|
|
|
|
regmatch_t pmatch[], int eflags)
|
|
|
|
|
{
|
|
|
|
|
return regexec (preg, string, nmatch, pmatch,
|
|
|
|
|
eflags & (REG_NOTBOL | REG_NOTEOL));
|
|
|
|
|
}
|
|
|
|
|
compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
|
|
|
|
|
# endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Entry points for GNU code. */
|
|
|
|
|
|
2002-07-27 08:20:17 +00:00
|
|
|
|
/* re_match, re_search, re_match_2, re_search_2
|
|
|
|
|
|
|
|
|
|
The former two functions operate on STRING with length LENGTH,
|
|
|
|
|
while the later two operate on concatenation of STRING1 and STRING2
|
|
|
|
|
with lengths LENGTH1 and LENGTH2, respectively.
|
|
|
|
|
|
|
|
|
|
re_match() matches the compiled pattern in BUFP against the string,
|
|
|
|
|
starting at index START.
|
|
|
|
|
|
|
|
|
|
re_search() first tries matching at index START, then it tries to match
|
|
|
|
|
starting from index START + 1, and so on. The last start position tried
|
|
|
|
|
is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same
|
|
|
|
|
way as re_match().)
|
|
|
|
|
|
|
|
|
|
The parameter STOP of re_{match,search}_2 specifies that no match exceeding
|
|
|
|
|
the first STOP characters of the concatenation of the strings should be
|
|
|
|
|
concerned.
|
|
|
|
|
|
|
|
|
|
If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
|
2017-12-20 03:26:08 +00:00
|
|
|
|
and all groups is stored in REGS. (For the "_2" variants, the offsets are
|
2002-07-27 08:20:17 +00:00
|
|
|
|
computed relative to the concatenation, not relative to the individual
|
|
|
|
|
strings.)
|
|
|
|
|
|
|
|
|
|
On success, re_match* functions return the length of the match, re_search*
|
|
|
|
|
return the position of the start of the match. Return value -1 means no
|
|
|
|
|
match was found and -2 indicates an internal error. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regoff_t
|
|
|
|
|
re_match (struct re_pattern_buffer *bufp, const char *string, Idx length,
|
|
|
|
|
Idx start, struct re_registers *regs)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return re_search_stub (bufp, string, length, start, 0, length, regs, true);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
weak_alias (__re_match, re_match)
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regoff_t
|
|
|
|
|
re_search (struct re_pattern_buffer *bufp, const char *string, Idx length,
|
|
|
|
|
Idx start, regoff_t range, struct re_registers *regs)
|
2002-07-27 08:20:17 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return re_search_stub (bufp, string, length, start, range, length, regs,
|
|
|
|
|
false);
|
2002-07-27 08:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
weak_alias (__re_search, re_search)
|
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regoff_t
|
|
|
|
|
re_match_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
|
|
|
|
|
const char *string2, Idx length2, Idx start,
|
|
|
|
|
struct re_registers *regs, Idx stop)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-07-27 08:20:17 +00:00
|
|
|
|
return re_search_2_stub (bufp, string1, length1, string2, length2,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
start, 0, regs, stop, true);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
weak_alias (__re_match_2, re_match_2)
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regoff_t
|
|
|
|
|
re_search_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
|
|
|
|
|
const char *string2, Idx length2, Idx start, regoff_t range,
|
|
|
|
|
struct re_registers *regs, Idx stop)
|
2002-07-27 08:20:17 +00:00
|
|
|
|
{
|
|
|
|
|
return re_search_2_stub (bufp, string1, length1, string2, length2,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
start, range, regs, stop, false);
|
2002-07-27 08:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
weak_alias (__re_search_2, re_search_2)
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static regoff_t
|
2015-10-21 11:57:23 +00:00
|
|
|
|
re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx length1, const char *string2, Idx length2, Idx start,
|
|
|
|
|
regoff_t range, struct re_registers *regs,
|
|
|
|
|
Idx stop, bool ret_len)
|
2002-07-27 08:20:17 +00:00
|
|
|
|
{
|
|
|
|
|
const char *str;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regoff_t rval;
|
|
|
|
|
Idx len;
|
2010-01-22 18:39:59 +00:00
|
|
|
|
char *s = NULL;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
|
|
|
|
|
|| INT_ADD_WRAPV (length1, length2, &len))))
|
2002-07-27 08:20:17 +00:00
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|
/* Concatenate the strings. */
|
|
|
|
|
if (length2 > 0)
|
|
|
|
|
if (length1 > 0)
|
|
|
|
|
{
|
2010-01-22 18:39:59 +00:00
|
|
|
|
s = re_malloc (char, len);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (s == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return -2;
|
2005-09-07 05:41:42 +00:00
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
memcpy (__mempcpy (s, string1, length1), string2, length2);
|
|
|
|
|
#else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
memcpy (s, string1, length1);
|
|
|
|
|
memcpy (s + length1, string2, length2);
|
2005-09-07 05:41:42 +00:00
|
|
|
|
#endif
|
2002-11-06 20:36:47 +00:00
|
|
|
|
str = s;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
str = string2;
|
|
|
|
|
else
|
|
|
|
|
str = string1;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
rval = re_search_stub (bufp, str, len, start, range, stop, regs,
|
|
|
|
|
ret_len);
|
2010-01-22 18:39:59 +00:00
|
|
|
|
re_free (s);
|
2002-07-27 08:20:17 +00:00
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The parameters have the same meaning as those of re_search.
|
|
|
|
|
Additional parameters:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
If RET_LEN is true the length of the match is returned (re_match style);
|
2002-07-27 08:20:17 +00:00
|
|
|
|
otherwise the position of the match is returned. */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static regoff_t
|
|
|
|
|
re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
|
|
|
|
|
Idx start, regoff_t range, Idx stop, struct re_registers *regs,
|
|
|
|
|
bool ret_len)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t result;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
regmatch_t *pmatch;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nregs;
|
|
|
|
|
regoff_t rval;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
int eflags = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = bufp->buffer;
|
|
|
|
|
Idx last_start = start + range;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
|
|
|
|
|
/* Check for out-of-range. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (start < 0 || start > length))
|
2002-07-27 08:20:17 +00:00
|
|
|
|
return -1;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (length < last_start
|
|
|
|
|
|| (0 <= range && last_start < start)))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
last_start = length;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
else if (__glibc_unlikely (last_start < 0
|
|
|
|
|
|| (range < 0 && start <= last_start)))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
last_start = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_lock (dfa->lock);
|
2005-05-06 23:34:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
|
|
|
|
|
eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
|
|
|
|
|
|
2002-07-27 08:20:17 +00:00
|
|
|
|
/* Compile fastmap if we haven't yet. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
|
2002-07-27 08:20:17 +00:00
|
|
|
|
re_compile_fastmap (bufp);
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (bufp->no_sub))
|
2002-07-27 08:20:17 +00:00
|
|
|
|
regs = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* We need at least 1 register. */
|
2002-07-27 08:20:17 +00:00
|
|
|
|
if (regs == NULL)
|
|
|
|
|
nregs = 1;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED
|
|
|
|
|
&& regs->num_regs <= bufp->re_nsub))
|
2002-07-27 08:20:17 +00:00
|
|
|
|
{
|
|
|
|
|
nregs = regs->num_regs;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (nregs < 1))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* Nothing can be copied to regs. */
|
|
|
|
|
regs = NULL;
|
|
|
|
|
nregs = 1;
|
|
|
|
|
}
|
2002-07-27 08:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nregs = bufp->re_nsub + 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
pmatch = re_malloc (regmatch_t, nregs);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (pmatch == NULL))
|
2005-05-06 23:34:44 +00:00
|
|
|
|
{
|
|
|
|
|
rval = -2;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
result = re_search_internal (bufp, string, length, start, last_start, stop,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
nregs, pmatch, eflags);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-07-27 08:20:17 +00:00
|
|
|
|
rval = 0;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* I hope we needn't fill their regs with -1's when no match was found. */
|
2002-07-27 08:20:17 +00:00
|
|
|
|
if (result != REG_NOERROR)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
rval = result == REG_NOMATCH ? -1 : -2;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
else if (regs != NULL)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-07-27 08:20:17 +00:00
|
|
|
|
/* If caller wants register contents data back, copy them. */
|
|
|
|
|
bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bufp->regs_allocated);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
rval = -2;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (rval == 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-07-27 08:20:17 +00:00
|
|
|
|
if (ret_len)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
assert (pmatch[0].rm_so == start);
|
|
|
|
|
rval = pmatch[0].rm_eo - start;
|
|
|
|
|
}
|
2002-07-27 08:20:17 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
rval = pmatch[0].rm_so;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
re_free (pmatch);
|
2005-05-06 23:34:44 +00:00
|
|
|
|
out:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_unlock (dfa->lock);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return rval;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-27 08:20:17 +00:00
|
|
|
|
static unsigned
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
|
2015-10-20 11:54:09 +00:00
|
|
|
|
int regs_allocated)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-07-27 08:20:17 +00:00
|
|
|
|
int rval = REGS_REALLOCATE;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
|
|
|
|
Idx need_regs = nregs + 1;
|
|
|
|
|
/* We need one extra element beyond 'num_regs' for the '-1' marker GNU code
|
2002-07-27 08:20:17 +00:00
|
|
|
|
uses. */
|
|
|
|
|
|
|
|
|
|
/* Have the register data arrays been allocated? */
|
|
|
|
|
if (regs_allocated == REGS_UNALLOCATED)
|
2003-12-29 17:59:41 +00:00
|
|
|
|
{ /* No. So allocate them with malloc. */
|
2003-12-29 00:42:16 +00:00
|
|
|
|
regs->start = re_malloc (regoff_t, need_regs);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (regs->start == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REGS_UNALLOCATED;
|
2010-01-22 20:33:58 +00:00
|
|
|
|
regs->end = re_malloc (regoff_t, need_regs);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (regs->end == NULL))
|
2010-01-22 20:33:58 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (regs->start);
|
|
|
|
|
return REGS_UNALLOCATED;
|
|
|
|
|
}
|
2002-07-27 08:20:17 +00:00
|
|
|
|
regs->num_regs = need_regs;
|
|
|
|
|
}
|
|
|
|
|
else if (regs_allocated == REGS_REALLOCATE)
|
|
|
|
|
{ /* Yes. If we need more elements than were already
|
2002-11-06 20:36:47 +00:00
|
|
|
|
allocated, reallocate them. If we need fewer, just
|
|
|
|
|
leave it alone. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (need_regs > regs->num_regs))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-12-29 17:59:41 +00:00
|
|
|
|
regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
|
2010-01-22 20:33:58 +00:00
|
|
|
|
regoff_t *new_end;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_start == NULL))
|
2003-12-29 00:42:16 +00:00
|
|
|
|
return REGS_UNALLOCATED;
|
2010-01-22 20:33:58 +00:00
|
|
|
|
new_end = re_realloc (regs->end, regoff_t, need_regs);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_end == NULL))
|
2010-01-22 20:33:58 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (new_start);
|
|
|
|
|
return REGS_UNALLOCATED;
|
|
|
|
|
}
|
2003-12-29 17:59:41 +00:00
|
|
|
|
regs->start = new_start;
|
|
|
|
|
regs->end = new_end;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
regs->num_regs = need_regs;
|
|
|
|
|
}
|
2002-07-27 08:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
assert (regs_allocated == REGS_FIXED);
|
|
|
|
|
/* This function may not be called with REGS_FIXED and nregs too big. */
|
|
|
|
|
assert (regs->num_regs >= nregs);
|
|
|
|
|
rval = REGS_FIXED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy the regs. */
|
|
|
|
|
for (i = 0; i < nregs; ++i)
|
|
|
|
|
{
|
|
|
|
|
regs->start[i] = pmatch[i].rm_so;
|
|
|
|
|
regs->end[i] = pmatch[i].rm_eo;
|
|
|
|
|
}
|
|
|
|
|
for ( ; i < regs->num_regs; ++i)
|
|
|
|
|
regs->start[i] = regs->end[i] = -1;
|
|
|
|
|
|
|
|
|
|
return rval;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
|
|
|
|
ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
|
|
|
|
|
this memory for recording register information. STARTS and ENDS
|
|
|
|
|
must be allocated using the malloc library routine, and must each
|
|
|
|
|
be at least NUM_REGS * sizeof (regoff_t) bytes long.
|
|
|
|
|
|
|
|
|
|
If NUM_REGS == 0, then subsequent matches should allocate their own
|
|
|
|
|
register data.
|
|
|
|
|
|
|
|
|
|
Unless this function is called, the first search or match using
|
|
|
|
|
PATTERN_BUFFER will allocate its own register data, without
|
|
|
|
|
freeing the old data. */
|
|
|
|
|
|
|
|
|
|
void
|
2015-10-20 11:54:09 +00:00
|
|
|
|
re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
__re_size_t num_regs, regoff_t *starts, regoff_t *ends)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (num_regs)
|
|
|
|
|
{
|
|
|
|
|
bufp->regs_allocated = REGS_REALLOCATE;
|
|
|
|
|
regs->num_regs = num_regs;
|
|
|
|
|
regs->start = starts;
|
|
|
|
|
regs->end = ends;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bufp->regs_allocated = REGS_UNALLOCATED;
|
|
|
|
|
regs->num_regs = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regs->start = regs->end = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
weak_alias (__re_set_registers, re_set_registers)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Entry points compatible with 4.2 BSD regex library. We don't define
|
|
|
|
|
them unless specifically requested. */
|
|
|
|
|
|
|
|
|
|
#if defined _REGEX_RE_COMP || defined _LIBC
|
|
|
|
|
int
|
|
|
|
|
# ifdef _LIBC
|
|
|
|
|
weak_function
|
|
|
|
|
# endif
|
Convert miscellaneous function definitions to prototype style.
This patch converts various miscellaneous functions definitions in
glibc, found with grep and not covered by my previous scripted
conversions, from old-style K&R to prototype-style. These changes
were made manually. This is not necessarily exhaustive as formatting
variants may have prevented my grep from finding some such
definitions.
Regarding the changes to files from GMP, they may originally have been
omitted when removing __STDC__ conditionals because of the files
coming from another package, but (a) GMP no longer has __STDC__
conditionals there anyway and (b) we don't try to keep these files
verbatim in sync with GMP (and there are licensing differences), so
making the change to them in glibc seems reasonable.
Tested for x86_64 and x86 (testsuite - this patch affects files
containing assertions).
* debug/fortify_fail.c (__fortify_fail): Convert to
prototype-style function definition. Use internal_function.
* libio/genops.c (save_for_backup): Convert to prototype-style
function definition.
* libio/wgenops.c (save_for_wbackup): Likewise.
* login/grantpt.c (grantpt): Likewise.
* login/ptsname.c (ptsname): Likewise.
(__ptsname_r): Likewise.
* login/unlockpt.c (unlockpt): Likewise.
* mach/msgserver.c (__mach_msg_server): Likewise.
* misc/efgcvt.c (__APPEND (FUNC_PREFIX, fcvt)): Likewise.
(__APPEND (FUNC_PREFIX, ecvt)): Likewise.
(__APPEND (FUNC_PREFIX, gcvt)): Likewise.
* misc/efgcvt_r.c (__APPEND (FUNC_PREFIX, fcvt_r)): Likewise.
(__APPEND (FUNC_PREFIX, ecvt_r)): Likewise.
* nptl/cleanup_compat.c (_pthread_cleanup_push): Likewise.
* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
Likewise.
* nptl/libc_pthread_init.c (__libc_pthread_init): Likewise. Use
internal_function.
* nptl/pthread_atfork.c (__pthread_atfork): Convert to
prototype-style function definition.
* nptl/pthread_create.c (__pthread_create_2_1): Likewise.
[SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)]
(__pthread_create_2_0): Likewise.
* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
* nptl/register-atfork.c (__register_atfork): Likewise.
* posix/glob.c (glob): Likewise.
* posix/regcomp.c (re_comp): Likewise.
* posix/regexec.c (re_exec): Likewise.
* stdlib/add_n.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/cmp.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/divmod_1.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/divrem.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/lshift.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/mod_1.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/mul.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/mul_n.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/rshift.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* stdlib/strtod.c (INTERNAL (STRTOF)): Convert to prototype-style
function definition.
(STRTOF): Likewise.
* stdlib/strtod_l.c (__STRTOF): Likewise.
* stdlib/strtol.c (INTERNAL (strtol)): Likewise.
* stdlib/strtol_l.c (INTERNAL (__strtol_l)): Likewise.
(__strtol_l): Likewise.
* stdlib/sub_n.c [__STDC__]: Make code unconditional.
[!__STDC__]: Remove conditional code.
* string/memrchr.c (MEMRCHR): Convert to prototype-style function
definition.
* string/strcasecmp.c (LOCALE_PARAM_DECL): Remove macro.
[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
type.
(__strcasecmp): Convert to prototype-style function definition.
* string/strncase.c (LOCALE_PARAM_DECL): Remove macro.
[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
type.
(__strncasecmp): Convert to prototype-style function definition.
* sunrpc/pm_getport.c (__libc_rpc_getport): Likewise.
* sunrpc/xdr.c (xdr_union): Likewise.
* sunrpc/xdr_array.c (xdr_array): Likewise.
* sunrpc/xdr_ref.c (xdr_reference): Likewise.
* sysdeps/m68k/m680x0/fpu/s_atan.c (__CONCATX(__,FUNC)): Likewise.
* sysdeps/m68k/m680x0/fpu/s_isinf.c (__CONCATX(__,FUNC)):
Likewise.
* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(__scalbn,suffix):
Likewise.
* sysdeps/m68k/m680x0/fpu/s_sincos.c (CONCATX(__,FUNC)): Likewise.
* sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64):
Likewise.
* time/strftime_l.c (LOCALE_PARAM_DECL): Remove macro.
(LOCALE_PARAM_PROTO): Likewise.
[_LIBC && USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include
argument type.
(ut_argument_spec): Remove macro.
(ut_argument_spec_iso): Rename to ut_argument_spec.
(memcpy_lowcase): Use LOCALE_PARAM in declaration. Convert to
prototype-style function definition.
(memcpy_uppcase): Likewise.
(__strftime_internal): Likewise.
(my_strftime): Likewise.
* time/strptime_l.c (LOCALE_PARAM_PROTO): Remove macro.
(LOCALE_PARAM_DECL): Likewise.
[_LIBC] (LOCALE_PARAM): Include argument type.
(__strptime_internal): Convert to prototype-style function
definition.
(strptime): Likewise.
* wcsmbs/wcscasecmp.c (LOCALE_PARAM_DECL): Remove macro.
[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
type.
(__wcscasecmp): Convert to prototype-style function definition.
* wcsmbs/wcsncase.c (LOCALE_PARAM_DECL): Remove macro.
[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
type.
(__wcsncasecmp): Convert to prototype-style function definition.
2015-10-20 21:27:22 +00:00
|
|
|
|
re_exec (const char *s)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
#endif /* _REGEX_RE_COMP */
|
|
|
|
|
|
|
|
|
|
/* Internal entry point. */
|
|
|
|
|
|
|
|
|
|
/* Searches for a compiled pattern PREG in the string STRING, whose
|
|
|
|
|
length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same
|
2017-12-20 11:47:44 +00:00
|
|
|
|
meaning as with regexec. LAST_START is START + RANGE, where
|
|
|
|
|
START and RANGE have the same meaning as with re_search.
|
2002-02-28 07:43:13 +00:00
|
|
|
|
Return REG_NOERROR if we find a match, and REG_NOMATCH if not,
|
|
|
|
|
otherwise return the error code.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
Note: We assume front end functions already check ranges.
|
2017-12-20 11:47:44 +00:00
|
|
|
|
(0 <= LAST_START && LAST_START <= LENGTH) */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_search_internal (const regex_t *preg, const char *string, Idx length,
|
|
|
|
|
Idx start, Idx last_start, Idx stop, size_t nmatch,
|
2015-10-21 11:57:23 +00:00
|
|
|
|
regmatch_t pmatch[], int eflags)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const re_dfa_t *dfa = preg->buffer;
|
|
|
|
|
Idx left_lim, right_lim;
|
|
|
|
|
int incr;
|
|
|
|
|
bool fl_longest_match;
|
|
|
|
|
int match_kind;
|
|
|
|
|
Idx match_first;
|
|
|
|
|
Idx match_last = -1;
|
|
|
|
|
Idx extra_nmatch;
|
|
|
|
|
bool sb;
|
|
|
|
|
int ch;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
|
|
|
|
|
re_match_context_t mctx = { .dfa = dfa };
|
|
|
|
|
#else
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_match_context_t mctx;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
#endif
|
2017-12-20 11:47:44 +00:00
|
|
|
|
char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
|
|
|
|
|
&& start != last_start && !preg->can_be_null)
|
|
|
|
|
? preg->fastmap : NULL);
|
2005-09-23 06:11:29 +00:00
|
|
|
|
RE_TRANSLATE_TYPE t = preg->translate;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
|
|
|
|
|
memset (&mctx, '\0', sizeof (re_match_context_t));
|
|
|
|
|
mctx.dfa = dfa;
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-01-27 19:08:10 +00:00
|
|
|
|
extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
|
|
|
|
|
nmatch -= extra_nmatch;
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Check if the DFA haven't been compiled. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL
|
|
|
|
|
|| dfa->init_state_word == NULL
|
|
|
|
|
|| dfa->init_state_nl == NULL
|
|
|
|
|
|| dfa->init_state_begbuf == NULL))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return REG_NOMATCH;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2003-12-17 22:58:24 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
/* We assume front-end functions already check them. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
assert (0 <= last_start && last_start <= length);
|
2003-12-17 22:58:24 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* If initial states with non-begbuf contexts have no elements,
|
|
|
|
|
the regex must be anchored. If preg->newline_anchor is set,
|
|
|
|
|
we'll never use init_state_nl, so do not check it. */
|
|
|
|
|
if (dfa->init_state->nodes.nelem == 0
|
|
|
|
|
&& dfa->init_state_word->nodes.nelem == 0
|
|
|
|
|
&& (dfa->init_state_nl->nodes.nelem == 0
|
|
|
|
|
|| !preg->newline_anchor))
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (start != 0 && last_start != 0)
|
|
|
|
|
return REG_NOMATCH;
|
|
|
|
|
start = last_start = 0;
|
2003-12-17 22:58:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* We must check the longest matching, if nmatch > 0. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
fl_longest_match = (nmatch != 0 || dfa->nbackref);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
preg->translate, (preg->syntax & RE_ICASE) != 0,
|
|
|
|
|
dfa);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
goto free_return;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
mctx.input.stop = stop;
|
|
|
|
|
mctx.input.raw_stop = stop;
|
|
|
|
|
mctx.input.newline_anchor = preg->newline_anchor;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
goto free_return;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* We will log all the DFA states through which the dfa pass,
|
|
|
|
|
if nmatch > 1, or this dfa has "multibyte node", which is a
|
|
|
|
|
back-reference or a node which can accept multibyte character or
|
|
|
|
|
multi character collating element. */
|
|
|
|
|
if (nmatch > 1 || dfa->has_mb_node)
|
2002-02-28 07:43:13 +00:00
|
|
|
|
{
|
2010-01-22 20:15:53 +00:00
|
|
|
|
/* Avoid overflow. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
|
|
|
|
|
<= mctx.input.bufs_len)))
|
2010-01-22 20:15:53 +00:00
|
|
|
|
{
|
|
|
|
|
err = REG_ESPACE;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx.state_log == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
err = REG_ESPACE;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-04-24 21:54:53 +00:00
|
|
|
|
mctx.state_log = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
match_first = start;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
|
|
|
|
|
: CONTEXT_NEWLINE | CONTEXT_BEGBUF;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Check incrementally whether the input string matches. */
|
|
|
|
|
incr = (last_start < start) ? -1 : 1;
|
|
|
|
|
left_lim = (last_start < start) ? last_start : start;
|
|
|
|
|
right_lim = (last_start < start) ? start : last_start;
|
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
2003-11-12 17:47:46 +00:00
|
|
|
|
sb = dfa->mb_cur_max == 1;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
match_kind =
|
|
|
|
|
(fastmap
|
|
|
|
|
? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
| (start <= last_start ? 2 : 0)
|
2004-11-10 15:48:06 +00:00
|
|
|
|
| (t != NULL ? 1 : 0))
|
|
|
|
|
: 8);
|
|
|
|
|
|
|
|
|
|
for (;; match_first += incr)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
err = REG_NOMATCH;
|
|
|
|
|
if (match_first < left_lim || right_lim < match_first)
|
|
|
|
|
goto free_return;
|
|
|
|
|
|
|
|
|
|
/* Advance as rapidly as possible through the string, until we
|
|
|
|
|
find a plausible place to start matching. This may be done
|
|
|
|
|
with varying efficiency, so there are various possibilities:
|
|
|
|
|
only the most common of them are specialized, in order to
|
|
|
|
|
save on code size. We use a switch statement for speed. */
|
|
|
|
|
switch (match_kind)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
case 8:
|
|
|
|
|
/* No fastmap. */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
|
/* Fastmap with single-byte translation, match forward. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
while (__glibc_likely (match_first < right_lim)
|
2004-11-10 15:48:06 +00:00
|
|
|
|
&& !fastmap[t[(unsigned char) string[match_first]]])
|
|
|
|
|
++match_first;
|
|
|
|
|
goto forward_match_found_start_or_reached_end;
|
|
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
/* Fastmap without translation, match forward. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
while (__glibc_likely (match_first < right_lim)
|
2004-11-10 15:48:06 +00:00
|
|
|
|
&& !fastmap[(unsigned char) string[match_first]])
|
|
|
|
|
++match_first;
|
|
|
|
|
|
|
|
|
|
forward_match_found_start_or_reached_end:
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (match_first == right_lim))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
ch = match_first >= length
|
|
|
|
|
? 0 : (unsigned char) string[match_first];
|
|
|
|
|
if (!fastmap[t ? t[ch] : ch])
|
|
|
|
|
goto free_return;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
case 5:
|
|
|
|
|
/* Fastmap without multi-byte translation, match backwards. */
|
|
|
|
|
while (match_first >= left_lim)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
ch = match_first >= length
|
|
|
|
|
? 0 : (unsigned char) string[match_first];
|
|
|
|
|
if (fastmap[t ? t[ch] : ch])
|
|
|
|
|
break;
|
|
|
|
|
--match_first;
|
|
|
|
|
}
|
|
|
|
|
if (match_first < left_lim)
|
|
|
|
|
goto free_return;
|
|
|
|
|
break;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
|
2004-11-10 15:48:06 +00:00
|
|
|
|
default:
|
|
|
|
|
/* In this case, we can't determine easily the current byte,
|
|
|
|
|
since it might be a component byte of a multibyte
|
|
|
|
|
character. Then we use the constructed buffer instead. */
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
/* If MATCH_FIRST is out of the valid range, reconstruct the
|
|
|
|
|
buffers. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
__re_size_t offset = match_first - mctx.input.raw_mbs_idx;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (offset
|
|
|
|
|
>= (__re_size_t) mctx.input.valid_raw_len))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
err = re_string_reconstruct (&mctx.input, match_first,
|
|
|
|
|
eflags);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-10 15:48:06 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
|
|
|
|
|
offset = match_first - mctx.input.raw_mbs_idx;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
/* If MATCH_FIRST is out of the buffer, leave it as '\0'.
|
|
|
|
|
Note that MATCH_FIRST must not be smaller than 0. */
|
|
|
|
|
ch = (match_first >= length
|
|
|
|
|
? 0 : re_string_byte_at (&mctx.input, offset));
|
|
|
|
|
if (fastmap[ch])
|
2002-11-06 19:57:50 +00:00
|
|
|
|
break;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
match_first += incr;
|
|
|
|
|
if (match_first < left_lim || match_first > right_lim)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
{
|
|
|
|
|
err = REG_NOMATCH;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
break;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-11-06 19:57:50 +00:00
|
|
|
|
/* Reconstruct the buffers so that the matcher can assume that
|
2003-11-23 09:46:38 +00:00
|
|
|
|
the matching starts from the beginning of the buffer. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
err = re_string_reconstruct (&mctx.input, match_first, eflags);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
goto free_return;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2004-11-10 15:48:06 +00:00
|
|
|
|
/* Don't consider this char as a possible match start if it part,
|
|
|
|
|
yet isn't the head, of a multibyte character. */
|
|
|
|
|
if (!sb && !re_string_first_byte (&mctx.input, 0))
|
|
|
|
|
continue;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
|
|
|
|
/* It seems to be appropriate one, then use the matcher. */
|
|
|
|
|
/* We assume that the matching starts from 0. */
|
|
|
|
|
mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
|
|
|
|
|
match_last = check_matching (&mctx, fl_longest_match,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
start <= last_start ? &match_first : NULL);
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (match_last != -1)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (match_last == -2))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
err = REG_ESPACE;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mctx.match_last = match_last;
|
|
|
|
|
if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
re_dfastate_t *pstate = mctx.state_log[match_last];
|
|
|
|
|
mctx.last_node = check_halt_state_context (&mctx, pstate,
|
|
|
|
|
match_last);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
|
|
|
|
|
|| dfa->nbackref)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
err = prune_impossible_nodes (&mctx);
|
|
|
|
|
if (err == REG_NOERROR)
|
|
|
|
|
break;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOMATCH))
|
2004-11-10 15:48:06 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
match_last = -1;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
else
|
|
|
|
|
break; /* We found a match. */
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
|
|
|
|
match_ctx_clean (&mctx);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-11-10 15:48:06 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (match_last != -1);
|
|
|
|
|
assert (err == REG_NOERROR);
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Set pmatch[] if we need. */
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (nmatch > 0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx reg_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Initialize registers. */
|
2003-11-26 03:24:15 +00:00
|
|
|
|
for (reg_idx = 1; reg_idx < nmatch; ++reg_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Set the points where matching start/end. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pmatch[0].rm_so = 0;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
pmatch[0].rm_eo = mctx.match_last;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* FIXME: This function should fail if mctx.match_last exceeds
|
|
|
|
|
the maximum possible regoff_t value. We need a new error
|
|
|
|
|
code REG_OVERFLOW. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (!preg->no_sub && nmatch > 1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
err = set_regs (preg, &mctx, nmatch, pmatch,
|
|
|
|
|
dfa->has_plural_match && dfa->nbackref > 0);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2017-12-20 03:26:08 +00:00
|
|
|
|
/* At last, add the offset to each register, since we slid
|
2003-11-26 03:24:15 +00:00
|
|
|
|
the buffers so that we could assume that the matching starts
|
|
|
|
|
from 0. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (pmatch[reg_idx].rm_so != -1)
|
|
|
|
|
{
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx.input.offsets_needed != 0))
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
{
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
pmatch[reg_idx].rm_so =
|
|
|
|
|
(pmatch[reg_idx].rm_so == mctx.input.valid_len
|
|
|
|
|
? mctx.input.valid_raw_len
|
|
|
|
|
: mctx.input.offsets[pmatch[reg_idx].rm_so]);
|
|
|
|
|
pmatch[reg_idx].rm_eo =
|
|
|
|
|
(pmatch[reg_idx].rm_eo == mctx.input.valid_len
|
|
|
|
|
? mctx.input.valid_raw_len
|
|
|
|
|
: mctx.input.offsets[pmatch[reg_idx].rm_eo]);
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
}
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#else
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
assert (mctx.input.offsets_needed == 0);
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#endif
|
2002-11-06 20:36:47 +00:00
|
|
|
|
pmatch[reg_idx].rm_so += match_first;
|
|
|
|
|
pmatch[reg_idx].rm_eo += match_first;
|
|
|
|
|
}
|
2005-01-27 19:08:10 +00:00
|
|
|
|
for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx)
|
|
|
|
|
{
|
|
|
|
|
pmatch[nmatch + reg_idx].rm_so = -1;
|
|
|
|
|
pmatch[nmatch + reg_idx].rm_eo = -1;
|
|
|
|
|
}
|
2004-11-18 23:57:34 +00:00
|
|
|
|
|
|
|
|
|
if (dfa->subexp_map)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
|
|
|
|
|
if (dfa->subexp_map[reg_idx] != reg_idx)
|
|
|
|
|
{
|
|
|
|
|
pmatch[reg_idx + 1].rm_so
|
|
|
|
|
= pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
|
|
|
|
|
pmatch[reg_idx + 1].rm_eo
|
|
|
|
|
= pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
2002-11-06 19:57:50 +00:00
|
|
|
|
free_return:
|
2002-04-24 21:54:53 +00:00
|
|
|
|
re_free (mctx.state_log);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (dfa->nbackref)
|
|
|
|
|
match_ctx_free (&mctx);
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
re_string_destruct (&mctx.input);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2015-10-20 11:54:09 +00:00
|
|
|
|
prune_impossible_nodes (re_match_context_t *mctx)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx halt_node, match_last;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
reg_errcode_t ret;
|
|
|
|
|
re_dfastate_t **sifted_states;
|
|
|
|
|
re_dfastate_t **lim_states = NULL;
|
|
|
|
|
re_sift_context_t sctx;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (mctx->state_log != NULL);
|
|
|
|
|
#endif
|
|
|
|
|
match_last = mctx->match_last;
|
|
|
|
|
halt_node = mctx->last_node;
|
2010-01-22 20:03:56 +00:00
|
|
|
|
|
|
|
|
|
/* Avoid overflow. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
|
|
|
|
|
<= match_last))
|
2010-01-22 20:03:56 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (sifted_states == NULL))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
ret = REG_ESPACE;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
if (dfa->nbackref)
|
|
|
|
|
{
|
|
|
|
|
lim_states = re_malloc (re_dfastate_t *, match_last + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (lim_states == NULL))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
ret = REG_ESPACE;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
memset (lim_states, '\0',
|
|
|
|
|
sizeof (re_dfastate_t *) * (match_last + 1));
|
|
|
|
|
sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
|
2004-11-08 16:07:55 +00:00
|
|
|
|
match_last);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
ret = sift_states_backward (mctx, &sctx);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set_free (&sctx.limits);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
if (sifted_states[0] != NULL || lim_states[0] != NULL)
|
|
|
|
|
break;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
--match_last;
|
|
|
|
|
if (match_last < 0)
|
|
|
|
|
{
|
|
|
|
|
ret = REG_NOMATCH;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
2003-11-26 03:24:15 +00:00
|
|
|
|
} while (mctx->state_log[match_last] == NULL
|
|
|
|
|
|| !mctx->state_log[match_last]->halt);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
halt_node = check_halt_state_context (mctx,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
mctx->state_log[match_last],
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
match_last);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
ret = merge_state_array (dfa, sifted_states, lim_states,
|
|
|
|
|
match_last + 1);
|
|
|
|
|
re_free (lim_states);
|
|
|
|
|
lim_states = NULL;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-11-08 16:07:55 +00:00
|
|
|
|
sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
ret = sift_states_backward (mctx, &sctx);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set_free (&sctx.limits);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
goto free_return;
|
2009-01-08 00:47:30 +00:00
|
|
|
|
if (sifted_states[0] == NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = REG_NOMATCH;
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
re_free (mctx->state_log);
|
|
|
|
|
mctx->state_log = sifted_states;
|
|
|
|
|
sifted_states = NULL;
|
|
|
|
|
mctx->last_node = halt_node;
|
|
|
|
|
mctx->match_last = match_last;
|
|
|
|
|
ret = REG_NOERROR;
|
|
|
|
|
free_return:
|
|
|
|
|
re_free (sifted_states);
|
|
|
|
|
re_free (lim_states);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Acquire an initial state and return it.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
We must select appropriate initial state depending on the context,
|
|
|
|
|
since initial states may have constraints like "\<", "^", etc.. */
|
|
|
|
|
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
static inline re_dfastate_t *
|
2017-12-20 11:47:44 +00:00
|
|
|
|
__attribute__ ((always_inline))
|
2005-10-13 20:08:58 +00:00
|
|
|
|
acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (dfa->init_state->has_constraint)
|
|
|
|
|
{
|
|
|
|
|
unsigned int context;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (IS_WORD_CONTEXT (context))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return dfa->init_state_word;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (IS_ORDINARY_CONTEXT (context))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return dfa->init_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return dfa->init_state_begbuf;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (IS_NEWLINE_CONTEXT (context))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return dfa->init_state_nl;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (IS_BEGBUF_CONTEXT (context))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* It is relatively rare case, then calculate on demand. */
|
2004-03-04 23:28:06 +00:00
|
|
|
|
return re_acquire_state_context (err, dfa,
|
|
|
|
|
dfa->init_state->entrance_nodes,
|
|
|
|
|
context);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* Must not happen? */
|
|
|
|
|
return dfa->init_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return dfa->init_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check whether the regular expression match input string INPUT or not,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
and return the index where the matching end. Return -1 if
|
|
|
|
|
there is no match, and return -2 in case of an error.
|
2002-04-24 21:54:53 +00:00
|
|
|
|
FL_LONGEST_MATCH means we want the POSIX longest matching.
|
2004-02-02 20:10:21 +00:00
|
|
|
|
If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
|
|
|
|
|
next place where we may want to try matching.
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Note that the matcher assumes that the matching starts from the current
|
2002-04-24 21:54:53 +00:00
|
|
|
|
index of the buffer. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
check_matching (re_match_context_t *mctx, bool fl_longest_match,
|
|
|
|
|
Idx *p_match_first)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx match = 0;
|
|
|
|
|
Idx match_last = -1;
|
|
|
|
|
Idx cur_str_idx = re_string_cur_idx (&mctx->input);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_dfastate_t *cur_state;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool at_init_state = p_match_first != NULL;
|
|
|
|
|
Idx next_start_idx = cur_str_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
err = REG_NOERROR;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* An initial state must not be NULL (invalid). */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (cur_state == NULL))
|
2004-03-04 23:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
assert (err == REG_ESPACE);
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
if (mctx->state_log != NULL)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2004-03-04 23:28:06 +00:00
|
|
|
|
mctx->state_log[cur_str_idx] = cur_state;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Check OP_OPEN_SUBEXP in the initial state in case that we use them
|
|
|
|
|
later. E.g. Processing back references. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->nbackref))
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
at_init_state = false;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
return err;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
|
|
|
|
|
if (cur_state->has_backref)
|
|
|
|
|
{
|
|
|
|
|
err = transit_state_bkref (mctx, &cur_state->nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return err;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
}
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* If the RE accepts NULL string. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (cur_state->halt))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (!cur_state->has_constraint
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
|| check_halt_state_context (mctx, cur_state, cur_str_idx))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (!fl_longest_match)
|
|
|
|
|
return cur_str_idx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
match_last = cur_str_idx;
|
|
|
|
|
match = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
while (!re_string_eoi (&mctx->input))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-02-02 20:10:21 +00:00
|
|
|
|
re_dfastate_t *old_state = cur_state;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len)
|
2011-05-28 21:14:30 +00:00
|
|
|
|
&& mctx->input.bufs_len < mctx->input.len)
|
2018-10-15 03:20:08 +00:00
|
|
|
|
|| (__glibc_unlikely (next_char_idx >= mctx->input.valid_len)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
&& mctx->input.valid_len < mctx->input.len))
|
|
|
|
|
{
|
2013-01-29 13:45:15 +00:00
|
|
|
|
err = extend_buffers (mctx, next_char_idx + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-10 15:48:06 +00:00
|
|
|
|
{
|
|
|
|
|
assert (err == REG_ESPACE);
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
2010-01-15 20:03:16 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
cur_state = transit_state (&err, mctx, cur_state);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
if (mctx->state_log != NULL)
|
|
|
|
|
cur_state = merge_state_with_log (&err, mctx, cur_state);
|
2004-02-02 20:10:21 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
if (cur_state == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Reached the invalid state or an error. Try to recover a valid
|
|
|
|
|
state using the state log, if available and if we have not
|
|
|
|
|
already found a valid (even if not the longest) match. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return -2;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
|
|
|
|
|
if (mctx->state_log == NULL
|
|
|
|
|
|| (match && !fl_longest_match)
|
|
|
|
|
|| (cur_state = find_recover_state (&err, mctx)) == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (at_init_state))
|
2004-03-04 23:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
if (old_state == cur_state)
|
2004-11-10 15:48:06 +00:00
|
|
|
|
next_start_idx = next_char_idx;
|
2003-11-20 23:36:40 +00:00
|
|
|
|
else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
at_init_state = false;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
if (cur_state->halt)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Reached a halt state.
|
2002-11-06 20:36:47 +00:00
|
|
|
|
Check the halt state can satisfy the current context. */
|
|
|
|
|
if (!cur_state->has_constraint
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
|| check_halt_state_context (mctx, cur_state,
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
re_string_cur_idx (&mctx->input)))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* We found an appropriate halt state. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
match_last = re_string_cur_idx (&mctx->input);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
match = 1;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
|
|
|
|
|
/* We found a match, do not modify match_first below. */
|
|
|
|
|
p_match_first = NULL;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (!fl_longest_match)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
}
|
2004-02-02 20:10:21 +00:00
|
|
|
|
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (p_match_first)
|
2004-03-04 23:28:06 +00:00
|
|
|
|
*p_match_first += next_start_idx;
|
2004-02-02 20:10:21 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return match_last;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check NODE match the current context. */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static bool
|
|
|
|
|
check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
re_token_type_t type = dfa->nodes[node].type;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
unsigned int constraint = dfa->nodes[node].constraint;
|
|
|
|
|
if (type != END_OF_RE)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (!constraint)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return true;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check the halt state STATE match the current context.
|
|
|
|
|
Return 0 if not match, if the node, STATE has, is a halt node and
|
|
|
|
|
match the context, return the node. */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_halt_state_context (const re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const re_dfastate_t *state, Idx idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int context;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (state->halt);
|
|
|
|
|
#endif
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, idx, mctx->eflags);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (i = 0; i < state->nodes.nelem; ++i)
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return state->nodes.elems[i];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
|
|
|
|
|
corresponding to the DFA).
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Return the destination node, and update EPS_VIA_NODES;
|
|
|
|
|
return -1 in case of errors. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
|
|
|
|
proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
|
|
|
|
|
Idx *pidx, Idx node, re_node_set *eps_via_nodes,
|
2005-10-13 20:08:58 +00:00
|
|
|
|
struct re_fail_stack_t *fs)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
|
|
|
|
bool ok;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (IS_EPSILON_NODE (dfa->nodes[node].type))
|
|
|
|
|
{
|
2002-10-12 08:34:26 +00:00
|
|
|
|
re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
re_node_set *edests = &dfa->edests[node];
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dest_node;
|
|
|
|
|
ok = re_node_set_insert (eps_via_nodes, node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2003-12-29 17:59:41 +00:00
|
|
|
|
return -2;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Pick up a valid destination, or return -1 if none
|
|
|
|
|
is found. */
|
2004-12-10 04:37:58 +00:00
|
|
|
|
for (dest_node = -1, i = 0; i < edests->nelem; ++i)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx candidate = edests->elems[i];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (!re_node_set_contains (cur_nodes, candidate))
|
|
|
|
|
continue;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (dest_node == -1)
|
2004-12-10 04:37:58 +00:00
|
|
|
|
dest_node = candidate;
|
|
|
|
|
|
2010-01-15 20:03:16 +00:00
|
|
|
|
else
|
2004-12-10 04:37:58 +00:00
|
|
|
|
{
|
|
|
|
|
/* In order to avoid infinite loop like "(a*)*", return the second
|
2010-01-15 20:03:16 +00:00
|
|
|
|
epsilon-transition if the first was already considered. */
|
2004-12-10 04:37:58 +00:00
|
|
|
|
if (re_node_set_contains (eps_via_nodes, dest_node))
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return candidate;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
|
|
|
|
|
/* Otherwise, push the second epsilon-transition on the fail stack. */
|
|
|
|
|
else if (fs != NULL
|
|
|
|
|
&& push_fail_stack (fs, *pidx, candidate, nregs, regs,
|
2010-01-15 20:03:16 +00:00
|
|
|
|
eps_via_nodes))
|
2004-12-10 04:37:58 +00:00
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|
/* We know we are going to exit. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dest_node;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx naccepted = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[node].type;
|
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
if (dfa->nodes[node].accept_mb)
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
else
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
if (type == OP_BACK_REF)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
|
|
|
|
|
if (fs != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (naccepted)
|
|
|
|
|
{
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
char *buf = (char *) re_string_get_buffer (&mctx->input);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
|
|
|
|
|
naccepted) != 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (naccepted == 0)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dest_node;
|
|
|
|
|
ok = re_node_set_insert (eps_via_nodes, node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return -2;
|
|
|
|
|
dest_node = dfa->edests[node].elems[0];
|
|
|
|
|
if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
|
|
|
|
|
dest_node))
|
|
|
|
|
return dest_node;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (naccepted != 0
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
|| check_node_accept (mctx, dfa->nodes + node, *pidx))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dest_node = dfa->nexts[node];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
*pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted;
|
|
|
|
|
if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
|
|
|
|
|
|| !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
|
|
|
|
|
dest_node)))
|
|
|
|
|
return -1;
|
|
|
|
|
re_node_set_empty (eps_via_nodes);
|
|
|
|
|
return dest_node;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-09-30 22:01:05 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
|
|
|
|
|
Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
|
2002-09-30 22:01:05 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx num = fs->num++;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
if (fs->num == fs->alloc)
|
|
|
|
|
{
|
2002-11-06 19:57:50 +00:00
|
|
|
|
struct re_fail_stack_ent_t *new_array;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
|
|
|
|
|
fs->alloc * 2);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
if (new_array == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
2003-12-29 17:59:41 +00:00
|
|
|
|
fs->alloc *= 2;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
fs->stack = new_array;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
}
|
|
|
|
|
fs->stack[num].idx = str_idx;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
fs->stack[num].node = dest_node;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
fs->stack[num].regs = re_malloc (regmatch_t, nregs);
|
2003-12-28 23:33:48 +00:00
|
|
|
|
if (fs->stack[num].regs == NULL)
|
|
|
|
|
return REG_ESPACE;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
|
|
|
|
|
err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
|
|
|
|
pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
|
2005-10-13 20:08:58 +00:00
|
|
|
|
regmatch_t *regs, re_node_set *eps_via_nodes)
|
2002-09-30 22:01:05 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx num = --fs->num;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
assert (num >= 0);
|
2003-12-29 17:59:41 +00:00
|
|
|
|
*pidx = fs->stack[num].idx;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
|
|
|
|
|
re_node_set_free (eps_via_nodes);
|
2002-10-12 08:34:26 +00:00
|
|
|
|
re_free (fs->stack[num].regs);
|
2002-09-30 22:01:05 +00:00
|
|
|
|
*eps_via_nodes = fs->stack[num].eps_via_nodes;
|
|
|
|
|
return fs->stack[num].node;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the positions where the subexpressions are starts/ends to registers
|
|
|
|
|
PMATCH.
|
|
|
|
|
Note: We assume that pmatch[0] is already set, and
|
2003-11-26 03:24:15 +00:00
|
|
|
|
pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regmatch_t *pmatch, bool fl_backtrack)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const re_dfa_t *dfa = preg->buffer;
|
|
|
|
|
Idx idx, cur_node;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set eps_via_nodes;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
struct re_fail_stack_t *fs;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
struct re_fail_stack_t fs_body = { 0, 2, NULL };
|
|
|
|
|
regmatch_t *prev_idx_match;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool prev_idx_match_malloced = false;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (nmatch > 1);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
assert (mctx->state_log != NULL);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif
|
2002-09-30 22:01:05 +00:00
|
|
|
|
if (fl_backtrack)
|
|
|
|
|
{
|
|
|
|
|
fs = &fs_body;
|
|
|
|
|
fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc);
|
2003-12-27 23:40:06 +00:00
|
|
|
|
if (fs->stack == NULL)
|
|
|
|
|
return REG_ESPACE;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fs = NULL;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
cur_node = dfa->init_node;
|
|
|
|
|
re_node_set_init_empty (&eps_via_nodes);
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
if (__libc_use_alloca (nmatch * sizeof (regmatch_t)))
|
|
|
|
|
prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prev_idx_match = re_malloc (regmatch_t, nmatch);
|
|
|
|
|
if (prev_idx_match == NULL)
|
|
|
|
|
{
|
|
|
|
|
free_fail_stack_return (fs);
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
prev_idx_match_malloced = true;
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
}
|
2005-01-27 19:08:10 +00:00
|
|
|
|
memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
|
|
|
|
|
{
|
2005-01-27 19:08:10 +00:00
|
|
|
|
update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-09-30 22:01:05 +00:00
|
|
|
|
if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx reg_idx;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (fs)
|
|
|
|
|
{
|
|
|
|
|
for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
|
|
|
|
|
if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
|
|
|
|
|
break;
|
|
|
|
|
if (reg_idx == nmatch)
|
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&eps_via_nodes);
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
if (prev_idx_match_malloced)
|
|
|
|
|
re_free (prev_idx_match);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return free_fail_stack_return (fs);
|
|
|
|
|
}
|
|
|
|
|
cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
|
|
|
|
|
&eps_via_nodes);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&eps_via_nodes);
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
if (prev_idx_match_malloced)
|
|
|
|
|
re_free (prev_idx_match);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Proceed to next node. */
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
&eps_via_nodes, fs);
|
2002-09-30 22:01:05 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (cur_node < 0))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (cur_node == -2))
|
2003-12-29 17:59:41 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&eps_via_nodes);
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
if (prev_idx_match_malloced)
|
|
|
|
|
re_free (prev_idx_match);
|
2003-12-29 17:59:41 +00:00
|
|
|
|
free_fail_stack_return (fs);
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (fs)
|
|
|
|
|
cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
|
|
|
|
|
&eps_via_nodes);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&eps_via_nodes);
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
if (prev_idx_match_malloced)
|
|
|
|
|
re_free (prev_idx_match);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_NOMATCH;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
re_node_set_free (&eps_via_nodes);
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
if (prev_idx_match_malloced)
|
|
|
|
|
re_free (prev_idx_match);
|
2002-10-12 08:34:26 +00:00
|
|
|
|
return free_fail_stack_return (fs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
free_fail_stack_return (struct re_fail_stack_t *fs)
|
2002-10-12 08:34:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (fs)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx fs_idx;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
for (fs_idx = 0; fs_idx < fs->num; ++fs_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&fs->stack[fs_idx].eps_via_nodes);
|
|
|
|
|
re_free (fs->stack[fs_idx].regs);
|
|
|
|
|
}
|
2002-10-12 08:34:26 +00:00
|
|
|
|
re_free (fs->stack);
|
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-10 23:09:16 +00:00
|
|
|
|
static void
|
2005-10-13 20:08:58 +00:00
|
|
|
|
update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
|
2002-07-10 23:09:16 +00:00
|
|
|
|
{
|
|
|
|
|
int type = dfa->nodes[cur_node].type;
|
|
|
|
|
if (type == OP_OPEN_SUBEXP)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-07-10 23:09:16 +00:00
|
|
|
|
/* We are at the first node of this sub expression. */
|
2003-12-27 23:40:06 +00:00
|
|
|
|
if (reg_num < nmatch)
|
|
|
|
|
{
|
|
|
|
|
pmatch[reg_num].rm_so = cur_idx;
|
|
|
|
|
pmatch[reg_num].rm_eo = -1;
|
|
|
|
|
}
|
2002-07-10 23:09:16 +00:00
|
|
|
|
}
|
|
|
|
|
else if (type == OP_CLOSE_SUBEXP)
|
2003-12-27 23:40:06 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
if (reg_num < nmatch)
|
|
|
|
|
{
|
|
|
|
|
/* We are at the last node of this sub expression. */
|
|
|
|
|
if (pmatch[reg_num].rm_so < cur_idx)
|
|
|
|
|
{
|
|
|
|
|
pmatch[reg_num].rm_eo = cur_idx;
|
|
|
|
|
/* This is a non-empty match or we are not inside an optional
|
|
|
|
|
subexpression. Accept this right away. */
|
|
|
|
|
memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dfa->nodes[cur_node].opt_subexp
|
|
|
|
|
&& prev_idx_match[reg_num].rm_so != -1)
|
|
|
|
|
/* We transited through an empty match for an optional
|
|
|
|
|
subexpression, like (a?)*, and this is not the subexp's
|
|
|
|
|
first match. Copy back the old content of the registers
|
|
|
|
|
so that matches of an inner subexpression are undone as
|
|
|
|
|
well, like in ((a?))*. */
|
|
|
|
|
memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch);
|
|
|
|
|
else
|
|
|
|
|
/* We completed a subexpression, but it may be part of
|
|
|
|
|
an optional one, so do not update PREV_IDX_MATCH. */
|
|
|
|
|
pmatch[reg_num].rm_eo = cur_idx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0
|
2002-04-24 21:54:53 +00:00
|
|
|
|
and sift the nodes in each states according to the following rules.
|
|
|
|
|
Updated state_log will be wrote to STATE_LOG.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Rules: We throw away the Node 'a' in the STATE_LOG[STR_IDX] if...
|
2002-02-26 19:06:03 +00:00
|
|
|
|
1. When STR_IDX == MATCH_LAST(the last index in the state_log):
|
2017-12-20 11:47:44 +00:00
|
|
|
|
If 'a' isn't the LAST_NODE and 'a' can't epsilon transit to
|
|
|
|
|
the LAST_NODE, we throw away the node 'a'.
|
|
|
|
|
2. When 0 <= STR_IDX < MATCH_LAST and 'a' accepts
|
|
|
|
|
string 's' and transit to 'b':
|
2002-11-06 20:36:47 +00:00
|
|
|
|
i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw
|
2017-12-20 11:47:44 +00:00
|
|
|
|
away the node 'a'.
|
2002-11-06 20:36:47 +00:00
|
|
|
|
ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is
|
2017-12-20 11:47:44 +00:00
|
|
|
|
thrown away, we throw away the node 'a'.
|
2003-10-06 23:44:15 +00:00
|
|
|
|
3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b':
|
2002-11-06 20:36:47 +00:00
|
|
|
|
i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the
|
2017-12-20 11:47:44 +00:00
|
|
|
|
node 'a'.
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
we throw away the node 'a'. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#define STATE_NODE_CONTAINS(state,node) \
|
|
|
|
|
((state) != NULL && re_node_set_contains (&(state)->nodes, node))
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
int null_cnt = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx = sctx->last_str_idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
re_node_set cur_dest;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2002-04-24 21:54:53 +00:00
|
|
|
|
assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Build sifted state_log[str_idx]. It has the nodes which can epsilon
|
|
|
|
|
transit to the last_node and the last_node itself. */
|
2002-09-28 05:28:44 +00:00
|
|
|
|
err = re_node_set_init_1 (&cur_dest, sctx->last_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return err;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
goto free_return;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Then check each states in the state_log. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
while (str_idx > 0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
/* Update counters. */
|
2002-09-28 05:28:44 +00:00
|
|
|
|
null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0;
|
|
|
|
|
if (null_cnt > mctx->max_mb_elem_len)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
memset (sctx->sifted_states, '\0',
|
|
|
|
|
sizeof (re_dfastate_t *) * str_idx);
|
|
|
|
|
re_node_set_free (&cur_dest);
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
re_node_set_empty (&cur_dest);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
--str_idx;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (mctx->state_log[str_idx])
|
|
|
|
|
{
|
|
|
|
|
err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
goto free_return;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
/* Add all the nodes which satisfy the following conditions:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
- It can epsilon transit to a node in CUR_DEST.
|
|
|
|
|
- It is in CUR_SRC.
|
|
|
|
|
And update state_log. */
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto free_return;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
err = REG_NOERROR;
|
|
|
|
|
free_return:
|
2002-09-28 05:28:44 +00:00
|
|
|
|
re_node_set_free (&cur_dest);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx, re_node_set *cur_dest)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
|
|
|
|
const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
|
|
|
|
/* Then build the next sifted state.
|
2017-12-20 11:47:44 +00:00
|
|
|
|
We build the next sifted state on 'cur_dest', and update
|
|
|
|
|
'sifted_states[str_idx]' with 'cur_dest'.
|
2004-11-08 22:49:44 +00:00
|
|
|
|
Note:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
'cur_dest' is the sifted state from 'state_log[str_idx + 1]'.
|
|
|
|
|
'cur_src' points the node_set of the old 'state_log[str_idx]'
|
2004-12-10 04:37:58 +00:00
|
|
|
|
(with the epsilon nodes pre-filtered out). */
|
2004-11-08 22:49:44 +00:00
|
|
|
|
for (i = 0; i < cur_src->nelem; i++)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx prev_node = cur_src->elems[i];
|
2004-11-08 22:49:44 +00:00
|
|
|
|
int naccepted = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool ok;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#ifdef DEBUG
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[prev_node].type;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
assert (!IS_EPSILON_NODE (type));
|
|
|
|
|
#endif
|
2004-11-08 22:49:44 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* If the node may accept "multi byte". */
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
if (dfa->nodes[prev_node].accept_mb)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
|
|
|
|
|
str_idx, sctx->last_str_idx);
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
|
|
|
|
/* We don't check backreferences here.
|
|
|
|
|
See update_cur_sifted_state(). */
|
|
|
|
|
if (!naccepted
|
|
|
|
|
&& check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
|
|
|
|
|
&& STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1],
|
|
|
|
|
dfa->nexts[prev_node]))
|
|
|
|
|
naccepted = 1;
|
|
|
|
|
|
|
|
|
|
if (naccepted == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (sctx->limits.nelem)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx to_idx = str_idx + naccepted;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (check_dst_limits (mctx, &sctx->limits,
|
|
|
|
|
dfa->nexts[prev_node], to_idx,
|
|
|
|
|
prev_node, str_idx))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (cur_dest, prev_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Helper functions. */
|
|
|
|
|
|
2003-06-13 21:05:42 +00:00
|
|
|
|
static reg_errcode_t
|
2017-12-20 11:47:44 +00:00
|
|
|
|
clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx top = mctx->state_log_top;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2011-05-28 21:14:30 +00:00
|
|
|
|
if ((next_state_log_idx >= mctx->input.bufs_len
|
|
|
|
|
&& mctx->input.bufs_len < mctx->input.len)
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
|| (next_state_log_idx >= mctx->input.valid_len
|
|
|
|
|
&& mctx->input.valid_len < mctx->input.len))
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
2013-01-29 13:45:15 +00:00
|
|
|
|
err = extend_buffers (mctx, next_state_log_idx + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (top < next_state_log_idx)
|
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
memset (mctx->state_log + top + 1, '\0',
|
2002-11-06 20:36:47 +00:00
|
|
|
|
sizeof (re_dfastate_t *) * (next_state_log_idx - top));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mctx->state_log_top = next_state_log_idx;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-06 19:57:50 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfastate_t **src, Idx num)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx st_idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
reg_errcode_t err;
|
|
|
|
|
for (st_idx = 0; st_idx < num; ++st_idx)
|
|
|
|
|
{
|
|
|
|
|
if (dst[st_idx] == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dst[st_idx] = src[st_idx];
|
2002-09-28 05:28:44 +00:00
|
|
|
|
else if (src[st_idx] != NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set merged_set;
|
|
|
|
|
err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
|
|
|
|
|
&src[st_idx]->nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
|
|
|
|
dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
|
|
|
|
|
re_node_set_free (&merged_set);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
update_cur_sifted_state (const re_match_context_t *mctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_sift_context_t *sctx, Idx str_idx,
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set *dest_nodes)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2005-09-30 15:46:19 +00:00
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
const re_node_set *candidates;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
candidates = ((mctx->state_log[str_idx] == NULL) ? NULL
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: &mctx->state_log[str_idx]->nodes);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (dest_nodes->nelem == 0)
|
|
|
|
|
sctx->sifted_states[str_idx] = NULL;
|
|
|
|
|
else
|
2002-10-12 08:34:26 +00:00
|
|
|
|
{
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (candidates)
|
|
|
|
|
{
|
|
|
|
|
/* At first, add the nodes which can epsilon transit to a node in
|
|
|
|
|
DEST_NODE. */
|
|
|
|
|
err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
return err;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
/* Then, check the limitations in the current sift_context. */
|
|
|
|
|
if (sctx->limits.nelem)
|
|
|
|
|
{
|
|
|
|
|
err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
|
|
|
|
|
mctx->bkref_ents, str_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (candidates && mctx->state_log[str_idx]->has_backref)
|
2002-09-28 05:28:44 +00:00
|
|
|
|
{
|
2004-11-08 16:07:55 +00:00
|
|
|
|
err = sift_states_bkref (mctx, sctx, str_idx, candidates);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
|
|
|
|
|
const re_node_set *candidates)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-12-10 04:37:58 +00:00
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
2004-12-10 04:37:58 +00:00
|
|
|
|
re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-09-28 05:28:44 +00:00
|
|
|
|
return err;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
|
|
|
|
|
if (!state->inveclosure.alloc)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-12-10 04:37:58 +00:00
|
|
|
|
err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return REG_ESPACE;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
for (i = 0; i < dest_nodes->nelem; i++)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
{
|
|
|
|
|
err = re_node_set_merge (&state->inveclosure,
|
|
|
|
|
dfa->inveclosures + dest_nodes->elems[i]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
2004-12-10 04:37:58 +00:00
|
|
|
|
return re_node_set_add_intersect (dest_nodes, candidates,
|
|
|
|
|
&state->inveclosure);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
static reg_errcode_t
|
2017-12-20 11:47:44 +00:00
|
|
|
|
sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
|
2005-10-13 20:08:58 +00:00
|
|
|
|
const re_node_set *candidates)
|
2002-09-28 05:28:44 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx ecl_idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
reg_errcode_t err;
|
|
|
|
|
re_node_set *inv_eclosure = dfa->inveclosures + node;
|
|
|
|
|
re_node_set except_nodes;
|
|
|
|
|
re_node_set_init_empty (&except_nodes);
|
|
|
|
|
for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node = inv_eclosure->elems[ecl_idx];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (cur_node == node)
|
|
|
|
|
continue;
|
|
|
|
|
if (IS_EPSILON_NODE (dfa->nodes[cur_node].type))
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx edst1 = dfa->edests[cur_node].elems[0];
|
|
|
|
|
Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
? dfa->edests[cur_node].elems[1] : -1);
|
|
|
|
|
if ((!re_node_set_contains (inv_eclosure, edst1)
|
|
|
|
|
&& re_node_set_contains (dest_nodes, edst1))
|
|
|
|
|
|| (edst2 > 0
|
|
|
|
|
&& !re_node_set_contains (inv_eclosure, edst2)
|
|
|
|
|
&& re_node_set_contains (dest_nodes, edst2)))
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_add_intersect (&except_nodes, candidates,
|
|
|
|
|
dfa->inveclosures + cur_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&except_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node = inv_eclosure->elems[ecl_idx];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (!re_node_set_contains (&except_nodes, cur_node))
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set_remove_at (dest_nodes, idx);
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
re_node_set_free (&except_nodes);
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static bool
|
|
|
|
|
check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
|
|
|
|
|
Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
|
2002-09-30 22:01:05 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx lim_idx, src_pos, dst_pos;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx);
|
|
|
|
|
Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx);
|
2002-09-30 22:01:05 +00:00
|
|
|
|
for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_idx;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
struct re_backref_cache_entry *ent;
|
|
|
|
|
ent = mctx->bkref_ents + limits->elems[lim_idx];
|
2004-12-06 03:03:01 +00:00
|
|
|
|
subexp_idx = dfa->nodes[ent->node].opr.idx;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
|
2004-11-08 22:49:44 +00:00
|
|
|
|
subexp_idx, dst_node, dst_idx,
|
|
|
|
|
dst_bkref_idx);
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
|
2004-11-08 22:49:44 +00:00
|
|
|
|
subexp_idx, src_node, src_idx,
|
|
|
|
|
src_bkref_idx);
|
2002-09-30 22:01:05 +00:00
|
|
|
|
|
|
|
|
|
/* In case of:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
<src> <dst> ( <subexp> )
|
|
|
|
|
( <subexp> ) <src> <dst>
|
|
|
|
|
( <subexp1> <src> <subexp2> <dst> <subexp3> ) */
|
2002-09-30 22:01:05 +00:00
|
|
|
|
if (src_pos == dst_pos)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue; /* This is unrelated limitation. */
|
2002-09-30 22:01:05 +00:00
|
|
|
|
else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return true;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_idx, Idx from_node, Idx bkref_idx)
|
2002-09-30 22:01:05 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
|
|
|
|
const re_node_set *eclosures = dfa->eclosures + from_node;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx;
|
2003-10-06 23:44:15 +00:00
|
|
|
|
|
|
|
|
|
/* Else, we are on the boundary: examine the nodes on the epsilon
|
|
|
|
|
closure. */
|
2003-12-22 06:52:35 +00:00
|
|
|
|
for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node = eclosures->elems[node_idx];
|
2003-10-06 23:44:15 +00:00
|
|
|
|
switch (dfa->nodes[node].type)
|
|
|
|
|
{
|
|
|
|
|
case OP_BACK_REF:
|
2004-12-06 03:03:01 +00:00
|
|
|
|
if (bkref_idx != -1)
|
|
|
|
|
{
|
|
|
|
|
struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
|
|
|
|
|
do
|
2010-01-15 20:03:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dst;
|
|
|
|
|
int cpos;
|
2003-10-06 23:44:15 +00:00
|
|
|
|
|
2004-12-06 03:03:01 +00:00
|
|
|
|
if (ent->node != node)
|
|
|
|
|
continue;
|
2003-10-06 23:44:15 +00:00
|
|
|
|
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
if (subexp_idx < BITSET_WORD_BITS
|
|
|
|
|
&& !(ent->eps_reachable_subexps_map
|
|
|
|
|
& ((bitset_word_t) 1 << subexp_idx)))
|
2004-12-06 03:03:01 +00:00
|
|
|
|
continue;
|
2003-10-06 23:44:15 +00:00
|
|
|
|
|
2004-12-06 03:03:01 +00:00
|
|
|
|
/* Recurse trying to reach the OP_OPEN_SUBEXP and
|
|
|
|
|
OP_CLOSE_SUBEXP cases below. But, if the
|
|
|
|
|
destination node is the same node as the source
|
|
|
|
|
node, don't recurse because it would cause an
|
|
|
|
|
infinite loop: a regex that exhibits this behavior
|
|
|
|
|
is ()\1*\1* */
|
|
|
|
|
dst = dfa->edests[node].elems[0];
|
|
|
|
|
if (dst == from_node)
|
|
|
|
|
{
|
|
|
|
|
if (boundaries & 1)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return -1;
|
2004-12-06 03:03:01 +00:00
|
|
|
|
else /* if (boundaries & 2) */
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return 0;
|
2004-12-06 03:03:01 +00:00
|
|
|
|
}
|
2004-11-12 09:45:05 +00:00
|
|
|
|
|
2004-12-06 03:03:01 +00:00
|
|
|
|
cpos =
|
|
|
|
|
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;
|
|
|
|
|
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
if (subexp_idx < BITSET_WORD_BITS)
|
|
|
|
|
ent->eps_reachable_subexps_map
|
|
|
|
|
&= ~((bitset_word_t) 1 << subexp_idx);
|
2010-01-15 20:03:16 +00:00
|
|
|
|
}
|
2004-12-06 03:03:01 +00:00
|
|
|
|
while (ent++->more);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
|
2003-10-06 23:44:15 +00:00
|
|
|
|
case OP_OPEN_SUBEXP:
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
|
2003-10-06 23:44:15 +00:00
|
|
|
|
return -1;
|
|
|
|
|
break;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
|
2003-10-06 23:44:15 +00:00
|
|
|
|
case OP_CLOSE_SUBEXP:
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx)
|
2003-10-06 23:44:15 +00:00
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-09-30 22:01:05 +00:00
|
|
|
|
}
|
2003-10-06 23:44:15 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
return (boundaries & 2) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2017-12-20 11:47:44 +00:00
|
|
|
|
check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
|
|
|
|
|
Idx subexp_idx, Idx from_node, Idx str_idx,
|
|
|
|
|
Idx bkref_idx)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
{
|
|
|
|
|
struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
|
|
|
|
|
int boundaries;
|
|
|
|
|
|
|
|
|
|
/* If we are outside the range of the subexpression, return -1 or 1. */
|
|
|
|
|
if (str_idx < lim->subexp_from)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (lim->subexp_to < str_idx)
|
2003-10-06 23:44:15 +00:00
|
|
|
|
return 1;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
|
|
|
|
/* If we are within the subexpression, return 0. */
|
|
|
|
|
boundaries = (str_idx == lim->subexp_from);
|
|
|
|
|
boundaries |= (str_idx == lim->subexp_to) << 1;
|
|
|
|
|
if (boundaries == 0)
|
2003-10-06 23:44:15 +00:00
|
|
|
|
return 0;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
|
|
|
|
/* Else, examine epsilon closure. */
|
|
|
|
|
return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
|
|
|
|
|
from_node, bkref_idx);
|
2002-09-30 22:01:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
/* Check the limitations of sub expressions LIMITS, and remove the nodes
|
|
|
|
|
which are against limitations from DEST_NODES. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
|
|
|
|
|
const re_node_set *candidates, re_node_set *limits,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
struct re_backref_cache_entry *bkref_ents, Idx str_idx)
|
2002-09-28 05:28:44 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx, lim_idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
|
|
|
|
for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
struct re_backref_cache_entry *ent;
|
|
|
|
|
ent = bkref_ents + limits->elems[lim_idx];
|
|
|
|
|
|
|
|
|
|
if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue; /* This is unrelated limitation. */
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
2004-12-06 03:03:01 +00:00
|
|
|
|
subexp_idx = dfa->nodes[ent->node].opr.idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
if (ent->subexp_to == str_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx ops_node = -1;
|
|
|
|
|
Idx cls_node = -1;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node = dest_nodes->elems[node_idx];
|
2003-11-27 05:32:46 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[node].type;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (type == OP_OPEN_SUBEXP
|
|
|
|
|
&& subexp_idx == dfa->nodes[node].opr.idx)
|
|
|
|
|
ops_node = node;
|
|
|
|
|
else if (type == OP_CLOSE_SUBEXP
|
|
|
|
|
&& subexp_idx == dfa->nodes[node].opr.idx)
|
|
|
|
|
cls_node = node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check the limitation of the open subexpression. */
|
|
|
|
|
/* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
|
|
|
|
|
if (ops_node >= 0)
|
|
|
|
|
{
|
2003-11-27 05:32:46 +00:00
|
|
|
|
err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
|
|
|
|
|
candidates);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2003-11-27 05:32:46 +00:00
|
|
|
|
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* Check the limitation of the close subexpression. */
|
2003-11-27 05:32:46 +00:00
|
|
|
|
if (cls_node >= 0)
|
|
|
|
|
for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node = dest_nodes->elems[node_idx];
|
2003-11-27 05:32:46 +00:00
|
|
|
|
if (!re_node_set_contains (dfa->inveclosures + node,
|
|
|
|
|
cls_node)
|
|
|
|
|
&& !re_node_set_contains (dfa->eclosures + node,
|
|
|
|
|
cls_node))
|
|
|
|
|
{
|
|
|
|
|
/* It is against this limitation.
|
|
|
|
|
Remove it form the current sifted state. */
|
|
|
|
|
err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
|
|
|
|
|
candidates);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2003-11-27 05:32:46 +00:00
|
|
|
|
return err;
|
|
|
|
|
--node_idx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
else /* (ent->subexp_to != str_idx) */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node = dest_nodes->elems[node_idx];
|
2003-11-27 05:32:46 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[node].type;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP)
|
|
|
|
|
{
|
|
|
|
|
if (subexp_idx != dfa->nodes[node].opr.idx)
|
|
|
|
|
continue;
|
2004-12-06 03:03:01 +00:00
|
|
|
|
/* It is against this limitation.
|
|
|
|
|
Remove it form the current sifted state. */
|
|
|
|
|
err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
|
|
|
|
|
candidates);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-12-06 03:03:01 +00:00
|
|
|
|
return err;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx, const re_node_set *candidates)
|
2002-09-28 05:28:44 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx, node;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
re_sift_context_t local_sctx;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
|
|
|
|
if (first_idx == -1)
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
|
|
|
|
|
|
|
|
|
|
for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx enabled_idx;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
re_token_type_t type;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
struct re_backref_cache_entry *entry;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
node = candidates->elems[node_idx];
|
|
|
|
|
type = dfa->nodes[node].type;
|
|
|
|
|
/* Avoid infinite loop for the REs like "()\1+". */
|
|
|
|
|
if (node == sctx->last_node && str_idx == sctx->last_str_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (type != OP_BACK_REF)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
entry = mctx->bkref_ents + first_idx;
|
|
|
|
|
enabled_idx = first_idx;
|
|
|
|
|
do
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_len;
|
|
|
|
|
Idx to_idx;
|
|
|
|
|
Idx dst_node;
|
|
|
|
|
bool ok;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
re_dfastate_t *cur_state;
|
|
|
|
|
|
|
|
|
|
if (entry->node != node)
|
|
|
|
|
continue;
|
|
|
|
|
subexp_len = entry->subexp_to - entry->subexp_from;
|
|
|
|
|
to_idx = str_idx + subexp_len;
|
|
|
|
|
dst_node = (subexp_len ? dfa->nexts[node]
|
|
|
|
|
: dfa->edests[node].elems[0]);
|
|
|
|
|
|
|
|
|
|
if (to_idx > sctx->last_str_idx
|
|
|
|
|
|| sctx->sifted_states[to_idx] == NULL
|
|
|
|
|
|| !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node)
|
|
|
|
|
|| check_dst_limits (mctx, &sctx->limits, node,
|
|
|
|
|
str_idx, dst_node, to_idx))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (local_sctx.sifted_states == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2004-11-08 22:49:44 +00:00
|
|
|
|
local_sctx = *sctx;
|
|
|
|
|
err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
local_sctx.last_node = node;
|
|
|
|
|
local_sctx.last_str_idx = str_idx;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
{
|
|
|
|
|
err = REG_ESPACE;
|
|
|
|
|
goto free_return;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
cur_state = local_sctx.sifted_states[str_idx];
|
|
|
|
|
err = sift_states_backward (mctx, &local_sctx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
if (sctx->limited_states != NULL)
|
|
|
|
|
{
|
|
|
|
|
err = merge_state_array (dfa, sctx->limited_states,
|
|
|
|
|
local_sctx.sifted_states,
|
|
|
|
|
str_idx + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
local_sctx.sifted_states[str_idx] = cur_state;
|
|
|
|
|
re_node_set_remove (&local_sctx.limits, enabled_idx);
|
|
|
|
|
|
|
|
|
|
/* mctx->bkref_ents may have changed, reload the pointer. */
|
2010-01-15 20:03:16 +00:00
|
|
|
|
entry = mctx->bkref_ents + enabled_idx;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
while (enabled_idx++, entry++->more);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
err = REG_NOERROR;
|
|
|
|
|
free_return:
|
2002-09-28 05:28:44 +00:00
|
|
|
|
if (local_sctx.sifted_states != NULL)
|
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&local_sctx.limits);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return err;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
static int
|
2005-10-13 20:08:58 +00:00
|
|
|
|
sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx, Idx str_idx, Idx max_str_idx)
|
2002-09-28 05:28:44 +00:00
|
|
|
|
{
|
2005-09-07 05:41:42 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
int naccepted;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Check the node can accept "multi byte". */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
|
|
|
|
|
!STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dfa->nexts[node_idx]))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* The node can't accept the "multi byte", or the
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
destination was already thrown away, then the node
|
2017-12-20 11:47:44 +00:00
|
|
|
|
could't accept the current input "multi byte". */
|
2002-09-28 05:28:44 +00:00
|
|
|
|
naccepted = 0;
|
|
|
|
|
/* Otherwise, it is sure that the node could accept
|
2017-12-20 11:47:44 +00:00
|
|
|
|
'naccepted' bytes input. */
|
2002-09-28 05:28:44 +00:00
|
|
|
|
return naccepted;
|
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Functions for state transition. */
|
|
|
|
|
|
|
|
|
|
/* Return the next state to which the current state STATE will transit by
|
|
|
|
|
accepting the current input byte, and update STATE_LOG if necessary.
|
|
|
|
|
If STATE can accept a multibyte char/collating element/back reference
|
|
|
|
|
update the destination of STATE_LOG. */
|
|
|
|
|
|
|
|
|
|
static re_dfastate_t *
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
transit_state (reg_errcode_t *err, re_match_context_t *mctx,
|
|
|
|
|
re_dfastate_t *state)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-03-05 10:54:16 +00:00
|
|
|
|
re_dfastate_t **trtable;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned char ch;
|
|
|
|
|
|
2004-11-10 15:48:06 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* If the current state can accept multibyte. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (state->accept_mb))
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
2004-11-10 15:48:06 +00:00
|
|
|
|
*err = transit_state_mb (mctx, state);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return NULL;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Then decide the next state with the single byte. */
|
2004-12-27 16:44:39 +00:00
|
|
|
|
#if 0
|
|
|
|
|
if (0)
|
|
|
|
|
/* don't use transition table */
|
|
|
|
|
return transit_state_sb (err, mctx, state);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Use transition table */
|
|
|
|
|
ch = re_string_fetch_byte (&mctx->input);
|
|
|
|
|
for (;;)
|
2004-03-04 23:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
trtable = state->trtable;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (trtable != NULL))
|
2004-12-27 16:44:39 +00:00
|
|
|
|
return trtable[ch];
|
|
|
|
|
|
|
|
|
|
trtable = state->word_trtable;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (trtable != NULL))
|
2010-01-15 20:03:16 +00:00
|
|
|
|
{
|
2004-03-04 23:28:06 +00:00
|
|
|
|
unsigned int context;
|
|
|
|
|
context
|
|
|
|
|
= re_string_context_at (&mctx->input,
|
|
|
|
|
re_string_cur_idx (&mctx->input) - 1,
|
|
|
|
|
mctx->eflags);
|
|
|
|
|
if (IS_WORD_CONTEXT (context))
|
|
|
|
|
return trtable[ch + SBC_MAX];
|
2003-11-20 23:36:40 +00:00
|
|
|
|
else
|
2004-03-04 23:28:06 +00:00
|
|
|
|
return trtable[ch];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2004-12-27 16:44:39 +00:00
|
|
|
|
|
|
|
|
|
if (!build_trtable (mctx->dfa, state))
|
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Retry, we now have a transition table. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2004-03-04 23:28:06 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Update the state_log if we need */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static re_dfastate_t *
|
2005-10-13 20:08:58 +00:00
|
|
|
|
merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
|
|
|
|
|
re_dfastate_t *next_state)
|
2004-03-05 10:54:16 +00:00
|
|
|
|
{
|
2005-09-07 05:41:42 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_idx = re_string_cur_idx (&mctx->input);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
|
|
|
|
|
if (cur_idx > mctx->state_log_top)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-03-04 23:28:06 +00:00
|
|
|
|
mctx->state_log[cur_idx] = next_state;
|
|
|
|
|
mctx->state_log_top = cur_idx;
|
|
|
|
|
}
|
|
|
|
|
else if (mctx->state_log[cur_idx] == 0)
|
|
|
|
|
{
|
|
|
|
|
mctx->state_log[cur_idx] = next_state;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
re_dfastate_t *pstate;
|
|
|
|
|
unsigned int context;
|
|
|
|
|
re_node_set next_nodes, *log_nodes, *table_nodes = NULL;
|
|
|
|
|
/* If (state_log[cur_idx] != 0), it implies that cur_idx is
|
2010-01-15 20:03:16 +00:00
|
|
|
|
the destination of a multibyte char/collating element/
|
|
|
|
|
back reference. Then the next state is the union set of
|
|
|
|
|
these destinations and the results of the transition table. */
|
2004-03-04 23:28:06 +00:00
|
|
|
|
pstate = mctx->state_log[cur_idx];
|
|
|
|
|
log_nodes = pstate->entrance_nodes;
|
|
|
|
|
if (next_state != NULL)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
{
|
|
|
|
|
table_nodes = next_state->entrance_nodes;
|
|
|
|
|
*err = re_node_set_init_union (&next_nodes, table_nodes,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
log_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2004-03-04 23:28:06 +00:00
|
|
|
|
return NULL;
|
2010-01-15 20:03:16 +00:00
|
|
|
|
}
|
2004-03-04 23:28:06 +00:00
|
|
|
|
else
|
2010-01-15 20:03:16 +00:00
|
|
|
|
next_nodes = *log_nodes;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Note: We already add the nodes of the initial state,
|
|
|
|
|
then we don't need to add them here. */
|
|
|
|
|
|
|
|
|
|
context = re_string_context_at (&mctx->input,
|
|
|
|
|
re_string_cur_idx (&mctx->input) - 1,
|
|
|
|
|
mctx->eflags);
|
|
|
|
|
next_state = mctx->state_log[cur_idx]
|
2010-01-15 20:03:16 +00:00
|
|
|
|
= re_acquire_state_context (err, dfa, &next_nodes, context);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* We don't need to check errors here, since the return value of
|
2010-01-15 20:03:16 +00:00
|
|
|
|
this function is next_state and ERR is already set. */
|
2004-03-04 23:28:06 +00:00
|
|
|
|
|
|
|
|
|
if (table_nodes != NULL)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
re_node_set_free (&next_nodes);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->nbackref) && next_state != NULL)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
/* Check OP_OPEN_SUBEXP in the current state in case that we use them
|
|
|
|
|
later. We must check them here, since the back references in the
|
|
|
|
|
next state might use them. */
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
*err = check_subexp_matching_top (mctx, &next_state->nodes,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
cur_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
/* If the next state has back references. */
|
|
|
|
|
if (next_state->has_backref)
|
|
|
|
|
{
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
*err = transit_state_bkref (mctx, &next_state->nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
next_state = mctx->state_log[cur_idx];
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2004-03-04 23:28:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return next_state;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-04 23:28:06 +00:00
|
|
|
|
/* Skip bytes in the input that correspond to part of a
|
|
|
|
|
multi-byte match, then look in the log for a state
|
|
|
|
|
from which to restart matching. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static re_dfastate_t *
|
2005-10-13 20:08:58 +00:00
|
|
|
|
find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
|
2004-03-04 23:28:06 +00:00
|
|
|
|
{
|
2005-09-07 07:16:24 +00:00
|
|
|
|
re_dfastate_t *cur_state;
|
2004-03-04 23:28:06 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx max = mctx->state_log_top;
|
|
|
|
|
Idx cur_str_idx = re_string_cur_idx (&mctx->input);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2010-01-15 20:03:16 +00:00
|
|
|
|
if (++cur_str_idx > max)
|
|
|
|
|
return NULL;
|
|
|
|
|
re_string_skip_bytes (&mctx->input, 1);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
}
|
|
|
|
|
while (mctx->state_log[cur_str_idx] == NULL);
|
|
|
|
|
|
|
|
|
|
cur_state = merge_state_with_log (err, mctx, NULL);
|
|
|
|
|
}
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
while (*err == REG_NOERROR && cur_state == NULL);
|
2004-03-04 23:28:06 +00:00
|
|
|
|
return cur_state;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Helper functions for transit_state. */
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* From the node set CUR_NODES, pick up the nodes whose types are
|
|
|
|
|
OP_OPEN_SUBEXP and which have corresponding back references in the regular
|
|
|
|
|
expression. And register them to use them later for evaluating the
|
2017-12-20 03:26:08 +00:00
|
|
|
|
corresponding back references. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
reg_errcode_t err;
|
|
|
|
|
|
|
|
|
|
/* TODO: This isn't efficient.
|
|
|
|
|
Because there might be more than one nodes whose types are
|
|
|
|
|
OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
|
|
|
|
|
nodes.
|
|
|
|
|
E.g. RE: (a){2} */
|
|
|
|
|
for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node = cur_nodes->elems[node_idx];
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (dfa->nodes[node].type == OP_OPEN_SUBEXP
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
&& dfa->nodes[node].opr.idx < BITSET_WORD_BITS
|
|
|
|
|
&& (dfa->used_bkref_map
|
|
|
|
|
& ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
err = match_ctx_add_subtop (mctx, node, str_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-20 23:36:40 +00:00
|
|
|
|
#if 0
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Return the next state to which the current state STATE will transit by
|
|
|
|
|
accepting the current input byte. */
|
|
|
|
|
|
|
|
|
|
static re_dfastate_t *
|
2005-10-13 20:08:58 +00:00
|
|
|
|
transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
|
|
|
|
|
re_dfastate_t *state)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 05:41:42 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set next_nodes;
|
|
|
|
|
re_dfastate_t *next_state;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int context;
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
*err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node = state->nodes.elems[node_cnt];
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = re_node_set_merge (&next_nodes,
|
|
|
|
|
dfa->eclosures + dfa->nexts[cur_node]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
next_state = re_acquire_state_context (err, dfa, &next_nodes, context);
|
|
|
|
|
/* We don't need to check errors here, since the return value of
|
|
|
|
|
this function is next_state and ERR is already set. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set_free (&next_nodes);
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
re_string_skip_bytes (&mctx->input, 1);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return next_state;
|
|
|
|
|
}
|
2003-11-20 23:36:40 +00:00
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 05:41:42 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < pstate->nodes.nelem; ++i)
|
|
|
|
|
{
|
|
|
|
|
re_node_set dest_nodes, *new_nodes;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node_idx = pstate->nodes.elems[i];
|
|
|
|
|
int naccepted;
|
|
|
|
|
Idx dest_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int context;
|
|
|
|
|
re_dfastate_t *dest_state;
|
|
|
|
|
|
2005-01-27 19:08:10 +00:00
|
|
|
|
if (!dfa->nodes[cur_node_idx].accept_mb)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
continue;
|
2005-01-27 19:08:10 +00:00
|
|
|
|
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (dfa->nodes[cur_node_idx].constraint)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input,
|
|
|
|
|
re_string_cur_idx (&mctx->input),
|
|
|
|
|
mctx->eflags);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint,
|
|
|
|
|
context))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2003-11-18 23:40:59 +00:00
|
|
|
|
/* How many bytes the node can accept? */
|
2005-01-27 19:08:10 +00:00
|
|
|
|
naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input,
|
|
|
|
|
re_string_cur_idx (&mctx->input));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (naccepted == 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* The node can accepts 'naccepted' bytes. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: mctx->max_mb_elem_len);
|
2003-12-30 20:01:17 +00:00
|
|
|
|
err = clean_state_log_if_needed (mctx, dest_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (dfa->nexts[cur_node_idx] != -1);
|
|
|
|
|
#endif
|
2005-01-27 19:08:10 +00:00
|
|
|
|
new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
dest_state = mctx->state_log[dest_idx];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (dest_state == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dest_nodes = *new_nodes;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
err = re_node_set_init_union (&dest_nodes,
|
|
|
|
|
dest_state->entrance_nodes, new_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, dest_idx - 1,
|
|
|
|
|
mctx->eflags);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
mctx->state_log[dest_idx]
|
2002-11-06 20:36:47 +00:00
|
|
|
|
= re_acquire_state_context (&err, dfa, &dest_nodes, context);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (dest_state != NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set_free (&dest_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL
|
|
|
|
|
&& err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 15:26:18 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
|
|
|
|
Idx cur_str_idx = re_string_cur_idx (&mctx->input);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < nodes->nelem; ++i)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dest_str_idx, prev_nelem, bkc_idx;
|
|
|
|
|
Idx node_idx = nodes->elems[i];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int context;
|
2003-11-23 09:46:38 +00:00
|
|
|
|
const re_token_t *node = dfa->nodes + node_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set *new_dest_nodes;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Check whether 'node' is a backreference or not. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (node->type != OP_BACK_REF)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
|
|
|
|
|
if (node->constraint)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, cur_str_idx,
|
|
|
|
|
mctx->eflags);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* 'node' is a backreference.
|
2002-11-06 20:36:47 +00:00
|
|
|
|
Check the substring which the substring matched. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
bkc_idx = mctx->nbkref_ents;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = get_subexp (mctx, node_idx, cur_str_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto free_return;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* And add the epsilon closures (which is 'new_dest_nodes') of
|
2002-11-06 20:36:47 +00:00
|
|
|
|
the backreference to appropriate state_log. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (dfa->nexts[node_idx] != -1);
|
|
|
|
|
#endif
|
2002-11-27 23:00:16 +00:00
|
|
|
|
for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_len;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_dfastate_t *dest_state;
|
|
|
|
|
struct re_backref_cache_entry *bkref_ent;
|
|
|
|
|
bkref_ent = mctx->bkref_ents + bkc_idx;
|
|
|
|
|
if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
|
|
|
|
|
continue;
|
|
|
|
|
subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
|
|
|
|
|
new_dest_nodes = (subexp_len == 0
|
|
|
|
|
? dfa->eclosures + dfa->edests[node_idx].elems[0]
|
|
|
|
|
: dfa->eclosures + dfa->nexts[node_idx]);
|
|
|
|
|
dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
|
|
|
|
|
- bkref_ent->subexp_from);
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, dest_str_idx - 1,
|
|
|
|
|
mctx->eflags);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dest_state = mctx->state_log[dest_str_idx];
|
|
|
|
|
prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
|
|
|
|
|
: mctx->state_log[cur_str_idx]->nodes.nelem);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Add 'new_dest_node' to state_log. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (dest_state == NULL)
|
|
|
|
|
{
|
|
|
|
|
mctx->state_log[dest_str_idx]
|
|
|
|
|
= re_acquire_state_context (&err, dfa, new_dest_nodes,
|
|
|
|
|
context);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
|
|
|
|
|
&& err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
re_node_set dest_nodes;
|
|
|
|
|
err = re_node_set_init_union (&dest_nodes,
|
|
|
|
|
dest_state->entrance_nodes,
|
|
|
|
|
new_dest_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&dest_nodes);
|
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
mctx->state_log[dest_str_idx]
|
|
|
|
|
= re_acquire_state_context (&err, dfa, &dest_nodes, context);
|
|
|
|
|
re_node_set_free (&dest_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
|
|
|
|
|
&& err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
/* We need to check recursively if the backreference can epsilon
|
|
|
|
|
transit. */
|
|
|
|
|
if (subexp_len == 0
|
|
|
|
|
&& mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
|
|
|
|
|
{
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = check_subexp_matching_top (mctx, new_dest_nodes,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
cur_str_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
goto free_return;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = transit_state_bkref (mctx, new_dest_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto free_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
err = REG_NOERROR;
|
|
|
|
|
free_return:
|
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Enumerate all the candidates which the backreference BKREF_NODE can match
|
|
|
|
|
at BKREF_STR_IDX, and register them by match_ctx_add_entry().
|
|
|
|
|
Note that we might collect inappropriate candidates here.
|
|
|
|
|
However, the cost of checking them strictly here is too high, then we
|
|
|
|
|
delay these checking for prune_impossible_nodes(). */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-09-07 15:26:18 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_num, sub_top_idx;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
const char *buf = (const char *) re_string_get_buffer (&mctx->input);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (cache_idx != -1)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
const struct re_backref_cache_entry *entry
|
|
|
|
|
= mctx->bkref_ents + cache_idx;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
do
|
2010-01-15 20:03:16 +00:00
|
|
|
|
if (entry->node == bkref_node)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
return REG_NOERROR; /* We already checked it. */
|
|
|
|
|
while (entry++->more);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
2004-12-06 03:03:01 +00:00
|
|
|
|
subexp_num = dfa->nodes[bkref_node].opr.idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
|
|
|
|
/* For each sub expression */
|
|
|
|
|
for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
|
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
|
|
|
|
re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
|
|
|
|
|
re_sub_match_last_t *sub_last;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx sub_last_idx, sl_str, bkref_str_off;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
|
|
|
|
if (dfa->nodes[sub_top->node].opr.idx != subexp_num)
|
|
|
|
|
continue; /* It isn't related. */
|
|
|
|
|
|
|
|
|
|
sl_str = sub_top->str_idx;
|
2003-12-30 20:01:17 +00:00
|
|
|
|
bkref_str_off = bkref_str_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* At first, check the last node of sub expressions we already
|
|
|
|
|
evaluated. */
|
|
|
|
|
for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
regoff_t sl_str_diff;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
sub_last = sub_top->lasts[sub_last_idx];
|
|
|
|
|
sl_str_diff = sub_last->str_idx - sl_str;
|
|
|
|
|
/* The matched string by the sub expression match with the substring
|
|
|
|
|
at the back reference? */
|
2004-01-19 20:17:24 +00:00
|
|
|
|
if (sl_str_diff > 0)
|
|
|
|
|
{
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (bkref_str_off + sl_str_diff
|
|
|
|
|
> mctx->input.valid_len))
|
2004-01-19 20:17:24 +00:00
|
|
|
|
{
|
|
|
|
|
/* Not enough chars for a successful match. */
|
|
|
|
|
if (bkref_str_off + sl_str_diff > mctx->input.len)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
err = clean_state_log_if_needed (mctx,
|
|
|
|
|
bkref_str_off
|
|
|
|
|
+ sl_str_diff);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-01-19 20:17:24 +00:00
|
|
|
|
return err;
|
|
|
|
|
buf = (const char *) re_string_get_buffer (&mctx->input);
|
|
|
|
|
}
|
|
|
|
|
if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0)
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
/* We don't need to search this sub expression any more. */
|
|
|
|
|
break;
|
2004-01-19 20:17:24 +00:00
|
|
|
|
}
|
2003-12-30 20:01:17 +00:00
|
|
|
|
bkref_str_off += sl_str_diff;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
sl_str += sl_str_diff;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
bkref_str_idx);
|
2003-11-19 07:18:32 +00:00
|
|
|
|
|
2003-12-30 20:01:17 +00:00
|
|
|
|
/* Reload buf, since the preceding call might have reallocated
|
|
|
|
|
the buffer. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
buf = (const char *) re_string_get_buffer (&mctx->input);
|
2003-11-19 07:18:32 +00:00
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (err == REG_NOMATCH)
|
|
|
|
|
continue;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2003-12-30 20:01:17 +00:00
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (sub_last_idx < sub_top->nlasts)
|
|
|
|
|
continue;
|
|
|
|
|
if (sub_last_idx > 0)
|
|
|
|
|
++sl_str;
|
|
|
|
|
/* Then, search for the other last nodes of the sub expression. */
|
|
|
|
|
for (; sl_str <= bkref_str_idx; ++sl_str)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cls_node;
|
|
|
|
|
regoff_t sl_str_off;
|
2003-11-23 09:46:38 +00:00
|
|
|
|
const re_node_set *nodes;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
sl_str_off = sl_str - sub_top->str_idx;
|
|
|
|
|
/* The matched string by the sub expression match with the substring
|
|
|
|
|
at the back reference? */
|
2004-01-19 20:17:24 +00:00
|
|
|
|
if (sl_str_off > 0)
|
|
|
|
|
{
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len))
|
2004-01-19 20:17:24 +00:00
|
|
|
|
{
|
|
|
|
|
/* If we are at the end of the input, we cannot match. */
|
|
|
|
|
if (bkref_str_off >= mctx->input.len)
|
|
|
|
|
break;
|
|
|
|
|
|
2013-01-29 13:45:15 +00:00
|
|
|
|
err = extend_buffers (mctx, bkref_str_off + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2004-01-19 20:17:24 +00:00
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
buf = (const char *) re_string_get_buffer (&mctx->input);
|
|
|
|
|
}
|
|
|
|
|
if (buf [bkref_str_off++] != buf[sl_str - 1])
|
|
|
|
|
break; /* We don't need to search this sub expression
|
|
|
|
|
any more. */
|
|
|
|
|
}
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (mctx->state_log[sl_str] == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
/* Does this state have a ')' of the sub expression? */
|
|
|
|
|
nodes = &mctx->state_log[sl_str]->nodes;
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
cls_node = find_subexp_node (dfa, nodes, subexp_num,
|
|
|
|
|
OP_CLOSE_SUBEXP);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (cls_node == -1)
|
|
|
|
|
continue; /* No. */
|
|
|
|
|
if (sub_top->path == NULL)
|
|
|
|
|
{
|
|
|
|
|
sub_top->path = calloc (sizeof (state_array_t),
|
|
|
|
|
sl_str - sub_top->str_idx + 1);
|
|
|
|
|
if (sub_top->path == NULL)
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
|
|
|
|
/* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node
|
|
|
|
|
in the current context? */
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = check_arrival (mctx, sub_top->path, sub_top->node,
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
sub_top->str_idx, cls_node, sl_str,
|
|
|
|
|
OP_CLOSE_SUBEXP);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (err == REG_NOMATCH)
|
|
|
|
|
continue;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (sub_last == NULL))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return REG_ESPACE;
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
bkref_str_idx);
|
2018-09-06 06:25:07 +00:00
|
|
|
|
buf = (const char *) re_string_get_buffer (&mctx->input);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (err == REG_NOMATCH)
|
|
|
|
|
continue;
|
2018-09-06 06:57:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
|
|
|
|
return err;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper functions for get_subexp(). */
|
|
|
|
|
|
|
|
|
|
/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR.
|
|
|
|
|
If it can arrive, register the sub expression expressed with SUB_TOP
|
|
|
|
|
and SUB_LAST. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx to_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Can the subexpression arrive the back reference? */
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = check_arrival (mctx, &sub_last->path, sub_last->node,
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
sub_last->str_idx, bkref_node, bkref_str,
|
|
|
|
|
OP_OPEN_SUBEXP);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (err != REG_NOERROR)
|
|
|
|
|
return err;
|
|
|
|
|
err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
|
|
|
|
|
sub_last->str_idx);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
|
2004-01-19 20:17:24 +00:00
|
|
|
|
return clean_state_log_if_needed (mctx, to_idx);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX.
|
|
|
|
|
Search '(' if FL_OPEN, or search ')' otherwise.
|
|
|
|
|
TODO: This function isn't efficient...
|
|
|
|
|
Because there might be more than one nodes whose types are
|
|
|
|
|
OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
|
|
|
|
|
nodes.
|
|
|
|
|
E.g. RE: (a){2} */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
2005-10-13 20:08:58 +00:00
|
|
|
|
find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_idx, int type)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cls_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cls_node = nodes->elems[cls_idx];
|
2003-11-23 09:46:38 +00:00
|
|
|
|
const re_token_t *node = dfa->nodes + cls_node;
|
2003-12-14 23:40:44 +00:00
|
|
|
|
if (node->type == type
|
2002-11-27 23:00:16 +00:00
|
|
|
|
&& node->opr.idx == subexp_idx)
|
|
|
|
|
return cls_node;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
|
|
|
|
|
LAST_NODE at LAST_STR. We record the path onto PATH since it will be
|
|
|
|
|
heavily reused.
|
|
|
|
|
Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
|
|
|
|
|
Idx top_str, Idx last_node, Idx last_str, int type)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2005-09-07 15:26:18 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2005-09-30 15:46:19 +00:00
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx subexp_num, backup_cur_idx, str_idx, null_cnt;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_dfastate_t *cur_state = NULL;
|
|
|
|
|
re_node_set *cur_nodes, next_nodes;
|
|
|
|
|
re_dfastate_t **backup_state_log;
|
|
|
|
|
unsigned int context;
|
|
|
|
|
|
|
|
|
|
subexp_num = dfa->nodes[top_node].opr.idx;
|
|
|
|
|
/* Extend the buffer if we need. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_dfastate_t **new_array;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx old_alloc = path->alloc;
|
|
|
|
|
Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
|
|
|
|
|
Idx new_alloc;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
new_alloc = old_alloc + incr_alloc;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_array == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return REG_ESPACE;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
path->array = new_array;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
path->alloc = new_alloc;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
memset (new_array + old_alloc, '\0',
|
|
|
|
|
sizeof (re_dfastate_t *) * (path->alloc - old_alloc));
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
str_idx = path->next_idx ? path->next_idx : top_str;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
|
|
|
|
/* Temporary modify MCTX. */
|
|
|
|
|
backup_state_log = mctx->state_log;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
backup_cur_idx = mctx->input.cur_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
mctx->state_log = path->array;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
mctx->input.cur_idx = str_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
|
|
|
|
/* Setup initial node set. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (str_idx == top_str)
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_init_1 (&next_nodes, top_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
2003-12-14 23:40:44 +00:00
|
|
|
|
err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cur_state = mctx->state_log[str_idx];
|
|
|
|
|
if (cur_state && cur_state->has_backref)
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
re_node_set_init_empty (&next_nodes);
|
|
|
|
|
}
|
|
|
|
|
if (str_idx == top_str || (cur_state && cur_state->has_backref))
|
|
|
|
|
{
|
|
|
|
|
if (next_nodes.nelem)
|
|
|
|
|
{
|
2004-11-08 16:07:55 +00:00
|
|
|
|
err = expand_bkref_cache (mctx, &next_nodes, str_idx,
|
2003-12-14 23:40:44 +00:00
|
|
|
|
subexp_num, type);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
mctx->state_log[str_idx] = cur_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
|
|
|
|
|
{
|
|
|
|
|
re_node_set_empty (&next_nodes);
|
|
|
|
|
if (mctx->state_log[str_idx + 1])
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_merge (&next_nodes,
|
|
|
|
|
&mctx->state_log[str_idx + 1]->nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (cur_state)
|
|
|
|
|
{
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
err = check_arrival_add_next_nodes (mctx, str_idx,
|
2005-09-07 15:26:18 +00:00
|
|
|
|
&cur_state->non_eps_nodes,
|
|
|
|
|
&next_nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
++str_idx;
|
|
|
|
|
if (next_nodes.nelem)
|
|
|
|
|
{
|
2003-12-14 23:40:44 +00:00
|
|
|
|
err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2004-11-08 16:07:55 +00:00
|
|
|
|
err = expand_bkref_cache (mctx, &next_nodes, str_idx,
|
2003-12-14 23:40:44 +00:00
|
|
|
|
subexp_num, type);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
mctx->state_log[str_idx] = cur_state;
|
|
|
|
|
null_cnt = cur_state == NULL ? null_cnt + 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
re_node_set_free (&next_nodes);
|
|
|
|
|
cur_nodes = (mctx->state_log[last_str] == NULL ? NULL
|
|
|
|
|
: &mctx->state_log[last_str]->nodes);
|
|
|
|
|
path->next_idx = str_idx;
|
|
|
|
|
|
|
|
|
|
/* Fix MCTX. */
|
|
|
|
|
mctx->state_log = backup_state_log;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
mctx->input.cur_idx = backup_cur_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
|
|
|
|
/* Then check the current node set has the node LAST_NODE. */
|
2003-12-16 06:16:27 +00:00
|
|
|
|
if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node))
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
|
|
|
|
|
return REG_NOMATCH;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper functions for check_arrival. */
|
|
|
|
|
|
|
|
|
|
/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them
|
|
|
|
|
to NEXT_NODES.
|
|
|
|
|
TODO: This function is similar to the functions transit_state*(),
|
|
|
|
|
however this function has many additional works.
|
|
|
|
|
Can't we unify them? */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set *cur_nodes, re_node_set *next_nodes)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2005-09-07 05:41:42 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool ok;
|
|
|
|
|
Idx cur_idx;
|
2017-12-22 15:57:25 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2005-09-30 15:46:19 +00:00
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
2017-12-22 15:57:25 +00:00
|
|
|
|
#endif
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set union_set;
|
|
|
|
|
re_node_set_init_empty (&union_set);
|
|
|
|
|
for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
|
|
|
|
|
{
|
|
|
|
|
int naccepted = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node = cur_nodes->elems[cur_idx];
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#ifdef DEBUG
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[cur_node].type;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
assert (!IS_EPSILON_NODE (type));
|
|
|
|
|
#endif
|
2002-11-27 23:00:16 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* If the node may accept "multi byte". */
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
if (dfa->nodes[cur_node].accept_mb)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
|
2002-11-27 23:00:16 +00:00
|
|
|
|
str_idx);
|
|
|
|
|
if (naccepted > 1)
|
|
|
|
|
{
|
|
|
|
|
re_dfastate_t *dest_state;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx next_node = dfa->nexts[cur_node];
|
|
|
|
|
Idx next_idx = str_idx + naccepted;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
dest_state = mctx->state_log[next_idx];
|
|
|
|
|
re_node_set_empty (&union_set);
|
|
|
|
|
if (dest_state)
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_merge (&union_set, &dest_state->nodes);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&union_set);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (&union_set, next_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2003-12-29 17:59:41 +00:00
|
|
|
|
re_node_set_free (&union_set);
|
|
|
|
|
return REG_ESPACE;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
|
|
|
|
|
&union_set);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->state_log[next_idx] == NULL
|
|
|
|
|
&& err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&union_set);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
if (naccepted
|
(match_ctx_free_subtops, search_cur_bkref_entry, match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context, prune_impossible_nodes, check_halt_state_context, proceed_next_node, sift_states_backward, update_cur_sifted_state, check_dst_limits, check_dst_limits_calc_pos, sift_states_bkref, transit_state, check_subexp_matching_top, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept): Remove dfa parameter. Get dfa from mctxt. Adjust callers. (re_search_internal): Initialize mctxt.dfa.
2004-01-03 04:06:39 +00:00
|
|
|
|
|| check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&union_set);
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
re_node_set_free (&union_set);
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For all the nodes in CUR_NODES, add the epsilon closures of them to
|
|
|
|
|
CUR_NODES, however exclude the nodes which are:
|
|
|
|
|
- inside the sub expression whose number is EX_SUBEXP, if FL_OPEN.
|
|
|
|
|
- out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx ex_subexp, int type)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx, outside_node;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_node_set new_nodes;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (cur_nodes->nelem);
|
|
|
|
|
#endif
|
|
|
|
|
err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
/* Create a new node set NEW_NODES with the nodes which are epsilon
|
|
|
|
|
closures of the node in CUR_NODES. */
|
|
|
|
|
|
|
|
|
|
for (idx = 0; idx < cur_nodes->nelem; ++idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node = cur_nodes->elems[idx];
|
2005-09-07 15:26:18 +00:00
|
|
|
|
const re_node_set *eclosure = dfa->eclosures + cur_node;
|
2003-12-14 23:40:44 +00:00
|
|
|
|
outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (outside_node == -1)
|
|
|
|
|
{
|
|
|
|
|
/* There are no problematic nodes, just merge them. */
|
|
|
|
|
err = re_node_set_merge (&new_nodes, eclosure);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&new_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* There are problematic nodes, re-calculate incrementally. */
|
|
|
|
|
err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
|
2003-12-14 23:40:44 +00:00
|
|
|
|
ex_subexp, type);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&new_nodes);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
re_node_set_free (cur_nodes);
|
|
|
|
|
*cur_nodes = new_nodes;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for check_arrival_expand_ecl.
|
|
|
|
|
Check incrementally the epsilon closure of TARGET, and if it isn't
|
|
|
|
|
problematic append it to DST_NODES. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx target, Idx ex_subexp, int type)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_node;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool ok;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
2003-12-14 23:40:44 +00:00
|
|
|
|
if (dfa->nodes[cur_node].type == type
|
2002-11-27 23:00:16 +00:00
|
|
|
|
&& dfa->nodes[cur_node].opr.idx == ex_subexp)
|
|
|
|
|
{
|
2003-12-14 23:40:44 +00:00
|
|
|
|
if (type == OP_CLOSE_SUBEXP)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dst_nodes, cur_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dst_nodes, cur_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
if (dfa->edests[cur_node].nelem == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (dfa->edests[cur_node].nelem == 2)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_errcode_t err;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
|
|
|
|
|
dfa->edests[cur_node].elems[1],
|
2003-12-14 23:40:44 +00:00
|
|
|
|
ex_subexp, type);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
cur_node = dfa->edests[cur_node].elems[0];
|
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* For all the back references in the current state, calculate the
|
|
|
|
|
destination of the back references by the appropriate entry
|
|
|
|
|
in MCTX->BKREF_ENTS. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2005-10-13 20:08:58 +00:00
|
|
|
|
expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cur_str, Idx subexp_num, int type)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa = mctx->dfa;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
|
2004-11-08 22:49:44 +00:00
|
|
|
|
struct re_backref_cache_entry *ent;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (cache_idx_start == -1)
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
|
|
|
|
|
restart:
|
|
|
|
|
ent = mctx->bkref_ents + cache_idx_start;
|
|
|
|
|
do
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx to_idx, next_node;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Is this entry ENT is appropriate? */
|
|
|
|
|
if (!re_node_set_contains (cur_nodes, ent->node))
|
|
|
|
|
continue; /* No. */
|
|
|
|
|
|
|
|
|
|
to_idx = cur_str + ent->subexp_to - ent->subexp_from;
|
|
|
|
|
/* Calculate the destination of the back reference, and append it
|
|
|
|
|
to MCTX->STATE_LOG. */
|
|
|
|
|
if (to_idx == cur_str)
|
|
|
|
|
{
|
|
|
|
|
/* The backreference did epsilon transit, we must re-check all the
|
|
|
|
|
node in the current state. */
|
|
|
|
|
re_node_set new_dests;
|
|
|
|
|
reg_errcode_t err2, err3;
|
|
|
|
|
next_node = dfa->edests[ent->node].elems[0];
|
|
|
|
|
if (re_node_set_contains (cur_nodes, next_node))
|
|
|
|
|
continue;
|
|
|
|
|
err = re_node_set_init_1 (&new_dests, next_node);
|
2003-12-14 23:40:44 +00:00
|
|
|
|
err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
err3 = re_node_set_merge (cur_nodes, &new_dests);
|
|
|
|
|
re_node_set_free (&new_dests);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR
|
|
|
|
|
|| err3 != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
err = (err != REG_NOERROR ? err
|
|
|
|
|
: (err2 != REG_NOERROR ? err2 : err3));
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
/* TODO: It is still inefficient... */
|
2004-11-08 22:49:44 +00:00
|
|
|
|
goto restart;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
re_node_set union_set;
|
|
|
|
|
next_node = dfa->nexts[ent->node];
|
|
|
|
|
if (mctx->state_log[to_idx])
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool ok;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
|
|
|
|
|
next_node))
|
|
|
|
|
continue;
|
|
|
|
|
err = re_node_set_init_copy (&union_set,
|
|
|
|
|
&mctx->state_log[to_idx]->nodes);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (&union_set, next_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR || ! ok))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&union_set);
|
|
|
|
|
err = err != REG_NOERROR ? err : REG_ESPACE;
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_init_1 (&union_set, next_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
|
|
|
|
|
re_node_set_free (&union_set);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->state_log[to_idx] == NULL
|
|
|
|
|
&& err != REG_NOERROR))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
while (ent++->more);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Build transition table for the state.
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Return true if successful. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static bool
|
2005-10-13 20:08:58 +00:00
|
|
|
|
build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i, j;
|
|
|
|
|
int ch;
|
|
|
|
|
bool need_word_trtable = false;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_word_t elem, mask;
|
|
|
|
|
bool dests_node_malloced = false;
|
|
|
|
|
bool dest_states_malloced = false;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx ndests; /* Number of the destination states from 'state'. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_dfastate_t **trtable;
|
|
|
|
|
re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
|
|
|
|
|
re_node_set follows, *dests_node;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_t *dests_ch;
|
|
|
|
|
bitset_t acceptable;
|
|
|
|
|
|
|
|
|
|
struct dests_alloc
|
|
|
|
|
{
|
|
|
|
|
re_node_set dests_node[SBC_MAX];
|
|
|
|
|
bitset_t dests_ch[SBC_MAX];
|
|
|
|
|
} *dests_alloc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* We build DFA states which corresponds to the destination nodes
|
2017-12-20 11:47:44 +00:00
|
|
|
|
from 'state'. 'dests_node[i]' represents the nodes which i-th
|
|
|
|
|
destination state contains, and 'dests_ch[i]' represents the
|
2002-02-26 19:06:03 +00:00
|
|
|
|
characters which i-th destination state accepts. */
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
if (__libc_use_alloca (sizeof (struct dests_alloc)))
|
|
|
|
|
dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc));
|
2002-11-03 00:59:09 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
dests_alloc = re_malloc (struct dests_alloc, 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dests_alloc == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
dests_node_malloced = true;
|
2002-11-03 00:59:09 +00:00
|
|
|
|
}
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
dests_node = dests_alloc->dests_node;
|
|
|
|
|
dests_ch = dests_alloc->dests_ch;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Initialize transition table. */
|
2004-12-27 16:44:39 +00:00
|
|
|
|
state->word_trtable = state->trtable = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* At first, group all nodes belonging to 'state' into several
|
2002-02-26 19:06:03 +00:00
|
|
|
|
destinations. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ndests <= 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-11-03 00:59:09 +00:00
|
|
|
|
if (dests_node_malloced)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (dests_alloc);
|
|
|
|
|
/* Return false in case of an error, true otherwise. */
|
2002-11-03 00:59:09 +00:00
|
|
|
|
if (ndests == 0)
|
2003-11-20 23:36:40 +00:00
|
|
|
|
{
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
state->trtable = (re_dfastate_t **)
|
2004-12-27 16:44:39 +00:00
|
|
|
|
calloc (sizeof (re_dfastate_t *), SBC_MAX);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (state->trtable == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2003-11-20 23:36:40 +00:00
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
err = re_node_set_alloc (&follows, ndests + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-03 00:59:09 +00:00
|
|
|
|
goto out_free;
|
2010-01-22 18:52:38 +00:00
|
|
|
|
|
|
|
|
|
/* Avoid arithmetic overflow in size calculation. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
size_t ndests_max
|
|
|
|
|
= ((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
|
|
|
|
|
/ (3 * sizeof (re_dfastate_t *)));
|
|
|
|
|
if (__glibc_unlikely (ndests_max < ndests))
|
2010-01-22 18:52:38 +00:00
|
|
|
|
goto out_free;
|
2002-11-03 00:59:09 +00:00
|
|
|
|
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
|
2002-11-03 00:59:09 +00:00
|
|
|
|
+ ndests * 3 * sizeof (re_dfastate_t *)))
|
|
|
|
|
dest_states = (re_dfastate_t **)
|
2004-12-27 16:44:39 +00:00
|
|
|
|
alloca (ndests * 3 * sizeof (re_dfastate_t *));
|
2002-11-03 00:59:09 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dest_states = re_malloc (re_dfastate_t *, ndests * 3);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dest_states == NULL))
|
2002-11-03 00:59:09 +00:00
|
|
|
|
{
|
|
|
|
|
out_free:
|
|
|
|
|
if (dest_states_malloced)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (dest_states);
|
2002-11-03 00:59:09 +00:00
|
|
|
|
re_node_set_free (&follows);
|
|
|
|
|
for (i = 0; i < ndests; ++i)
|
|
|
|
|
re_node_set_free (dests_node + i);
|
|
|
|
|
if (dests_node_malloced)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (dests_alloc);
|
|
|
|
|
return false;
|
2002-11-03 00:59:09 +00:00
|
|
|
|
}
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
dest_states_malloced = true;
|
2002-11-03 00:59:09 +00:00
|
|
|
|
}
|
|
|
|
|
dest_states_word = dest_states + ndests;
|
|
|
|
|
dest_states_nl = dest_states_word + ndests;
|
|
|
|
|
bitset_empty (acceptable);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Then build the states for all destinations. */
|
|
|
|
|
for (i = 0; i < ndests; ++i)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx next_node;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set_empty (&follows);
|
|
|
|
|
/* Merge the follows of this destination states. */
|
|
|
|
|
for (j = 0; j < dests_node[i].nelem; ++j)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
next_node = dfa->nexts[dests_node[i].elems[j]];
|
|
|
|
|
if (next_node != -1)
|
|
|
|
|
{
|
|
|
|
|
err = re_node_set_merge (&follows, dfa->eclosures + next_node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-03 00:59:09 +00:00
|
|
|
|
goto out_free;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto out_free;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* If the new state has context constraint,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
build appropriate states for these contexts. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (dest_states[i]->has_constraint)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
|
|
|
|
|
CONTEXT_WORD);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dest_states_word[i] == NULL
|
|
|
|
|
&& err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto out_free;
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
|
2004-12-27 16:44:39 +00:00
|
|
|
|
if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
need_word_trtable = true;
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
|
|
|
|
|
CONTEXT_NEWLINE);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto out_free;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
dest_states_word[i] = dest_states[i];
|
|
|
|
|
dest_states_nl[i] = dest_states[i];
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
bitset_merge (acceptable, dests_ch[i]);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (!__glibc_unlikely (need_word_trtable))
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
/* We don't care about whether the following character is a word
|
|
|
|
|
character, or we are in a single-byte character set so we can
|
|
|
|
|
discern by looking at the character code: allocate a
|
|
|
|
|
256-entry transition table. */
|
2004-12-27 16:44:39 +00:00
|
|
|
|
trtable = state->trtable =
|
|
|
|
|
(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (trtable == NULL))
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
|
|
/* For all characters ch...: */
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (i = 0; i < BITSET_WORDS; ++i)
|
|
|
|
|
for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
elem;
|
|
|
|
|
mask <<= 1, elem >>= 1, ++ch)
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (elem & 1))
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
/* There must be exactly one destination which accepts
|
|
|
|
|
character ch. See group_nodes_into_DFAstates. */
|
|
|
|
|
for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
|
|
|
|
|
;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
/* j-th destination accepts the word character ch. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (dfa->word_char[i] & mask)
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
trtable[ch] = dest_states_word[j];
|
|
|
|
|
else
|
|
|
|
|
trtable[ch] = dest_states[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We care about whether the following character is a word
|
|
|
|
|
character, and we are in a multi-byte character set: discern
|
|
|
|
|
by looking at the character code: build two 256-entry
|
|
|
|
|
transition tables, one starting at trtable[0] and one
|
|
|
|
|
starting at trtable[SBC_MAX]. */
|
2004-12-27 16:44:39 +00:00
|
|
|
|
trtable = state->word_trtable =
|
|
|
|
|
(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (trtable == NULL))
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
goto out_free;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
/* For all characters ch...: */
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (i = 0; i < BITSET_WORDS; ++i)
|
|
|
|
|
for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
elem;
|
|
|
|
|
mask <<= 1, elem >>= 1, ++ch)
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (elem & 1))
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
/* There must be exactly one destination which accepts
|
|
|
|
|
character ch. See group_nodes_into_DFAstates. */
|
|
|
|
|
for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
|
|
|
|
|
;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
/* j-th destination accepts the word character ch. */
|
|
|
|
|
trtable[ch] = dest_states[j];
|
|
|
|
|
trtable[ch + SBC_MAX] = dest_states_word[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* new line */
|
2002-09-10 18:40:35 +00:00
|
|
|
|
if (bitset_contain (acceptable, NEWLINE_CHAR))
|
|
|
|
|
{
|
|
|
|
|
/* The current state accepts newline character. */
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
for (j = 0; j < ndests; ++j)
|
|
|
|
|
if (bitset_contain (dests_ch[j], NEWLINE_CHAR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* k-th destination accepts newline character. */
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
trtable[NEWLINE_CHAR] = dest_states_nl[j];
|
2004-12-27 16:44:39 +00:00
|
|
|
|
if (need_word_trtable)
|
(build_trtable): Don't allocate the trtable until state->word_trtable is known. Don't hardcode UINT_BITS iterations on each bitset item.
(match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
2003-12-23 01:43:19 +00:00
|
|
|
|
trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* There must be only one destination which accepts
|
|
|
|
|
newline. See group_nodes_into_DFAstates. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-09-10 18:40:35 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-11-03 00:59:09 +00:00
|
|
|
|
if (dest_states_malloced)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (dest_states);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
re_node_set_free (&follows);
|
|
|
|
|
for (i = 0; i < ndests; ++i)
|
|
|
|
|
re_node_set_free (dests_node + i);
|
|
|
|
|
|
2002-11-03 00:59:09 +00:00
|
|
|
|
if (dests_node_malloced)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (dests_alloc);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return true;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Group all nodes belonging to STATE into several destinations.
|
|
|
|
|
Then for all destinations, set the nodes belonging to the destination
|
|
|
|
|
to DESTS_NODE[i] and set the characters accepted by the destination
|
|
|
|
|
to DEST_CH[i]. This function return the number of destinations. */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
2005-10-13 20:08:58 +00:00
|
|
|
|
group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
|
|
|
|
|
re_node_set *dests_node, bitset_t *dests_ch)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool ok;
|
|
|
|
|
Idx i, j, k;
|
|
|
|
|
Idx ndests; /* Number of the destinations from 'state'. */
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_t accepts; /* Characters a node can accept. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
const re_node_set *cur_nodes = &state->nodes;
|
|
|
|
|
bitset_empty (accepts);
|
|
|
|
|
ndests = 0;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* For all the nodes belonging to 'state', */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (i = 0; i < cur_nodes->nelem; ++i)
|
|
|
|
|
{
|
|
|
|
|
re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
|
|
|
|
|
re_token_type_t type = node->type;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
unsigned int constraint = node->constraint;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Enumerate all single byte character this node can accept. */
|
|
|
|
|
if (type == CHARACTER)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bitset_set (accepts, node->opr.c);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (type == SIMPLE_BRACKET)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
bitset_merge (accepts, node->opr.sbcset);
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (type == OP_PERIOD)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (dfa->mb_cur_max > 1)
|
|
|
|
|
bitset_merge (accepts, dfa->sb_char);
|
|
|
|
|
else
|
2003-12-14 23:40:44 +00:00
|
|
|
|
#endif
|
2003-11-24 19:30:51 +00:00
|
|
|
|
bitset_set_all (accepts);
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (!(dfa->syntax & RE_DOT_NEWLINE))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bitset_clear (accepts, '\n');
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (dfa->syntax & RE_DOT_NOT_NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bitset_clear (accepts, '\0');
|
|
|
|
|
}
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2003-11-18 23:40:59 +00:00
|
|
|
|
else if (type == OP_UTF8_PERIOD)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (ASCII_CHARS % BITSET_WORD_BITS == 0)
|
|
|
|
|
memset (accepts, -1, ASCII_CHARS / CHAR_BIT);
|
|
|
|
|
else
|
|
|
|
|
bitset_merge (accepts, utf8_sb_map);
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (!(dfa->syntax & RE_DOT_NEWLINE))
|
2003-11-18 23:40:59 +00:00
|
|
|
|
bitset_clear (accepts, '\n');
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (dfa->syntax & RE_DOT_NOT_NULL)
|
2003-11-18 23:40:59 +00:00
|
|
|
|
bitset_clear (accepts, '\0');
|
2010-01-15 20:03:16 +00:00
|
|
|
|
}
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Check the 'accepts' and sift the characters which are not
|
2002-11-06 20:36:47 +00:00
|
|
|
|
match it the context. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (constraint)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (constraint & NEXT_NEWLINE_CONSTRAINT)
|
|
|
|
|
{
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bitset_empty (accepts);
|
|
|
|
|
if (accepts_newline)
|
|
|
|
|
bitset_set (accepts, NEWLINE_CHAR);
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2003-06-12 18:29:52 +00:00
|
|
|
|
if (constraint & NEXT_ENDBUF_CONSTRAINT)
|
|
|
|
|
{
|
|
|
|
|
bitset_empty (accepts);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2003-11-20 23:36:40 +00:00
|
|
|
|
|
2003-06-12 18:29:52 +00:00
|
|
|
|
if (constraint & NEXT_WORD_CONSTRAINT)
|
2003-11-24 19:30:51 +00:00
|
|
|
|
{
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_word_t any_set = 0;
|
2003-12-22 06:52:35 +00:00
|
|
|
|
if (type == CHARACTER && !node->word_char)
|
|
|
|
|
{
|
|
|
|
|
bitset_empty (accepts);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (dfa->mb_cur_max > 1)
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (j = 0; j < BITSET_WORDS; ++j)
|
2003-12-16 18:58:47 +00:00
|
|
|
|
any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
|
2003-11-24 19:30:51 +00:00
|
|
|
|
else
|
|
|
|
|
#endif
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (j = 0; j < BITSET_WORDS; ++j)
|
2003-12-16 18:58:47 +00:00
|
|
|
|
any_set |= (accepts[j] &= dfa->word_char[j]);
|
|
|
|
|
if (!any_set)
|
|
|
|
|
continue;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
}
|
2003-06-12 18:29:52 +00:00
|
|
|
|
if (constraint & NEXT_NOTWORD_CONSTRAINT)
|
2003-11-24 19:30:51 +00:00
|
|
|
|
{
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_word_t any_set = 0;
|
2003-12-22 06:52:35 +00:00
|
|
|
|
if (type == CHARACTER && node->word_char)
|
|
|
|
|
{
|
|
|
|
|
bitset_empty (accepts);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (dfa->mb_cur_max > 1)
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (j = 0; j < BITSET_WORDS; ++j)
|
2003-12-16 18:58:47 +00:00
|
|
|
|
any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
|
2003-11-24 19:30:51 +00:00
|
|
|
|
else
|
|
|
|
|
#endif
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (j = 0; j < BITSET_WORDS; ++j)
|
2003-12-16 18:58:47 +00:00
|
|
|
|
any_set |= (accepts[j] &= ~dfa->word_char[j]);
|
|
|
|
|
if (!any_set)
|
|
|
|
|
continue;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Then divide 'accepts' into DFA states, or create a new
|
2003-12-16 18:58:47 +00:00
|
|
|
|
state. Above, we make sure that accepts is not empty. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (j = 0; j < ndests; ++j)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_t intersec; /* Intersection sets, see below. */
|
|
|
|
|
bitset_t remains;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* Flags, see below. */
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_word_t has_intersec, not_subset, not_consumed;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
|
|
|
|
|
/* Optimization, skip if this state doesn't accept the character. */
|
|
|
|
|
if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
|
|
|
|
|
continue;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Enumerate the intersection set of this state and 'accepts'. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
has_intersec = 0;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (k = 0; k < BITSET_WORDS; ++k)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
|
|
|
|
|
/* And skip if the intersection set is empty. */
|
|
|
|
|
if (!has_intersec)
|
|
|
|
|
continue;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Then check if this state is a subset of 'accepts'. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
not_subset = not_consumed = 0;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (k = 0; k < BITSET_WORDS; ++k)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k];
|
|
|
|
|
not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* If this state isn't a subset of 'accepts', create a
|
|
|
|
|
new group state, which has the 'remains'. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (not_subset)
|
|
|
|
|
{
|
|
|
|
|
bitset_copy (dests_ch[ndests], remains);
|
|
|
|
|
bitset_copy (dests_ch[j], intersec);
|
|
|
|
|
err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
++ndests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Put the position in the current group. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* If all characters are consumed, go to next node. */
|
|
|
|
|
if (!not_consumed)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Some characters remain, create a new group. */
|
|
|
|
|
if (j == ndests)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
bitset_copy (dests_ch[ndests], accepts);
|
|
|
|
|
err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
++ndests;
|
|
|
|
|
bitset_empty (accepts);
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return ndests;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
error_return:
|
|
|
|
|
for (j = 0; j < ndests; ++j)
|
|
|
|
|
re_node_set_free (dests_node + j);
|
|
|
|
|
return -1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
|
2002-04-26 20:52:02 +00:00
|
|
|
|
Return the number of the bytes the node accepts.
|
|
|
|
|
STR_IDX is the current index of the input string.
|
|
|
|
|
|
|
|
|
|
This function handles the nodes which can accept one character, or
|
|
|
|
|
one collating element like '.', '[a-z]', opposite to the other nodes
|
|
|
|
|
can only accept one byte. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2014-09-11 23:02:17 +00:00
|
|
|
|
# ifdef _LIBC
|
|
|
|
|
# include <locale/weight.h>
|
|
|
|
|
# endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static int
|
2017-12-20 11:47:44 +00:00
|
|
|
|
check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
|
|
|
|
|
const re_string_t *input, Idx str_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
const re_token_t *node = dfa->nodes + node_idx;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
int char_len, elem_len;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
|
2003-11-18 23:40:59 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char c = re_string_byte_at (input, str_idx), d;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (c < 0xc2))
|
2003-11-18 23:40:59 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (str_idx + 2 > input->len)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
d = re_string_byte_at (input, str_idx + 1);
|
|
|
|
|
if (c < 0xe0)
|
|
|
|
|
return (d < 0x80 || d > 0xbf) ? 0 : 2;
|
|
|
|
|
else if (c < 0xf0)
|
|
|
|
|
{
|
|
|
|
|
char_len = 3;
|
|
|
|
|
if (c == 0xe0 && d < 0xa0)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (c < 0xf8)
|
|
|
|
|
{
|
|
|
|
|
char_len = 4;
|
|
|
|
|
if (c == 0xf0 && d < 0x90)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (c < 0xfc)
|
|
|
|
|
{
|
|
|
|
|
char_len = 5;
|
|
|
|
|
if (c == 0xf8 && d < 0x88)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (c < 0xfe)
|
|
|
|
|
{
|
|
|
|
|
char_len = 6;
|
|
|
|
|
if (c == 0xfc && d < 0x84)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (str_idx + char_len > input->len)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < char_len; ++i)
|
|
|
|
|
{
|
|
|
|
|
d = re_string_byte_at (input, str_idx + i);
|
|
|
|
|
if (d < 0x80 || d > 0xbf)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return char_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char_len = re_string_char_size_at (input, str_idx);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (node->type == OP_PERIOD)
|
|
|
|
|
{
|
2003-11-18 23:40:59 +00:00
|
|
|
|
if (char_len <= 1)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return 0;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
/* FIXME: I don't think this if is needed, as both '\n'
|
|
|
|
|
and '\0' are char_len == 1. */
|
2002-04-26 20:52:02 +00:00
|
|
|
|
/* '.' accepts any one character except the following two cases. */
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_string_byte_at (input, str_idx) == '\n') ||
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
((dfa->syntax & RE_DOT_NOT_NULL) &&
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_string_byte_at (input, str_idx) == '\0'))
|
|
|
|
|
return 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return char_len;
|
|
|
|
|
}
|
2003-11-18 23:40:59 +00:00
|
|
|
|
|
|
|
|
|
elem_len = re_string_elem_size_at (input, str_idx);
|
2004-02-11 22:49:57 +00:00
|
|
|
|
if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
|
2003-11-18 23:40:59 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (node->type == COMPLEX_BRACKET)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
const re_charset_t *cset = node->opr.mbcset;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# ifdef _LIBC
|
2005-03-06 07:27:56 +00:00
|
|
|
|
const unsigned char *pin
|
|
|
|
|
= ((const unsigned char *) re_string_get_buffer (input) + str_idx);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx j;
|
2003-11-18 07:25:02 +00:00
|
|
|
|
uint32_t nrules;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# endif /* _LIBC */
|
|
|
|
|
int match_len = 0;
|
|
|
|
|
wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
? re_string_wchar_at (input, str_idx) : 0);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
|
|
|
|
|
/* match with multibyte character? */
|
|
|
|
|
for (i = 0; i < cset->nmbchars; ++i)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (wc == cset->mbchars[i])
|
|
|
|
|
{
|
|
|
|
|
match_len = char_len;
|
|
|
|
|
goto check_node_accept_bytes_match;
|
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
/* match with character_class? */
|
|
|
|
|
for (i = 0; i < cset->nchar_classes; ++i)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
wctype_t wt = cset->char_classes[i];
|
|
|
|
|
if (__iswctype (wc, wt))
|
|
|
|
|
{
|
|
|
|
|
match_len = char_len;
|
|
|
|
|
goto check_node_accept_bytes_match;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
|
|
|
|
|
# ifdef _LIBC
|
2003-11-18 07:25:02 +00:00
|
|
|
|
nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (nrules != 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int in_collseq = 0;
|
|
|
|
|
const int32_t *table, *indirect;
|
|
|
|
|
const unsigned char *weights, *extra;
|
|
|
|
|
const char *collseqwc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* match with collating_symbol? */
|
|
|
|
|
if (cset->ncoll_syms)
|
|
|
|
|
extra = (const unsigned char *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
|
|
|
|
|
for (i = 0; i < cset->ncoll_syms; ++i)
|
|
|
|
|
{
|
|
|
|
|
const unsigned char *coll_sym = extra + cset->coll_syms[i];
|
|
|
|
|
/* Compare the length of input collating element and
|
|
|
|
|
the length of current collating element. */
|
|
|
|
|
if (*coll_sym != elem_len)
|
|
|
|
|
continue;
|
|
|
|
|
/* Compare each bytes. */
|
|
|
|
|
for (j = 0; j < *coll_sym; j++)
|
|
|
|
|
if (pin[j] != coll_sym[1 + j])
|
|
|
|
|
break;
|
|
|
|
|
if (j == *coll_sym)
|
|
|
|
|
{
|
|
|
|
|
/* Match if every bytes is equal. */
|
|
|
|
|
match_len = j;
|
|
|
|
|
goto check_node_accept_bytes_match;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cset->nranges)
|
|
|
|
|
{
|
|
|
|
|
if (elem_len <= char_len)
|
|
|
|
|
{
|
|
|
|
|
collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
|
2003-06-13 21:05:42 +00:00
|
|
|
|
in_collseq = __collseq_table_lookup (collseqwc, wc);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
in_collseq = find_collation_sequence_value (pin, elem_len);
|
|
|
|
|
}
|
|
|
|
|
/* match with range expression? */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* FIXME: Implement rational ranges here, too. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
for (i = 0; i < cset->nranges; ++i)
|
|
|
|
|
if (cset->range_starts[i] <= in_collseq
|
|
|
|
|
&& in_collseq <= cset->range_ends[i])
|
|
|
|
|
{
|
|
|
|
|
match_len = elem_len;
|
|
|
|
|
goto check_node_accept_bytes_match;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* match with equivalence_class? */
|
|
|
|
|
if (cset->nequiv_classes)
|
|
|
|
|
{
|
|
|
|
|
const unsigned char *cp = pin;
|
|
|
|
|
table = (const int32_t *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
|
|
|
|
weights = (const unsigned char *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
|
|
|
|
|
extra = (const unsigned char *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
|
|
|
|
|
indirect = (const int32_t *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
|
2014-09-11 23:02:17 +00:00
|
|
|
|
int32_t idx = findidx (table, indirect, extra, &cp, elem_len);
|
2018-07-10 09:18:26 +00:00
|
|
|
|
int32_t rule = idx >> 24;
|
|
|
|
|
idx &= 0xffffff;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (idx > 0)
|
2018-07-10 09:18:26 +00:00
|
|
|
|
{
|
|
|
|
|
size_t weight_len = weights[idx];
|
|
|
|
|
for (i = 0; i < cset->nequiv_classes; ++i)
|
|
|
|
|
{
|
|
|
|
|
int32_t equiv_class_idx = cset->equiv_classes[i];
|
|
|
|
|
int32_t equiv_class_rule = equiv_class_idx >> 24;
|
|
|
|
|
equiv_class_idx &= 0xffffff;
|
|
|
|
|
if (weights[equiv_class_idx] == weight_len
|
|
|
|
|
&& equiv_class_rule == rule
|
|
|
|
|
&& memcmp (weights + idx + 1,
|
|
|
|
|
weights + equiv_class_idx + 1,
|
|
|
|
|
weight_len) == 0)
|
|
|
|
|
{
|
|
|
|
|
match_len = elem_len;
|
|
|
|
|
goto check_node_accept_bytes_match;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
else
|
|
|
|
|
# endif /* _LIBC */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* match with range expression? */
|
|
|
|
|
for (i = 0; i < cset->nranges; ++i)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
match_len = char_len;
|
|
|
|
|
goto check_node_accept_bytes_match;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
check_node_accept_bytes_match:
|
|
|
|
|
if (!cset->non_match)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return match_len;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (match_len > 0)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return (elem_len > char_len) ? elem_len : char_len;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# ifdef _LIBC
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static unsigned int
|
2005-10-13 20:08:58 +00:00
|
|
|
|
find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
|
|
|
|
if (nrules == 0)
|
|
|
|
|
{
|
|
|
|
|
if (mbs_len == 1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* No valid character. Match it as a single byte character. */
|
|
|
|
|
const unsigned char *collseq = (const unsigned char *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
|
|
|
|
|
return collseq[mbs[0]];
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return UINT_MAX;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int32_t idx;
|
|
|
|
|
const unsigned char *extra = (const unsigned char *)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
|
2004-02-11 22:49:57 +00:00
|
|
|
|
int32_t extrasize = (const unsigned char *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-02-11 22:49:57 +00:00
|
|
|
|
for (idx = 0; idx < extrasize;)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
int mbs_cnt;
|
|
|
|
|
bool found = false;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
int32_t elem_mbs_len;
|
|
|
|
|
/* Skip the name of collating element name. */
|
|
|
|
|
idx = idx + extra[idx] + 1;
|
|
|
|
|
elem_mbs_len = extra[idx++];
|
|
|
|
|
if (mbs_len == elem_mbs_len)
|
|
|
|
|
{
|
|
|
|
|
for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt)
|
|
|
|
|
if (extra[idx + mbs_cnt] != mbs[mbs_cnt])
|
|
|
|
|
break;
|
|
|
|
|
if (mbs_cnt == elem_mbs_len)
|
|
|
|
|
/* Found the entry. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
found = true;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
/* Skip the byte sequence of the collating element. */
|
|
|
|
|
idx += elem_mbs_len;
|
|
|
|
|
/* Adjust for the alignment. */
|
|
|
|
|
idx = (idx + 3) & ~3;
|
|
|
|
|
/* Skip the collation sequence value. */
|
|
|
|
|
idx += sizeof (uint32_t);
|
|
|
|
|
/* Skip the wide char sequence of the collating element. */
|
2010-05-05 16:59:25 +00:00
|
|
|
|
idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* If we found the entry, return the sequence value. */
|
|
|
|
|
if (found)
|
|
|
|
|
return *(uint32_t *) (extra + idx);
|
|
|
|
|
/* Skip the collation sequence value. */
|
|
|
|
|
idx += sizeof (uint32_t);
|
|
|
|
|
}
|
2004-02-11 22:49:57 +00:00
|
|
|
|
return UINT_MAX;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# endif /* _LIBC */
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Check whether the node accepts the byte which is IDX-th
|
|
|
|
|
byte of the INPUT. */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static bool
|
2005-10-13 20:08:58 +00:00
|
|
|
|
check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char ch;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
ch = re_string_byte_at (&mctx->input, idx);
|
2003-11-18 23:40:59 +00:00
|
|
|
|
switch (node->type)
|
|
|
|
|
{
|
|
|
|
|
case CHARACTER:
|
2004-12-10 04:37:58 +00:00
|
|
|
|
if (node->opr.c != ch)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-11-18 23:40:59 +00:00
|
|
|
|
case SIMPLE_BRACKET:
|
2004-12-10 04:37:58 +00:00
|
|
|
|
if (!bitset_contain (node->opr.sbcset, ch))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2003-11-18 23:40:59 +00:00
|
|
|
|
case OP_UTF8_PERIOD:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (ch >= ASCII_CHARS)
|
|
|
|
|
return false;
|
|
|
|
|
FALLTHROUGH;
|
2003-12-16 06:16:27 +00:00
|
|
|
|
#endif
|
2003-11-18 23:40:59 +00:00
|
|
|
|
case OP_PERIOD:
|
2004-12-10 04:37:58 +00:00
|
|
|
|
if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
|
|
|
|
|
|| (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-11-18 23:40:59 +00:00
|
|
|
|
default:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
}
|
2004-12-10 04:37:58 +00:00
|
|
|
|
|
|
|
|
|
if (node->constraint)
|
|
|
|
|
{
|
|
|
|
|
/* The node has constraints. Check whether the current context
|
|
|
|
|
satisfies the constraints. */
|
|
|
|
|
unsigned int context = re_string_context_at (&mctx->input, idx,
|
|
|
|
|
mctx->eflags);
|
|
|
|
|
if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return false;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return true;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
/* Extend the buffers, if the buffers have run out. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2013-01-29 13:45:15 +00:00
|
|
|
|
extend_buffers (re_match_context_t *mctx, int min_len)
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t ret;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
re_string_t *pstr = &mctx->input;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2010-01-22 20:41:12 +00:00
|
|
|
|
/* Avoid overflow. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
|
|
|
|
|
<= pstr->bufs_len))
|
2010-01-22 20:41:12 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Double the lengths of the buffers, but allocate at least MIN_LEN. */
|
2013-01-29 13:45:15 +00:00
|
|
|
|
ret = re_string_realloc_buffers (pstr,
|
|
|
|
|
MAX (min_len,
|
|
|
|
|
MIN (pstr->len, pstr->bufs_len * 2)));
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-04-24 21:54:53 +00:00
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
if (mctx->state_log != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* And double the length of state_log. */
|
2003-11-23 19:21:23 +00:00
|
|
|
|
/* XXX We have no indication of the size of this buffer. If this
|
|
|
|
|
allocation fail we have no indication that the state_log array
|
|
|
|
|
does not have the right size. */
|
|
|
|
|
re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
|
|
|
|
|
pstr->bufs_len + 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_array == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
mctx->state_log = new_array;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Then reconstruct the buffers. */
|
|
|
|
|
if (pstr->icase)
|
|
|
|
|
{
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
2003-11-12 17:47:46 +00:00
|
|
|
|
if (pstr->mb_cur_max > 1)
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
{
|
|
|
|
|
ret = build_wcs_upper_buffer (pstr);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
build_upper_buffer (pstr);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
2003-11-12 17:47:46 +00:00
|
|
|
|
if (pstr->mb_cur_max > 1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
build_wcs_buffer (pstr);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (pstr->trans != NULL)
|
|
|
|
|
re_string_translate_buffer (pstr);
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Functions for matching context. */
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Initialize MCTX. */
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
mctx->eflags = eflags;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
mctx->match_last = -1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (n > 0)
|
2002-02-28 07:43:13 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Avoid overflow. */
|
|
|
|
|
size_t max_object_size =
|
|
|
|
|
MAX (sizeof (struct re_backref_cache_entry),
|
|
|
|
|
sizeof (re_sub_match_top_t *));
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
}
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
/* Already zero-ed by the caller.
|
|
|
|
|
else
|
|
|
|
|
mctx->bkref_ents = NULL;
|
|
|
|
|
mctx->nbkref_ents = 0;
|
|
|
|
|
mctx->nsub_tops = 0; */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mctx->abkref_ents = n;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
mctx->max_mb_elem_len = 1;
|
|
|
|
|
mctx->asub_tops = n;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Clean the entries which depend on the current input in MCTX.
|
|
|
|
|
This function must be invoked when the matcher changes the start index
|
|
|
|
|
of the input, or changes the input string. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-13 20:08:58 +00:00
|
|
|
|
match_ctx_clean (re_match_context_t *mctx)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx st_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx sl_idx;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_sub_match_top_t *top = mctx->sub_tops[st_idx];
|
|
|
|
|
for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
|
|
|
|
|
{
|
|
|
|
|
re_sub_match_last_t *last = top->lasts[sl_idx];
|
|
|
|
|
re_free (last->path.array);
|
|
|
|
|
re_free (last);
|
|
|
|
|
}
|
|
|
|
|
re_free (top->lasts);
|
|
|
|
|
if (top->path)
|
|
|
|
|
{
|
|
|
|
|
re_free (top->path->array);
|
|
|
|
|
re_free (top->path);
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (top);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
2004-11-10 18:51:26 +00:00
|
|
|
|
|
|
|
|
|
mctx->nsub_tops = 0;
|
|
|
|
|
mctx->nbkref_ents = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free all the memory associated with MCTX. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-13 20:08:58 +00:00
|
|
|
|
match_ctx_free (re_match_context_t *mctx)
|
2004-11-10 18:51:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* First, free all the memory associated with MCTX->SUB_TOPS. */
|
|
|
|
|
match_ctx_clean (mctx);
|
|
|
|
|
re_free (mctx->sub_tops);
|
|
|
|
|
re_free (mctx->bkref_ents);
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add a new backreference entry to MCTX.
|
|
|
|
|
Note that we assume that caller never call this function with duplicate
|
|
|
|
|
entry, and call with STR_IDX which isn't smaller than any existing entry.
|
|
|
|
|
*/
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
|
|
|
|
|
Idx to)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (mctx->nbkref_ents >= mctx->abkref_ents)
|
|
|
|
|
{
|
2002-11-06 19:57:50 +00:00
|
|
|
|
struct re_backref_cache_entry* new_entry;
|
|
|
|
|
new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
mctx->abkref_ents * 2);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_entry == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (mctx->bkref_ents);
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
mctx->bkref_ents = new_entry;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
|
2002-11-06 20:36:47 +00:00
|
|
|
|
sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mctx->abkref_ents *= 2;
|
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (mctx->nbkref_ents > 0
|
|
|
|
|
&& mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx)
|
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1;
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents].node = node;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
|
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
|
2004-11-12 09:45:05 +00:00
|
|
|
|
|
|
|
|
|
/* This is a cache that saves negative results of check_dst_limits_calc_pos.
|
|
|
|
|
If bit N is clear, means that this entry won't epsilon-transition to
|
|
|
|
|
an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If
|
|
|
|
|
it is set, check_dst_limits_calc_pos_1 will recurse and try to find one
|
|
|
|
|
such node.
|
|
|
|
|
|
|
|
|
|
A backreference does not epsilon-transition unless it is empty, so set
|
|
|
|
|
to all zeros if FROM != TO. */
|
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map
|
2017-12-20 11:47:44 +00:00
|
|
|
|
= (from == to ? -1 : 0);
|
2004-11-12 09:45:05 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
if (mctx->max_mb_elem_len < to - from)
|
|
|
|
|
mctx->max_mb_elem_len = to - from;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Return the first entry with the same str_idx, or -1 if none is
|
2004-11-08 22:49:44 +00:00
|
|
|
|
found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
|
|
|
|
search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx left, right, mid, last;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
last = right = mctx->nbkref_ents;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
for (left = 0; left < right;)
|
|
|
|
|
{
|
|
|
|
|
mid = (left + right) / 2;
|
|
|
|
|
if (mctx->bkref_ents[mid].str_idx < str_idx)
|
|
|
|
|
left = mid + 1;
|
|
|
|
|
else
|
|
|
|
|
right = mid;
|
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
|
|
|
|
|
return left;
|
|
|
|
|
else
|
|
|
|
|
return -1;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
|
|
|
|
|
at STR_IDX. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute_warn_unused_result__
|
2017-12-20 11:47:44 +00:00
|
|
|
|
match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
assert (mctx->sub_tops != NULL);
|
|
|
|
|
assert (mctx->asub_tops > 0);
|
|
|
|
|
#endif
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx new_asub_tops = mctx->asub_tops * 2;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
|
|
|
|
|
re_sub_match_top_t *,
|
|
|
|
|
new_asub_tops);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_array == NULL))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
mctx->sub_tops = new_array;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
mctx->asub_tops = new_asub_tops;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
mctx->sub_tops[mctx->nsub_tops]->node = node;
|
|
|
|
|
mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
|
|
|
|
|
at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */
|
|
|
|
|
|
|
|
|
|
static re_sub_match_last_t *
|
2017-12-20 11:47:44 +00:00
|
|
|
|
match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
re_sub_match_last_t *new_entry;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (subtop->nlasts == subtop->alasts))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx new_alasts = 2 * subtop->alasts + 1;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
|
|
|
|
|
re_sub_match_last_t *,
|
|
|
|
|
new_alasts);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_array == NULL))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
subtop->lasts = new_array;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
subtop->alasts = new_alasts;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
new_entry = calloc (1, sizeof (re_sub_match_last_t));
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (new_entry != NULL))
|
2003-11-23 19:21:23 +00:00
|
|
|
|
{
|
|
|
|
|
subtop->lasts[subtop->nlasts] = new_entry;
|
|
|
|
|
new_entry->node = node;
|
|
|
|
|
new_entry->str_idx = str_idx;
|
|
|
|
|
++subtop->nlasts;
|
|
|
|
|
}
|
2002-11-27 23:00:16 +00:00
|
|
|
|
return new_entry;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
static void
|
2005-10-13 20:08:58 +00:00
|
|
|
|
sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
|
2002-09-28 05:28:44 +00:00
|
|
|
|
{
|
|
|
|
|
sctx->sifted_states = sifted_sts;
|
|
|
|
|
sctx->limited_states = limited_sts;
|
|
|
|
|
sctx->last_node = last_node;
|
|
|
|
|
sctx->last_str_idx = last_str_idx;
|
|
|
|
|
re_node_set_init_empty (&sctx->limits);
|
|
|
|
|
}
|