2002-02-26 19:06:03 +00:00
|
|
|
|
/* Extended regular expression matching and search library.
|
2023-01-06 21:08:04 +00:00
|
|
|
|
Copyright (C) 2002-2023 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
|
|
|
|
|
2014-09-11 23:02:17 +00:00
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
# include <locale/weight.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
|
* 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
|
|
|
|
size_t length, reg_syntax_t syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static void re_compile_fastmap_iter (regex_t *bufp,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
const re_dfastate_t *init_state,
|
|
|
|
|
char *fastmap);
|
* 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 reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static void free_charset (re_charset_t *cset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static void free_workarea_compile (regex_t *preg);
|
|
|
|
|
static reg_errcode_t create_initial_state (re_dfa_t *dfa);
|
2003-11-12 19:09:20 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
static void optimize_utf8 (re_dfa_t *dfa);
|
|
|
|
|
#endif
|
[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
|
|
|
|
static reg_errcode_t analyze (regex_t *preg);
|
|
|
|
|
static reg_errcode_t preorder (bin_tree_t *root,
|
|
|
|
|
reg_errcode_t (fn (void *, bin_tree_t *)),
|
|
|
|
|
void *extra);
|
|
|
|
|
static reg_errcode_t postorder (bin_tree_t *root,
|
|
|
|
|
reg_errcode_t (fn (void *, bin_tree_t *)),
|
|
|
|
|
void *extra);
|
|
|
|
|
static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node);
|
|
|
|
|
static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node);
|
|
|
|
|
static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
|
|
|
|
|
bin_tree_t *node);
|
|
|
|
|
static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
|
|
|
|
|
static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
|
|
|
|
|
static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint);
|
|
|
|
|
static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
|
2002-12-17 10:58:04 +00:00
|
|
|
|
unsigned int constraint);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node, bool root);
|
2005-01-27 19:08:10 +00:00
|
|
|
|
static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx fetch_number (re_string_t *input, re_token_t *token,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
reg_syntax_t syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static int peek_token (re_token_t *token, re_string_t *input,
|
2017-08-31 16:25:55 +00:00
|
|
|
|
reg_syntax_t syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
reg_syntax_t syntax, reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_token_t *token, reg_syntax_t syntax,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nest, reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_token_t *token, reg_syntax_t syntax,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nest, reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_token_t *token, reg_syntax_t syntax,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nest, reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_token_t *token, reg_syntax_t syntax,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nest, reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_dfa_t *dfa, re_token_t *token,
|
|
|
|
|
reg_syntax_t syntax, reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_token_t *token, reg_syntax_t syntax,
|
|
|
|
|
reg_errcode_t *err);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_string_t *regexp,
|
|
|
|
|
re_token_t *token, int token_len,
|
|
|
|
|
re_dfa_t *dfa,
|
2003-11-13 20:04:16 +00:00
|
|
|
|
reg_syntax_t syntax,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool accept_hyphen);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_string_t *regexp,
|
|
|
|
|
re_token_t *token);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
[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
|
|
|
|
static reg_errcode_t build_equiv_class (bitset_t sbcset,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_charset_t *mbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *equiv_class_alloc,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
const unsigned char *name);
|
2005-09-23 06:11:29 +00:00
|
|
|
|
static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
|
[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 sbcset,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_charset_t *mbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *char_class_alloc,
|
|
|
|
|
const char *class_name,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
reg_syntax_t syntax);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#else /* not RE_ENABLE_I18N */
|
[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
|
|
|
|
static reg_errcode_t build_equiv_class (bitset_t sbcset,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
const unsigned char *name);
|
2005-09-23 06:11:29 +00:00
|
|
|
|
static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
|
[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 sbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *class_name,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
reg_syntax_t syntax);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2004-01-06 21:59:24 +00:00
|
|
|
|
static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
|
2005-09-23 06:11:29 +00:00
|
|
|
|
RE_TRANSLATE_TYPE trans,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *class_name,
|
|
|
|
|
const char *extra,
|
|
|
|
|
bool non_match, reg_errcode_t *err);
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
static bin_tree_t *create_tree (re_dfa_t *dfa,
|
|
|
|
|
bin_tree_t *left, bin_tree_t *right,
|
[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);
|
|
|
|
|
static bin_tree_t *create_token_tree (re_dfa_t *dfa,
|
|
|
|
|
bin_tree_t *left, bin_tree_t *right,
|
|
|
|
|
const re_token_t *token);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
|
[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
|
|
|
|
static void free_token (re_token_t *node);
|
|
|
|
|
static reg_errcode_t free_tree (void *extra, bin_tree_t *node);
|
|
|
|
|
static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* This table gives an error message for each of the error codes listed
|
|
|
|
|
in regex.h. Obviously the order here has to be same as there.
|
|
|
|
|
POSIX doesn't require that we do anything for REG_NOERROR,
|
|
|
|
|
but why not be nice? */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static const char __re_error_msgid[] =
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
#define REG_NOERROR_IDX 0
|
|
|
|
|
gettext_noop ("Success") /* REG_NOERROR */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
|
|
|
|
|
gettext_noop ("No match") /* REG_NOMATCH */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
|
|
|
|
|
gettext_noop ("Invalid regular expression") /* REG_BADPAT */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
|
|
|
|
|
gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
|
|
|
|
|
gettext_noop ("Invalid character class name") /* REG_ECTYPE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
|
|
|
|
|
gettext_noop ("Trailing backslash") /* REG_EESCAPE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
|
|
|
|
|
gettext_noop ("Invalid back reference") /* REG_ESUBREG */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
|
2017-12-20 11:47:44 +00:00
|
|
|
|
gettext_noop ("Unmatched [, [^, [:, [., or [=") /* REG_EBRACK */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
"\0"
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [, [^, [:, [., or [=")
|
2002-02-26 19:06:03 +00:00
|
|
|
|
gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
|
|
|
|
|
gettext_noop ("Unmatched \\{") /* REG_EBRACE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
|
|
|
|
|
gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
|
|
|
|
|
gettext_noop ("Invalid range end") /* REG_ERANGE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
|
|
|
|
|
gettext_noop ("Memory exhausted") /* REG_ESPACE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
|
|
|
|
|
gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
|
|
|
|
|
gettext_noop ("Premature end of regular expression") /* REG_EEND */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
|
|
|
|
|
gettext_noop ("Regular expression too big") /* REG_ESIZE */
|
|
|
|
|
"\0"
|
|
|
|
|
#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
|
|
|
|
|
gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static const size_t __re_error_msgid_idx[] =
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
REG_NOERROR_IDX,
|
|
|
|
|
REG_NOMATCH_IDX,
|
|
|
|
|
REG_BADPAT_IDX,
|
|
|
|
|
REG_ECOLLATE_IDX,
|
|
|
|
|
REG_ECTYPE_IDX,
|
|
|
|
|
REG_EESCAPE_IDX,
|
|
|
|
|
REG_ESUBREG_IDX,
|
|
|
|
|
REG_EBRACK_IDX,
|
|
|
|
|
REG_EPAREN_IDX,
|
|
|
|
|
REG_EBRACE_IDX,
|
|
|
|
|
REG_BADBR_IDX,
|
|
|
|
|
REG_ERANGE_IDX,
|
|
|
|
|
REG_ESPACE_IDX,
|
|
|
|
|
REG_BADRPT_IDX,
|
|
|
|
|
REG_EEND_IDX,
|
|
|
|
|
REG_ESIZE_IDX,
|
|
|
|
|
REG_ERPAREN_IDX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Entry points for GNU code. */
|
|
|
|
|
|
|
|
|
|
/* re_compile_pattern is the GNU regular expression compiler: it
|
2002-07-27 08:20:17 +00:00
|
|
|
|
compiles PATTERN (of length LENGTH) and puts the result in BUFP.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
Returns 0 if the pattern was valid, otherwise an error string.
|
|
|
|
|
|
2015-03-10 20:53:34 +00:00
|
|
|
|
Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields
|
2002-02-26 19:06:03 +00:00
|
|
|
|
are set in BUFP on entry. */
|
|
|
|
|
|
|
|
|
|
const char *
|
2015-10-20 11:54:09 +00:00
|
|
|
|
re_compile_pattern (const char *pattern, size_t length,
|
|
|
|
|
struct re_pattern_buffer *bufp)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t ret;
|
|
|
|
|
|
|
|
|
|
/* And GNU code determines whether or not to get register information
|
|
|
|
|
by passing null for the REGS argument to re_match, etc., not by
|
2004-11-18 23:57:34 +00:00
|
|
|
|
setting no_sub, unless RE_NO_SUB is set. */
|
|
|
|
|
bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Match anchors at newline. */
|
|
|
|
|
bufp->newline_anchor = 1;
|
|
|
|
|
|
2002-09-05 03:33:58 +00:00
|
|
|
|
ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
|
return NULL;
|
2002-03-13 08:59:47 +00:00
|
|
|
|
return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
weak_alias (__re_compile_pattern, re_compile_pattern)
|
|
|
|
|
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
|
2002-02-26 19:06:03 +00:00
|
|
|
|
also be assigned to arbitrarily: each pattern buffer stores its own
|
|
|
|
|
syntax, so it can be changed between regex compilations. */
|
|
|
|
|
/* This has no initializer because initialized variables in Emacs
|
|
|
|
|
become read-only after dumping. */
|
|
|
|
|
reg_syntax_t re_syntax_options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Specify the precise syntax of regexps for compilation. This provides
|
|
|
|
|
for compatibility for various utilities which historically have
|
|
|
|
|
different, incompatible syntaxes.
|
|
|
|
|
|
|
|
|
|
The argument SYNTAX is a bit mask comprised of the various bits
|
|
|
|
|
defined in regex.h. We return the old syntax. */
|
|
|
|
|
|
|
|
|
|
reg_syntax_t
|
2015-10-20 11:54:09 +00:00
|
|
|
|
re_set_syntax (reg_syntax_t syntax)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
reg_syntax_t ret = re_syntax_options;
|
|
|
|
|
|
|
|
|
|
re_syntax_options = syntax;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
weak_alias (__re_set_syntax, re_set_syntax)
|
|
|
|
|
|
|
|
|
|
int
|
2015-10-20 11:54:09 +00:00
|
|
|
|
re_compile_fastmap (struct re_pattern_buffer *bufp)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = bufp->buffer;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
char *fastmap = bufp->fastmap;
|
|
|
|
|
|
|
|
|
|
memset (fastmap, '\0', sizeof (char) * SBC_MAX);
|
|
|
|
|
re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
|
|
|
|
|
if (dfa->init_state != dfa->init_state_word)
|
|
|
|
|
re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
|
|
|
|
|
if (dfa->init_state != dfa->init_state_nl)
|
|
|
|
|
re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
|
|
|
|
|
if (dfa->init_state != dfa->init_state_begbuf)
|
|
|
|
|
re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
|
|
|
|
|
bufp->fastmap_accurate = 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
weak_alias (__re_compile_fastmap, re_compile_fastmap)
|
|
|
|
|
|
2002-11-06 19:57:50 +00:00
|
|
|
|
static inline void
|
2015-03-10 20:53:34 +00:00
|
|
|
|
__attribute__ ((always_inline))
|
|
|
|
|
re_set_fastmap (char *fastmap, bool icase, int ch)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
fastmap[ch] = 1;
|
|
|
|
|
if (icase)
|
|
|
|
|
fastmap[tolower (ch)] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Helper function for re_compile_fastmap.
|
|
|
|
|
Compile fastmap for the initial_state INIT_STATE. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-13 20:40:05 +00:00
|
|
|
|
re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
|
|
|
|
|
char *fastmap)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = bufp->buffer;
|
|
|
|
|
Idx node_cnt;
|
|
|
|
|
bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node = init_state->nodes.elems[node_cnt];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[node].type;
|
|
|
|
|
|
|
|
|
|
if (type == CHARACTER)
|
2003-11-12 06:13:10 +00:00
|
|
|
|
{
|
|
|
|
|
re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2003-11-12 19:09:20 +00:00
|
|
|
|
if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
|
2003-11-12 06:13:10 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
unsigned char buf[MB_LEN_MAX];
|
|
|
|
|
unsigned char *p;
|
2003-11-12 06:13:10 +00:00
|
|
|
|
wchar_t wc;
|
|
|
|
|
mbstate_t state;
|
|
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
|
*p++ = dfa->nodes[node].opr.c;
|
|
|
|
|
while (++node < dfa->nodes_len
|
|
|
|
|
&& dfa->nodes[node].type == CHARACTER
|
|
|
|
|
&& dfa->nodes[node].mb_partial)
|
|
|
|
|
*p++ = dfa->nodes[node].opr.c;
|
[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
|
|
|
|
memset (&state, '\0', sizeof (state));
|
2009-01-08 00:23:09 +00:00
|
|
|
|
if (__mbrtowc (&wc, (const char *) buf, p - buf,
|
|
|
|
|
&state) == p - buf
|
2015-06-05 20:04:47 +00:00
|
|
|
|
&& (__wcrtomb ((char *) buf, __towlower (wc), &state)
|
[BZ #779]
2005-03-10 Jakub Jelinek <jakub@redhat.com>
* math/test-misc.c (main): Add some more tests.
2005-03-17 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c (re_compile_fastmap_iter): Fix check for failed
__wcrtomb. Check return values of other __wcrtomb calls.
* posix/regex_internal.c (build_wcs_buffer, re_string_skip_chars):
Change mbclen type to size_t.
(build_wcs_upper_buffer): Change mbclen and mbcdlen type to size_t.
Handle mb chars whose upper case doesn't have multibyte representation
in locale's charset.
2005-03-15 Jakub Jelinek <jakub@redhat.com>
* malloc/malloc.c (_int_icalloc, _int_icomalloc, iALLOc,
public_iCALLOc, public_iCALLOc, public_iCOMALLOc): Protect with
#ifndef _LIBC.
[BZ #779]
* malloc/malloc.c (public_mTRIm): Initialize malloc if not yet
initialized.
2005-03-10 Jakub Jelinek <jakub@redhat.com>
* misc/sys/cdefs.h (__always_inline): Define.
* posix/bits/unistd.h (read, pread, pread64, readlink, getcwd, getwd):
Use __always_inline instead of __inline.
* socket/bits/socket2.h (recv, recvfrom): Likewise.
* libio/bits/stdio2.h (gets, fgets, fgets_unlocked): Likewise.
* string/bits/string3.h (__memcpy_ichk, __memmove_ichk, __mempcpy_ichk,
__memset_ichk, __strcpy_ichk, __stpcpy_ichk, __strncpy_ichk,
__strcat_ichk, __strncat_ichk): Use __always_inline instead of
__inline__ __attribute__ ((__always_inline__)).
2005-03-09 Jakub Jelinek <jakub@redhat.com>
* debug/tst-chk1.c: Include sys/socket.h and sys/un.h.
(do_test): Add new tests for recv, recvfrom, getcwd, getwd and
readlink. Add some more tests for read, pread, pread64, fgets and
fgets_unlocked.
* posix/bits/unistd.h (read, pread, pread64, readlink,
getcwd, getwd): Change macros into extern inline functions.
(__read_alias, __pread_alias, __pread64_alias, __readlink_alias,
__getcwd_alias, __getwd_alias): New prototypes.
* socket/bits/socket2.h (recv, recvfrom): Change macros into
extern inline functions.
(__recv_alias, __recvfrom_alias): New prototypes.
* libio/bits/stdio2.h (gets, fgets, fgets_unlocked): Change macros
into extern inline functions.
(__gets_alias, __fgets_alias, __fgets_unlocked_alias): New prototypes.
* debug/pread_chk.c (__pread_chk): Fix order of arguments passed
to __pread.
* debug/pread64_chk.c (__pread64_chk): Fix order of arguments passed
to __pread64.
2005-03-19 00:28:51 +00:00
|
|
|
|
!= (size_t) -1))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_set_fastmap (fastmap, false, buf[0]);
|
2003-11-12 06:13:10 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (type == SIMPLE_BRACKET)
|
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
|
|
|
|
int i, ch;
|
|
|
|
|
for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
|
|
|
|
|
{
|
|
|
|
|
int j;
|
|
|
|
|
bitset_word_t w = dfa->nodes[node].opr.sbcset[i];
|
|
|
|
|
for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
|
|
|
|
|
if (w & ((bitset_word_t) 1 << j))
|
|
|
|
|
re_set_fastmap (fastmap, icase, ch);
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (type == COMPLEX_BRACKET)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_charset_t *cset = dfa->nodes[node].opr.mbcset;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
2009-01-08 00:42:51 +00:00
|
|
|
|
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef _LIBC
|
2009-01-08 00:42:51 +00:00
|
|
|
|
/* See if we have to try all bytes which start multiple collation
|
|
|
|
|
elements.
|
|
|
|
|
e.g. In da_DK, we want to catch 'a' since "aa" is a valid
|
|
|
|
|
collation element, and don't catch 'b' since 'b' is
|
|
|
|
|
the only collation element which starts from 'b' (and
|
|
|
|
|
it is caught by SIMPLE_BRACKET). */
|
|
|
|
|
if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0
|
|
|
|
|
&& (cset->ncoll_syms || cset->nranges))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
const int32_t *table = (const int32_t *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
[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 < SBC_MAX; ++i)
|
|
|
|
|
if (table[i] < 0)
|
|
|
|
|
re_set_fastmap (fastmap, icase, i);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2009-01-08 00:42:51 +00:00
|
|
|
|
# endif /* _LIBC */
|
|
|
|
|
|
|
|
|
|
/* See if we have to start the match at all multibyte characters,
|
|
|
|
|
i.e. where we would not find an invalid sequence. This only
|
|
|
|
|
applies to multibyte character sets; for single byte character
|
|
|
|
|
sets, the SIMPLE_BRACKET again suffices. */
|
|
|
|
|
if (dfa->mb_cur_max > 1
|
2009-11-18 00:23:24 +00:00
|
|
|
|
&& (cset->nchar_classes || cset->non_match || cset->nranges
|
2009-01-08 00:42:51 +00:00
|
|
|
|
# ifdef _LIBC
|
|
|
|
|
|| cset->nequiv_classes
|
|
|
|
|
# endif /* _LIBC */
|
|
|
|
|
))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2009-01-08 00:42:51 +00:00
|
|
|
|
unsigned char c = 0;
|
|
|
|
|
do
|
2003-11-12 06:13:10 +00:00
|
|
|
|
{
|
2009-01-08 00:42:51 +00:00
|
|
|
|
mbstate_t mbs;
|
|
|
|
|
memset (&mbs, 0, sizeof (mbs));
|
|
|
|
|
if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2)
|
|
|
|
|
re_set_fastmap (fastmap, false, (int) c);
|
2003-11-12 06:13:10 +00:00
|
|
|
|
}
|
2009-01-08 00:42:51 +00:00
|
|
|
|
while (++c != 0);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2009-01-08 00:42:51 +00:00
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* ... Else catch all bytes which can start the mbchars. */
|
|
|
|
|
for (i = 0; i < cset->nmbchars; ++i)
|
|
|
|
|
{
|
|
|
|
|
char buf[256];
|
|
|
|
|
mbstate_t state;
|
|
|
|
|
memset (&state, '\0', sizeof (state));
|
|
|
|
|
if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
|
|
|
|
|
re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
|
|
|
|
|
if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
|
|
|
|
|
{
|
2015-06-05 20:04:47 +00:00
|
|
|
|
if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state)
|
2009-01-08 00:42:51 +00:00
|
|
|
|
!= (size_t) -1)
|
|
|
|
|
re_set_fastmap (fastmap, false, *(unsigned char *) buf);
|
|
|
|
|
}
|
2010-01-15 20:20:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2003-12-16 06:16:27 +00:00
|
|
|
|
else if (type == OP_PERIOD
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
|| type == OP_UTF8_PERIOD
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|| type == END_OF_RE)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
memset (fastmap, '\1', sizeof (char) * SBC_MAX);
|
|
|
|
|
if (type == END_OF_RE)
|
|
|
|
|
bufp->can_be_null = 1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Entry point for POSIX code. */
|
|
|
|
|
/* regcomp takes a regular expression as a string and compiles it.
|
|
|
|
|
|
|
|
|
|
PREG is a regex_t *. We do not expect any fields to be initialized,
|
|
|
|
|
since POSIX says we shouldn't. Thus, we set
|
|
|
|
|
|
2015-03-10 20:53:34 +00:00
|
|
|
|
'buffer' to the compiled pattern;
|
|
|
|
|
'used' to the length of the compiled pattern;
|
|
|
|
|
'syntax' to RE_SYNTAX_POSIX_EXTENDED if the
|
2002-02-26 19:06:03 +00:00
|
|
|
|
REG_EXTENDED bit in CFLAGS is set; otherwise, to
|
|
|
|
|
RE_SYNTAX_POSIX_BASIC;
|
2015-03-10 20:53:34 +00:00
|
|
|
|
'newline_anchor' to REG_NEWLINE being set in CFLAGS;
|
|
|
|
|
'fastmap' to an allocated space for the fastmap;
|
|
|
|
|
'fastmap_accurate' to zero;
|
|
|
|
|
're_nsub' to the number of subexpressions in PATTERN.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
PATTERN is the address of the pattern string.
|
|
|
|
|
|
|
|
|
|
CFLAGS is a series of bits which affect compilation.
|
|
|
|
|
|
|
|
|
|
If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
|
|
|
|
|
use POSIX basic syntax.
|
|
|
|
|
|
|
|
|
|
If REG_NEWLINE is set, then . and [^...] don't match newline.
|
|
|
|
|
Also, regexec will try a match beginning after every newline.
|
|
|
|
|
|
|
|
|
|
If REG_ICASE is set, then we considers upper- and lowercase
|
|
|
|
|
versions of letters to be equivalent when matching.
|
|
|
|
|
|
|
|
|
|
If REG_NOSUB is set, then when PREG is passed to regexec, that
|
|
|
|
|
routine will report only success or failure, and nothing about the
|
|
|
|
|
registers.
|
|
|
|
|
|
|
|
|
|
It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
|
|
|
|
|
the return codes and their meanings.) */
|
|
|
|
|
|
|
|
|
|
int
|
2018-12-26 22:13:43 +00:00
|
|
|
|
regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t ret;
|
|
|
|
|
reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: RE_SYNTAX_POSIX_BASIC);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
preg->buffer = NULL;
|
|
|
|
|
preg->allocated = 0;
|
|
|
|
|
preg->used = 0;
|
|
|
|
|
|
|
|
|
|
/* Try to allocate space for the fastmap. */
|
|
|
|
|
preg->fastmap = re_malloc (char, SBC_MAX);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (preg->fastmap == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
|
|
|
|
syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
|
|
|
|
|
|
|
|
|
|
/* If REG_NEWLINE is set, newlines are treated differently. */
|
|
|
|
|
if (cflags & REG_NEWLINE)
|
|
|
|
|
{ /* REG_NEWLINE implies neither . nor [^...] match newline. */
|
|
|
|
|
syntax &= ~RE_DOT_NEWLINE;
|
|
|
|
|
syntax |= RE_HAT_LISTS_NOT_NEWLINE;
|
|
|
|
|
/* It also changes the matching behavior. */
|
|
|
|
|
preg->newline_anchor = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
preg->newline_anchor = 0;
|
|
|
|
|
preg->no_sub = !!(cflags & REG_NOSUB);
|
|
|
|
|
preg->translate = NULL;
|
|
|
|
|
|
|
|
|
|
ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
|
|
|
|
|
|
|
|
|
|
/* POSIX doesn't distinguish between an unmatched open-group and an
|
|
|
|
|
unmatched close-group: both are REG_EPAREN. */
|
|
|
|
|
if (ret == REG_ERPAREN)
|
|
|
|
|
ret = REG_EPAREN;
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* We have already checked preg->fastmap != NULL. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (ret == REG_NOERROR))
|
2002-11-06 08:34:35 +00:00
|
|
|
|
/* Compute the fastmap now, since regexec cannot modify the pattern
|
2004-01-06 21:59:24 +00:00
|
|
|
|
buffer. This function never fails in this implementation. */
|
2002-12-13 23:45:32 +00:00
|
|
|
|
(void) re_compile_fastmap (preg);
|
2002-11-06 08:34:35 +00:00
|
|
|
|
else
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-11-06 08:34:35 +00:00
|
|
|
|
/* Some error occurred while compiling the expression. */
|
|
|
|
|
re_free (preg->fastmap);
|
|
|
|
|
preg->fastmap = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (int) ret;
|
|
|
|
|
}
|
2017-10-01 22:52:56 +00:00
|
|
|
|
libc_hidden_def (__regcomp)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
weak_alias (__regcomp, regcomp)
|
|
|
|
|
|
|
|
|
|
/* Returns a message corresponding to an error code, ERRCODE, returned
|
|
|
|
|
from either regcomp or regexec. We don't use PREG here. */
|
|
|
|
|
|
|
|
|
|
size_t
|
2018-12-26 22:13:43 +00:00
|
|
|
|
regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
|
2015-10-20 11:54:09 +00:00
|
|
|
|
size_t errbuf_size)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
const char *msg;
|
|
|
|
|
size_t msg_size;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Only error codes returned by the rest of the code should be passed
|
|
|
|
|
to this routine. If we are given anything else, or if other regex
|
|
|
|
|
code generates an invalid error code, then the program has a bug.
|
|
|
|
|
Dump core so we can fix it. */
|
|
|
|
|
abort ();
|
|
|
|
|
|
2002-03-13 08:59:47 +00:00
|
|
|
|
msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
msg_size = strlen (msg) + 1; /* Includes the null. */
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (errbuf_size != 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
size_t cpy_size = msg_size;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (msg_size > errbuf_size))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
cpy_size = errbuf_size - 1;
|
|
|
|
|
errbuf[cpy_size] = '\0';
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
memcpy (errbuf, msg, cpy_size);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return msg_size;
|
|
|
|
|
}
|
|
|
|
|
weak_alias (__regerror, regerror)
|
|
|
|
|
|
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* This static array is used for the map to single-byte characters when
|
|
|
|
|
UTF-8 is used. Otherwise we would allocate memory just to initialize
|
|
|
|
|
it the same all the time. UTF-8 is the preferred encoding so this is
|
|
|
|
|
a worthwhile optimization. */
|
[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
|
|
|
|
static const bitset_t utf8_sb_map =
|
2004-11-08 22:49:44 +00:00
|
|
|
|
{
|
|
|
|
|
/* Set the first 128 bits. */
|
2020-12-29 20:32:25 +00:00
|
|
|
|
# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
|
[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
|
|
|
|
[0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# else
|
|
|
|
|
# if 4 * BITSET_WORD_BITS < ASCII_CHARS
|
|
|
|
|
# error "bitset_word_t is narrower than 32 bits"
|
|
|
|
|
# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
|
|
|
|
|
BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
|
|
|
|
|
# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
|
|
|
|
|
BITSET_WORD_MAX, BITSET_WORD_MAX,
|
|
|
|
|
# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
|
|
|
|
|
BITSET_WORD_MAX,
|
|
|
|
|
# endif
|
|
|
|
|
(BITSET_WORD_MAX
|
|
|
|
|
>> (SBC_MAX % BITSET_WORD_BITS == 0
|
|
|
|
|
? 0
|
|
|
|
|
: BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
|
|
|
|
|
# endif
|
2004-11-08 22:49:44 +00:00
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2002-11-06 08:34:35 +00:00
|
|
|
|
static void
|
|
|
|
|
free_dfa_content (re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i, j;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
if (dfa->nodes)
|
|
|
|
|
for (i = 0; i < dfa->nodes_len; ++i)
|
[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
|
|
|
|
free_token (dfa->nodes + i);
|
2002-11-06 08:34:35 +00:00
|
|
|
|
re_free (dfa->nexts);
|
|
|
|
|
for (i = 0; i < dfa->nodes_len; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (dfa->eclosures != NULL)
|
|
|
|
|
re_node_set_free (dfa->eclosures + i);
|
|
|
|
|
if (dfa->inveclosures != NULL)
|
|
|
|
|
re_node_set_free (dfa->inveclosures + i);
|
|
|
|
|
if (dfa->edests != NULL)
|
|
|
|
|
re_node_set_free (dfa->edests + i);
|
|
|
|
|
}
|
|
|
|
|
re_free (dfa->edests);
|
|
|
|
|
re_free (dfa->eclosures);
|
|
|
|
|
re_free (dfa->inveclosures);
|
|
|
|
|
re_free (dfa->nodes);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
if (dfa->state_table)
|
|
|
|
|
for (i = 0; i <= dfa->state_hash_mask; ++i)
|
|
|
|
|
{
|
|
|
|
|
struct re_state_table_entry *entry = dfa->state_table + i;
|
|
|
|
|
for (j = 0; j < entry->num; ++j)
|
|
|
|
|
{
|
|
|
|
|
re_dfastate_t *state = entry->array[j];
|
|
|
|
|
free_state (state);
|
|
|
|
|
}
|
2010-01-15 05:35:15 +00:00
|
|
|
|
re_free (entry->array);
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
}
|
2002-11-06 08:34:35 +00:00
|
|
|
|
re_free (dfa->state_table);
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (dfa->sb_char != utf8_sb_map)
|
|
|
|
|
re_free (dfa->sb_char);
|
2003-12-29 00:42:16 +00:00
|
|
|
|
#endif
|
2004-11-18 23:57:34 +00:00
|
|
|
|
re_free (dfa->subexp_map);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
#ifdef DEBUG
|
2002-11-06 08:34:35 +00:00
|
|
|
|
re_free (dfa->re_str);
|
2002-09-28 05:28:44 +00:00
|
|
|
|
#endif
|
2002-11-06 08:34:35 +00:00
|
|
|
|
|
|
|
|
|
re_free (dfa);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Free dynamically allocated space used by PREG. */
|
|
|
|
|
|
|
|
|
|
void
|
2015-10-20 11:54:09 +00:00
|
|
|
|
regfree (regex_t *preg)
|
2002-11-06 08:34:35 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (dfa != NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
{
|
|
|
|
|
lock_fini (dfa->lock);
|
|
|
|
|
free_dfa_content (dfa);
|
|
|
|
|
}
|
2004-01-06 21:59:24 +00:00
|
|
|
|
preg->buffer = NULL;
|
|
|
|
|
preg->allocated = 0;
|
2002-11-06 08:34:35 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_free (preg->fastmap);
|
2004-01-06 21:59:24 +00:00
|
|
|
|
preg->fastmap = NULL;
|
|
|
|
|
|
|
|
|
|
re_free (preg->translate);
|
|
|
|
|
preg->translate = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2017-10-01 22:52:56 +00:00
|
|
|
|
libc_hidden_def (__regfree)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
weak_alias (__regfree, regfree)
|
|
|
|
|
|
|
|
|
|
/* Entry points compatible with 4.2 BSD regex library. We don't define
|
|
|
|
|
them unless specifically requested. */
|
|
|
|
|
|
|
|
|
|
#if defined _REGEX_RE_COMP || defined _LIBC
|
|
|
|
|
|
|
|
|
|
/* BSD has one and only one pattern buffer. */
|
|
|
|
|
static struct re_pattern_buffer re_comp_buf;
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
# ifdef _LIBC
|
|
|
|
|
/* Make these definitions weak in libc, so POSIX programs can redefine
|
|
|
|
|
these names if they don't use our functions, and still use
|
|
|
|
|
regcomp/regexec above without link errors. */
|
|
|
|
|
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_comp (const char *s)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t ret;
|
2002-10-24 00:22:27 +00:00
|
|
|
|
char *fastmap;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
|
{
|
|
|
|
|
if (!re_comp_buf.buffer)
|
|
|
|
|
return gettext ("No previous regular expression");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-24 00:22:27 +00:00
|
|
|
|
if (re_comp_buf.buffer)
|
|
|
|
|
{
|
|
|
|
|
fastmap = re_comp_buf.fastmap;
|
|
|
|
|
re_comp_buf.fastmap = NULL;
|
|
|
|
|
__regfree (&re_comp_buf);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
|
2002-10-24 00:22:27 +00:00
|
|
|
|
re_comp_buf.fastmap = fastmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (re_comp_buf.fastmap == NULL)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_comp_buf.fastmap = re_malloc (char, SBC_MAX);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (re_comp_buf.fastmap == NULL)
|
2002-03-13 08:59:47 +00:00
|
|
|
|
return (char *) gettext (__re_error_msgid
|
|
|
|
|
+ __re_error_msgid_idx[(int) REG_ESPACE]);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* Since 're_exec' always passes NULL for the 'regs' argument, we
|
2002-02-26 19:06:03 +00:00
|
|
|
|
don't need to initialize the pattern buffer fields which affect it. */
|
|
|
|
|
|
|
|
|
|
/* Match anchors at newlines. */
|
|
|
|
|
re_comp_buf.newline_anchor = 1;
|
|
|
|
|
|
|
|
|
|
ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
|
|
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Yes, we're discarding 'const' here if !HAVE_LIBINTL. */
|
2002-03-13 08:59:47 +00:00
|
|
|
|
return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-10-24 00:22:27 +00:00
|
|
|
|
|
|
|
|
|
#ifdef _LIBC
|
2022-12-27 21:11:42 +00:00
|
|
|
|
void
|
|
|
|
|
__libc_regcomp_freemem (void)
|
2002-10-24 00:22:27 +00:00
|
|
|
|
{
|
|
|
|
|
__regfree (&re_comp_buf);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif /* _REGEX_RE_COMP */
|
|
|
|
|
|
|
|
|
|
/* Internal entry point.
|
|
|
|
|
Compile the regular expression PATTERN, whose length is LENGTH.
|
|
|
|
|
SYNTAX indicate regular expression's syntax. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
re_compile_internal (regex_t *preg, const char * pattern, size_t length,
|
|
|
|
|
reg_syntax_t syntax)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
|
|
|
|
re_dfa_t *dfa;
|
|
|
|
|
re_string_t regexp;
|
|
|
|
|
|
|
|
|
|
/* Initialize the pattern buffer. */
|
|
|
|
|
preg->fastmap_accurate = 0;
|
|
|
|
|
preg->syntax = syntax;
|
|
|
|
|
preg->not_bol = preg->not_eol = 0;
|
|
|
|
|
preg->used = 0;
|
|
|
|
|
preg->re_nsub = 0;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
preg->can_be_null = 0;
|
|
|
|
|
preg->regs_allocated = REGS_UNALLOCATED;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Initialize the dfa. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa = preg->buffer;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t)))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
/* If zero allocated, but buffer is non-null, try to realloc
|
|
|
|
|
enough space. This loses if buffer's address is bogus, but
|
|
|
|
|
that is the user's responsibility. If ->buffer is NULL this
|
|
|
|
|
is a simple allocation. */
|
|
|
|
|
dfa = re_realloc (preg->buffer, re_dfa_t, 1);
|
|
|
|
|
if (dfa == NULL)
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
preg->allocated = sizeof (re_dfa_t);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
preg->buffer = dfa;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
preg->used = sizeof (re_dfa_t);
|
|
|
|
|
|
|
|
|
|
err = init_dfa (dfa, length);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
err = REG_ESPACE;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
free_dfa_content (dfa);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
preg->buffer = NULL;
|
2003-01-16 17:27:50 +00:00
|
|
|
|
preg->allocated = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
#ifdef DEBUG
|
* 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
|
|
|
|
/* Note: length+1 will not overflow since it is checked in init_dfa. */
|
2002-09-28 05:28:44 +00:00
|
|
|
|
dfa->re_str = re_malloc (char, length + 1);
|
|
|
|
|
strncpy (dfa->re_str, pattern, length + 1);
|
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
err = re_string_construct (®exp, pattern, length, preg->translate,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
(syntax & RE_ICASE) != 0, dfa);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
re_compile_internal_free_return:
|
|
|
|
|
free_workarea_compile (preg);
|
|
|
|
|
re_string_destruct (®exp);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_fini (dfa->lock);
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
free_dfa_content (dfa);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
preg->buffer = NULL;
|
2003-01-16 17:27:50 +00:00
|
|
|
|
preg->allocated = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Parse the regular expression, and build a structure tree. */
|
|
|
|
|
preg->re_nsub = 0;
|
|
|
|
|
dfa->str_tree = parse (®exp, preg, syntax, &err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->str_tree == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
goto re_compile_internal_free_return;
|
|
|
|
|
|
[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
|
|
|
|
/* Analyze the tree and create the nfa. */
|
|
|
|
|
err = analyze (preg);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
[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
|
|
|
|
goto re_compile_internal_free_return;
|
|
|
|
|
|
2003-11-12 19:09:20 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* If possible, do searching in single byte encoding to speed things up. */
|
2003-11-18 23:40:59 +00:00
|
|
|
|
if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
|
2003-11-12 19:09:20 +00:00
|
|
|
|
optimize_utf8 (dfa);
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Then create the initial state of the dfa. */
|
|
|
|
|
err = create_initial_state (dfa);
|
|
|
|
|
|
|
|
|
|
/* Release work areas. */
|
|
|
|
|
free_workarea_compile (preg);
|
|
|
|
|
re_string_destruct (®exp);
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 08:34:35 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_fini (dfa->lock);
|
2002-11-06 08:34:35 +00:00
|
|
|
|
free_dfa_content (dfa);
|
|
|
|
|
preg->buffer = NULL;
|
2003-01-16 17:27:50 +00:00
|
|
|
|
preg->allocated = 0;
|
2002-11-06 08:34:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize DFA. We use the length of the regular expression PAT_LEN
|
|
|
|
|
as the initial length of some arrays. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
init_dfa (re_dfa_t *dfa, size_t pat_len)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
__re_size_t table_size;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
#ifndef _LIBC
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *codeset_name;
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
|
|
|
|
|
#else
|
|
|
|
|
size_t max_i18n_object_size = 0;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
#endif
|
2017-12-20 11:47:44 +00:00
|
|
|
|
size_t max_object_size =
|
|
|
|
|
MAX (sizeof (struct re_state_table_entry),
|
|
|
|
|
MAX (sizeof (re_token_t),
|
|
|
|
|
MAX (sizeof (re_node_set),
|
|
|
|
|
MAX (sizeof (regmatch_t),
|
|
|
|
|
max_i18n_object_size))));
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
|
|
|
|
memset (dfa, '\0', sizeof (re_dfa_t));
|
|
|
|
|
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
/* Force allocation of str_tree_storage the first time. */
|
|
|
|
|
dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Avoid overflows. The extra "/ 2" is for the table_size doubling
|
|
|
|
|
calculation below, and for similar doubling calculations
|
|
|
|
|
elsewhere. And it's <= rather than <, because some of the
|
|
|
|
|
doubling calculations add 1 afterwards. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2
|
|
|
|
|
<= pat_len))
|
* 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
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dfa->nodes_alloc = pat_len + 1;
|
|
|
|
|
dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc);
|
|
|
|
|
|
|
|
|
|
/* table_size = 2 ^ ceil(log pat_len) */
|
* 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
|
|
|
|
for (table_size = 1; ; table_size <<= 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (table_size > pat_len)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
|
|
|
|
|
dfa->state_hash_mask = table_size - 1;
|
|
|
|
|
|
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
|
|
|
|
dfa->mb_cur_max = MB_CUR_MAX;
|
|
|
|
|
#ifdef _LIBC
|
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 (dfa->mb_cur_max == 6
|
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
|
|
|
|
&& strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
|
|
|
|
|
dfa->is_utf8 = 1;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
|
|
|
|
|
!= 0);
|
2004-11-08 22:49:44 +00:00
|
|
|
|
#else
|
|
|
|
|
codeset_name = nl_langinfo (CODESET);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if ((codeset_name[0] == 'U' || codeset_name[0] == 'u')
|
|
|
|
|
&& (codeset_name[1] == 'T' || codeset_name[1] == 't')
|
|
|
|
|
&& (codeset_name[2] == 'F' || codeset_name[2] == 'f')
|
|
|
|
|
&& strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
dfa->is_utf8 = 1;
|
|
|
|
|
|
|
|
|
|
/* We check exhaustively in the loop below if this charset is a
|
|
|
|
|
superset of ASCII. */
|
|
|
|
|
dfa->map_notascii = 0;
|
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
|
|
|
|
#endif
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (dfa->mb_cur_max > 1)
|
|
|
|
|
{
|
|
|
|
|
if (dfa->is_utf8)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
else
|
2004-11-08 22:49:44 +00:00
|
|
|
|
{
|
|
|
|
|
int i, j, 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
|
|
|
|
dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->sb_char == NULL))
|
2004-11-08 22:49:44 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
[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
|
|
|
|
/* Set the bits corresponding to single byte chars. */
|
|
|
|
|
for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
|
|
|
|
|
for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
|
2004-11-08 22:49:44 +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
|
|
|
|
wint_t wch = __btowc (ch);
|
2004-11-08 22:49:44 +00:00
|
|
|
|
if (wch != WEOF)
|
[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->sb_char[i] |= (bitset_word_t) 1 << j;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
# ifndef _LIBC
|
* 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 (isascii (ch) && wch != ch)
|
2004-11-08 22:49:44 +00:00
|
|
|
|
dfa->map_notascii = 1;
|
|
|
|
|
# endif
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-24 19:30:51 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
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
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
return REG_ESPACE;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize WORD_CHAR table, which indicate which character is
|
|
|
|
|
"word". In this case "word" means that it is the word construction
|
|
|
|
|
character used by some operators like "\<", "\>", etc. */
|
|
|
|
|
|
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
|
|
|
|
static void
|
2005-10-13 20:40:05 +00:00
|
|
|
|
init_word_char (re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2012-01-03 12:54:15 +00:00
|
|
|
|
int i = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
int j;
|
2012-01-03 12:54:15 +00:00
|
|
|
|
int ch = 0;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa->word_ops_used = 1;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (dfa->map_notascii == 0))
|
2012-01-03 12:54:15 +00:00
|
|
|
|
{
|
2017-11-22 19:21:44 +00:00
|
|
|
|
/* Avoid uint32_t and uint64_t as some non-GCC platforms lack
|
|
|
|
|
them, an issue when this code is used in Gnulib. */
|
2017-11-21 00:25:49 +00:00
|
|
|
|
bitset_word_t bits0 = 0x00000000;
|
|
|
|
|
bitset_word_t bits1 = 0x03ff0000;
|
|
|
|
|
bitset_word_t bits2 = 0x87fffffe;
|
|
|
|
|
bitset_word_t bits3 = 0x07fffffe;
|
|
|
|
|
if (BITSET_WORD_BITS == 64)
|
2012-01-03 12:54:15 +00:00
|
|
|
|
{
|
2017-11-22 19:21:44 +00:00
|
|
|
|
/* Pacify gcc -Woverflow on 32-bit platformns. */
|
2017-11-21 00:25:49 +00:00
|
|
|
|
dfa->word_char[0] = bits1 << 31 << 1 | bits0;
|
|
|
|
|
dfa->word_char[1] = bits3 << 31 << 1 | bits2;
|
2012-01-03 12:54:15 +00:00
|
|
|
|
i = 2;
|
|
|
|
|
}
|
2017-11-21 00:25:49 +00:00
|
|
|
|
else if (BITSET_WORD_BITS == 32)
|
2012-01-03 12:54:15 +00:00
|
|
|
|
{
|
2017-11-21 00:25:49 +00:00
|
|
|
|
dfa->word_char[0] = bits0;
|
|
|
|
|
dfa->word_char[1] = bits1;
|
|
|
|
|
dfa->word_char[2] = bits2;
|
|
|
|
|
dfa->word_char[3] = bits3;
|
2012-01-03 12:54:15 +00:00
|
|
|
|
i = 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-11-21 00:25:49 +00:00
|
|
|
|
goto general_case;
|
2012-01-03 12:54:15 +00:00
|
|
|
|
ch = 128;
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (dfa->is_utf8))
|
2012-01-03 12:54:15 +00:00
|
|
|
|
{
|
|
|
|
|
memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 00:25:49 +00:00
|
|
|
|
general_case:
|
2012-01-03 12:54:15 +00:00
|
|
|
|
for (; i < BITSET_WORDS; ++i)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (isalnum (ch) || 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
|
|
|
|
dfa->word_char[i] |= (bitset_word_t) 1 << j;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free the work area which are only used while compiling. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-13 20:40:05 +00:00
|
|
|
|
free_workarea_compile (regex_t *preg)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
bin_tree_storage_t *storage, *next;
|
|
|
|
|
for (storage = dfa->str_tree_storage; storage; storage = next)
|
|
|
|
|
{
|
|
|
|
|
next = storage->next;
|
|
|
|
|
re_free (storage);
|
|
|
|
|
}
|
|
|
|
|
dfa->str_tree_storage = NULL;
|
|
|
|
|
dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dfa->str_tree = NULL;
|
2002-12-17 10:58:04 +00:00
|
|
|
|
re_free (dfa->org_indices);
|
|
|
|
|
dfa->org_indices = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create initial states for all contexts. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
create_initial_state (re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx first, i;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
reg_errcode_t err;
|
|
|
|
|
re_node_set init_nodes;
|
|
|
|
|
|
|
|
|
|
/* Initial states have the epsilon closure of the node which is
|
|
|
|
|
the first node of the regular expression. */
|
[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
|
|
|
|
first = dfa->str_tree->first->node_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dfa->init_node = first;
|
|
|
|
|
err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
/* The back-references which are in initial states can epsilon transit,
|
|
|
|
|
since in this case all of the subexpressions can be null.
|
|
|
|
|
Then we add epsilon closures of the nodes which are the next nodes of
|
|
|
|
|
the back-references. */
|
|
|
|
|
if (dfa->nbackref > 0)
|
|
|
|
|
for (i = 0; i < init_nodes.nelem; ++i)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx = init_nodes.elems[i];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_token_type_t type = dfa->nodes[node_idx].type;
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx clexp_idx;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (type != OP_BACK_REF)
|
|
|
|
|
continue;
|
|
|
|
|
for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx)
|
|
|
|
|
{
|
|
|
|
|
re_token_t *clexp_node;
|
|
|
|
|
clexp_node = dfa->nodes + init_nodes.elems[clexp_idx];
|
|
|
|
|
if (clexp_node->type == OP_CLOSE_SUBEXP
|
2004-12-06 02:56:42 +00:00
|
|
|
|
&& clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (clexp_idx == init_nodes.nelem)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (type == OP_BACK_REF)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dest_idx = dfa->edests[node_idx].elems[0];
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (!re_node_set_contains (&init_nodes, dest_idx))
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_errcode_t merge_err
|
|
|
|
|
= re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
|
|
|
|
|
if (merge_err != REG_NOERROR)
|
|
|
|
|
return merge_err;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* It must be the first time to invoke acquire_state. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
|
|
|
|
|
/* We don't check ERR here, since the initial state must not be NULL. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->init_state == NULL))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (dfa->init_state->has_constraint)
|
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
CONTEXT_WORD);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
CONTEXT_NEWLINE);
|
2002-02-28 07:43:13 +00:00
|
|
|
|
dfa->init_state_begbuf = re_acquire_state_context (&err, dfa,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
&init_nodes,
|
|
|
|
|
CONTEXT_NEWLINE
|
|
|
|
|
| CONTEXT_BEGBUF);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->init_state_word == NULL
|
|
|
|
|
|| dfa->init_state_nl == NULL
|
|
|
|
|
|| dfa->init_state_begbuf == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
dfa->init_state_word = dfa->init_state_nl
|
|
|
|
|
= dfa->init_state_begbuf = dfa->init_state;
|
|
|
|
|
|
|
|
|
|
re_node_set_free (&init_nodes);
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-12 19:09:20 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* If it is possible to do searching in single byte encoding instead of UTF-8
|
|
|
|
|
to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
|
|
|
|
|
DFA nodes where needed. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-13 20:40:05 +00:00
|
|
|
|
optimize_utf8 (re_dfa_t *dfa)
|
2003-11-12 19:09:20 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node;
|
|
|
|
|
int i;
|
|
|
|
|
bool mb_chars = false;
|
|
|
|
|
bool has_period = false;
|
2003-11-12 19:09:20 +00:00
|
|
|
|
|
|
|
|
|
for (node = 0; node < dfa->nodes_len; ++node)
|
|
|
|
|
switch (dfa->nodes[node].type)
|
|
|
|
|
{
|
|
|
|
|
case CHARACTER:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (dfa->nodes[node].opr.c >= ASCII_CHARS)
|
|
|
|
|
mb_chars = true;
|
2003-11-12 19:09:20 +00:00
|
|
|
|
break;
|
|
|
|
|
case ANCHOR:
|
2007-12-14 03:54:07 +00:00
|
|
|
|
switch (dfa->nodes[node].opr.ctx_type)
|
2003-11-12 19:09:20 +00:00
|
|
|
|
{
|
|
|
|
|
case LINE_FIRST:
|
|
|
|
|
case LINE_LAST:
|
|
|
|
|
case BUF_FIRST:
|
|
|
|
|
case BUF_LAST:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2008-05-15 04:42:20 +00:00
|
|
|
|
/* Word anchors etc. cannot be handled. It's okay to test
|
|
|
|
|
opr.ctx_type since constraints (for all DFA nodes) are
|
|
|
|
|
created by ORing one or more opr.ctx_type values. */
|
2003-11-12 19:09:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
case OP_PERIOD:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
has_period = true;
|
2010-01-15 05:35:15 +00:00
|
|
|
|
break;
|
2003-11-12 19:09:20 +00:00
|
|
|
|
case OP_BACK_REF:
|
|
|
|
|
case OP_ALT:
|
|
|
|
|
case END_OF_RE:
|
|
|
|
|
case OP_DUP_ASTERISK:
|
|
|
|
|
case OP_OPEN_SUBEXP:
|
|
|
|
|
case OP_CLOSE_SUBEXP:
|
|
|
|
|
break;
|
[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
|
|
|
|
case COMPLEX_BRACKET:
|
|
|
|
|
return;
|
2003-11-13 21:23:11 +00:00
|
|
|
|
case SIMPLE_BRACKET:
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Just double check. */
|
|
|
|
|
{
|
|
|
|
|
int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0
|
|
|
|
|
? 0
|
|
|
|
|
: BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS);
|
|
|
|
|
for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0)
|
|
|
|
|
return;
|
|
|
|
|
rshift = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-13 21:23:11 +00:00
|
|
|
|
break;
|
2003-11-12 19:09:20 +00:00
|
|
|
|
default:
|
[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
|
|
|
|
abort ();
|
2003-11-12 19:09:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-18 23:40:59 +00:00
|
|
|
|
if (mb_chars || has_period)
|
2003-11-18 07:25:02 +00:00
|
|
|
|
for (node = 0; node < dfa->nodes_len; ++node)
|
2003-11-18 23:40:59 +00:00
|
|
|
|
{
|
|
|
|
|
if (dfa->nodes[node].type == CHARACTER
|
2017-12-20 11:47:44 +00:00
|
|
|
|
&& dfa->nodes[node].opr.c >= ASCII_CHARS)
|
2003-11-18 23:40:59 +00:00
|
|
|
|
dfa->nodes[node].mb_partial = 0;
|
|
|
|
|
else if (dfa->nodes[node].type == OP_PERIOD)
|
|
|
|
|
dfa->nodes[node].type = OP_UTF8_PERIOD;
|
|
|
|
|
}
|
2003-11-18 07:25:02 +00:00
|
|
|
|
|
2003-11-12 19:09:20 +00:00
|
|
|
|
/* The search can be in single byte locale. */
|
|
|
|
|
dfa->mb_cur_max = 1;
|
|
|
|
|
dfa->is_utf8 = 0;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
dfa->has_mb_node = dfa->nbackref > 0 || has_period;
|
2003-11-12 19:09:20 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Analyze the structure tree, and calculate "first", "next", "edest",
|
|
|
|
|
"eclosure", and "inveclosure". */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
analyze (regex_t *preg)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
reg_errcode_t ret;
|
|
|
|
|
|
|
|
|
|
/* Allocate arrays. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa->nexts = re_malloc (Idx, dfa->nodes_alloc);
|
|
|
|
|
dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
|
|
|
|
|
dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL
|
|
|
|
|
|| dfa->edests == NULL || dfa->eclosures == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_ESPACE;
|
[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
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
|
[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->subexp_map != NULL)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i;
|
[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
|
|
|
|
for (i = 0; i < preg->re_nsub; i++)
|
|
|
|
|
dfa->subexp_map[i] = i;
|
|
|
|
|
preorder (dfa->str_tree, optimize_subexps, dfa);
|
|
|
|
|
for (i = 0; i < preg->re_nsub; i++)
|
|
|
|
|
if (dfa->subexp_map[i] != i)
|
|
|
|
|
break;
|
|
|
|
|
if (i == preg->re_nsub)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_free (dfa->subexp_map);
|
[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
|
|
|
|
dfa->subexp_map = NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
ret = postorder (dfa->str_tree, lower_subexps, preg);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
[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
|
|
|
|
return ret;
|
|
|
|
|
ret = postorder (dfa->str_tree, calc_first, dfa);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
[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
|
|
|
|
return ret;
|
|
|
|
|
preorder (dfa->str_tree, calc_next, dfa);
|
|
|
|
|
ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
[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
|
|
|
|
return ret;
|
|
|
|
|
ret = calc_eclosure (dfa);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
[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
|
|
|
|
return ret;
|
2005-01-27 19:08:10 +00:00
|
|
|
|
|
|
|
|
|
/* We only need this during the prune_impossible_nodes pass in regexec.c;
|
|
|
|
|
skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */
|
|
|
|
|
if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
|
|
|
|
|
|| dfa->nbackref)
|
|
|
|
|
{
|
|
|
|
|
dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->inveclosures == NULL))
|
2010-01-15 05:35:15 +00:00
|
|
|
|
return REG_ESPACE;
|
2005-01-27 19:08:10 +00:00
|
|
|
|
ret = calc_inveclosure (dfa);
|
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Our parse trees are very unbalanced, so we cannot use a stack to
|
|
|
|
|
implement parse tree visits. Instead, we use parent pointers and
|
|
|
|
|
some hairy code in these two functions. */
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
|
|
|
|
|
void *extra)
|
[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
|
|
|
|
{
|
|
|
|
|
bin_tree_t *node, *prev;
|
|
|
|
|
|
|
|
|
|
for (node = root; ; )
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
[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
|
|
|
|
/* Descend down the tree, preferably to the left (or to the right
|
|
|
|
|
if that's the only child). */
|
|
|
|
|
while (node->left || node->right)
|
|
|
|
|
if (node->left)
|
2010-01-15 05:35:15 +00:00
|
|
|
|
node = node->left;
|
|
|
|
|
else
|
|
|
|
|
node = node->right;
|
[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
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err = fn (extra, node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
[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
|
|
|
|
return err;
|
2010-01-15 05:35:15 +00:00
|
|
|
|
if (node->parent == NULL)
|
[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
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
prev = node;
|
|
|
|
|
node = node->parent;
|
|
|
|
|
}
|
|
|
|
|
/* Go up while we have a node that is reached from the right. */
|
|
|
|
|
while (node->right == prev || node->right == NULL);
|
|
|
|
|
node = node->right;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
|
|
|
|
|
void *extra)
|
[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
|
|
|
|
{
|
|
|
|
|
bin_tree_t *node;
|
|
|
|
|
|
|
|
|
|
for (node = root; ; )
|
|
|
|
|
{
|
|
|
|
|
reg_errcode_t err = fn (extra, node);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
[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
|
|
|
|
return err;
|
2007-07-12 18:26:36 +00:00
|
|
|
|
|
[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
|
|
|
|
/* Go to the left node, or up and to the right. */
|
|
|
|
|
if (node->left)
|
|
|
|
|
node = node->left;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bin_tree_t *prev = NULL;
|
|
|
|
|
while (node->right == prev || node->right == NULL)
|
|
|
|
|
{
|
|
|
|
|
prev = node;
|
|
|
|
|
node = node->parent;
|
|
|
|
|
if (!node)
|
2010-01-15 05:35:15 +00:00
|
|
|
|
return REG_NOERROR;
|
[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
|
|
|
|
}
|
|
|
|
|
node = node->right;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell
|
|
|
|
|
re_search_internal to map the inner one's opr.idx to this one's. Adjust
|
|
|
|
|
backreferences as well. Requires a preorder visit. */
|
2007-07-12 18:26:36 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
optimize_subexps (void *extra, bin_tree_t *node)
|
2007-07-12 18:26:36 +00:00
|
|
|
|
{
|
[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_dfa_t *dfa = (re_dfa_t *) extra;
|
2007-07-12 18:26:36 +00:00
|
|
|
|
|
[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 (node->token.type == OP_BACK_REF && dfa->subexp_map)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
[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
|
|
|
|
int idx = node->token.opr.idx;
|
|
|
|
|
node->token.opr.idx = dfa->subexp_map[idx];
|
|
|
|
|
dfa->used_bkref_map |= 1 << node->token.opr.idx;
|
2007-07-12 18:26:36 +00:00
|
|
|
|
}
|
[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
|
|
|
|
|
|
|
|
|
else if (node->token.type == SUBEXP
|
2010-01-15 05:35:15 +00:00
|
|
|
|
&& node->left && node->left->token.type == SUBEXP)
|
2007-07-12 18:26:36 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx other_idx = node->left->token.opr.idx;
|
[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
|
|
|
|
|
|
|
|
|
node->left = node->left->left;
|
|
|
|
|
if (node->left)
|
2010-01-15 05:35:15 +00:00
|
|
|
|
node->left->parent = node;
|
[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
|
|
|
|
|
|
|
|
|
dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx];
|
[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 (other_idx < BITSET_WORD_BITS)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
[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
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation
|
|
|
|
|
of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
lower_subexps (void *extra, bin_tree_t *node)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
[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
|
|
|
|
regex_t *preg = (regex_t *) extra;
|
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[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 (node->left && node->left->token.type == SUBEXP)
|
2007-07-12 18:26:36 +00:00
|
|
|
|
{
|
[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
|
|
|
|
node->left = lower_subexp (&err, preg, node->left);
|
|
|
|
|
if (node->left)
|
|
|
|
|
node->left->parent = node;
|
|
|
|
|
}
|
|
|
|
|
if (node->right && node->right->token.type == SUBEXP)
|
|
|
|
|
{
|
|
|
|
|
node->right = lower_subexp (&err, preg, node->right);
|
|
|
|
|
if (node->right)
|
|
|
|
|
node->right->parent = node;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
return err;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[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
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
|
2007-07-12 18:26:36 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
[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
|
|
|
|
bin_tree_t *body = node->left;
|
|
|
|
|
bin_tree_t *op, *cls, *tree1, *tree;
|
|
|
|
|
|
|
|
|
|
if (preg->no_sub
|
2005-02-22 05:07:20 +00:00
|
|
|
|
/* We do not optimize empty subexpressions, because otherwise we may
|
|
|
|
|
have bad CONCAT nodes with NULL children. This is obviously not
|
|
|
|
|
very common, so we do not lose much. An example that triggers
|
|
|
|
|
this case is the sed "script" /\(\)/x. */
|
|
|
|
|
&& node->left != NULL
|
[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
|
|
|
|
&& (node->token.opr.idx >= BITSET_WORD_BITS
|
|
|
|
|
|| !(dfa->used_bkref_map
|
|
|
|
|
& ((bitset_word_t) 1 << node->token.opr.idx))))
|
[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
|
|
|
|
return node->left;
|
|
|
|
|
|
|
|
|
|
/* Convert the SUBEXP node to the concatenation of an
|
|
|
|
|
OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */
|
|
|
|
|
op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP);
|
|
|
|
|
cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
|
|
|
|
|
tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
|
|
|
|
|
tree = create_tree (dfa, op, tree1, CONCAT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL || tree1 == NULL
|
|
|
|
|
|| op == NULL || cls == NULL))
|
2007-07-12 18:26:36 +00:00
|
|
|
|
{
|
[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
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
2007-07-12 18:26:36 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[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
|
|
|
|
op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx;
|
|
|
|
|
op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp;
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
2004-12-22 20:10:10 +00:00
|
|
|
|
|
[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
|
|
|
|
/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton
|
|
|
|
|
nodes. Requires a postorder visit. */
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
calc_first (void *extra, bin_tree_t *node)
|
[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_dfa_t *dfa = (re_dfa_t *) extra;
|
|
|
|
|
if (node->token.type == CONCAT)
|
|
|
|
|
{
|
|
|
|
|
node->first = node->left->first;
|
|
|
|
|
node->node_idx = node->left->node_idx;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
node->first = node;
|
|
|
|
|
node->node_idx = re_dfa_add_node (dfa, node->token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (node->node_idx == -1))
|
2010-01-15 05:35:15 +00:00
|
|
|
|
return REG_ESPACE;
|
2008-05-15 04:42:20 +00:00
|
|
|
|
if (node->token.type == ANCHOR)
|
2010-01-15 05:35:15 +00:00
|
|
|
|
dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
|
[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
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pass 2: compute NEXT on the tree. Preorder visit. */
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
calc_next (void *extra, bin_tree_t *node)
|
[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
|
|
|
|
{
|
|
|
|
|
switch (node->token.type)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
case OP_DUP_ASTERISK:
|
[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
|
|
|
|
node->left->next = node;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case CONCAT:
|
[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
|
|
|
|
node->left->next = node->right->first;
|
|
|
|
|
node->right->next = node->next;
|
|
|
|
|
break;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
default:
|
[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 (node->left)
|
|
|
|
|
node->left->next = node->next;
|
|
|
|
|
if (node->right)
|
2010-01-15 05:35:15 +00:00
|
|
|
|
node->right->next = node->next;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
[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
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
link_nfa_nodes (void *extra, bin_tree_t *node)
|
2004-12-22 20:10:10 +00:00
|
|
|
|
{
|
[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_dfa_t *dfa = (re_dfa_t *) extra;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx = node->node_idx;
|
[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
|
|
|
|
reg_errcode_t err = REG_NOERROR;
|
|
|
|
|
|
|
|
|
|
switch (node->token.type)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
[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
|
|
|
|
case CONCAT:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case END_OF_RE:
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (node->next == NULL);
|
[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
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_DUP_ASTERISK:
|
|
|
|
|
case OP_ALT:
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx left, right;
|
[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
|
|
|
|
dfa->has_plural_match = 1;
|
|
|
|
|
if (node->left != NULL)
|
|
|
|
|
left = node->left->first->node_idx;
|
|
|
|
|
else
|
|
|
|
|
left = node->next->node_idx;
|
|
|
|
|
if (node->right != NULL)
|
|
|
|
|
right = node->right->first->node_idx;
|
|
|
|
|
else
|
|
|
|
|
right = node->next->node_idx;
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (left > -1);
|
|
|
|
|
DEBUG_ASSERT (right > -1);
|
[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
|
|
|
|
err = re_node_set_init_2 (dfa->edests + idx, left, right);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ANCHOR:
|
|
|
|
|
case OP_OPEN_SUBEXP:
|
|
|
|
|
case OP_CLOSE_SUBEXP:
|
|
|
|
|
err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_BACK_REF:
|
|
|
|
|
dfa->nexts[idx] = node->next->node_idx;
|
|
|
|
|
if (node->token.type == OP_BACK_REF)
|
2010-01-15 20:03:16 +00:00
|
|
|
|
err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
|
[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
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type));
|
[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
|
|
|
|
dfa->nexts[idx] = node->next->node_idx;
|
|
|
|
|
break;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
[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
|
|
|
|
|
|
|
|
|
return err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 08:34:26 +00:00
|
|
|
|
/* Duplicate the epsilon closure of the node ROOT_NODE.
|
|
|
|
|
Note that duplicated nodes have constraint INIT_CONSTRAINT in addition
|
|
|
|
|
to their own constraint. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2017-12-20 11:47:44 +00:00
|
|
|
|
duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
|
|
|
|
|
Idx root_node, unsigned int init_constraint)
|
2002-10-12 08:34:26 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx org_node, clone_node;
|
|
|
|
|
bool ok;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
unsigned int constraint = init_constraint;
|
|
|
|
|
for (org_node = top_org_node, clone_node = top_clone_node;;)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx org_dest, clone_dest;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (dfa->nodes[org_node].type == OP_BACK_REF)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2002-10-12 08:34:26 +00:00
|
|
|
|
/* If the back reference epsilon-transit, its destination must
|
|
|
|
|
also have the constraint. Then duplicate the epsilon closure
|
|
|
|
|
of the destination of the back reference, and store it in
|
|
|
|
|
edests of the back reference. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
org_dest = dfa->nexts[org_node];
|
|
|
|
|
re_node_set_empty (dfa->edests + clone_node);
|
* 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
|
|
|
|
clone_dest = duplicate_node (dfa, org_dest, constraint);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (clone_dest == -1))
|
* 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
|
|
|
|
return REG_ESPACE;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dfa->nexts[clone_node] = dfa->nexts[org_node];
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-10-12 08:34:26 +00:00
|
|
|
|
else if (dfa->edests[org_node].nelem == 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2002-10-12 08:34:26 +00:00
|
|
|
|
/* In case of the node can't epsilon-transit, don't duplicate the
|
|
|
|
|
destination and store the original destination as the
|
|
|
|
|
destination of the node. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dfa->nexts[clone_node] = dfa->nexts[org_node];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-10-12 08:34:26 +00:00
|
|
|
|
else if (dfa->edests[org_node].nelem == 1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2002-10-12 08:34:26 +00:00
|
|
|
|
/* In case of the node can epsilon-transit, and it has only one
|
|
|
|
|
destination. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
org_dest = dfa->edests[org_node].elems[0];
|
|
|
|
|
re_node_set_empty (dfa->edests + clone_node);
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* If the node is root_node itself, it means the epsilon closure
|
2017-12-20 11:47:44 +00:00
|
|
|
|
has a loop. Then tie it to the destination of the root_node. */
|
2008-05-15 04:42:20 +00:00
|
|
|
|
if (org_node == root_node && clone_node != org_node)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
return REG_ESPACE;
|
2008-05-15 04:42:20 +00:00
|
|
|
|
break;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* In case the node has another constraint, append it. */
|
2008-05-15 04:42:20 +00:00
|
|
|
|
constraint |= dfa->nodes[org_node].constraint;
|
* 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
|
|
|
|
clone_dest = duplicate_node (dfa, org_dest, constraint);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (clone_dest == -1))
|
* 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
|
|
|
|
return REG_ESPACE;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-10-12 08:34:26 +00:00
|
|
|
|
else /* dfa->edests[org_node].nelem == 2 */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2002-10-12 08:34:26 +00:00
|
|
|
|
/* In case of the node can epsilon-transit, and it has two
|
[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
|
|
|
|
destinations. In the bin_tree_t and DFA, that's '|' and '*'. */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
org_dest = dfa->edests[org_node].elems[0];
|
|
|
|
|
re_node_set_empty (dfa->edests + clone_node);
|
2002-12-17 10:58:04 +00:00
|
|
|
|
/* Search for a duplicated node which satisfies the constraint. */
|
|
|
|
|
clone_dest = search_duplicated_node (dfa, org_dest, constraint);
|
|
|
|
|
if (clone_dest == -1)
|
|
|
|
|
{
|
2008-05-15 04:42:20 +00:00
|
|
|
|
/* There is no such duplicated node, create a new one. */
|
* 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
|
|
|
|
reg_errcode_t err;
|
|
|
|
|
clone_dest = duplicate_node (dfa, org_dest, constraint);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (clone_dest == -1))
|
* 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
|
|
|
|
return REG_ESPACE;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2003-12-22 06:45:04 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
err = duplicate_node_closure (dfa, org_dest, clone_dest,
|
|
|
|
|
root_node, constraint);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2003-12-22 06:45:04 +00:00
|
|
|
|
return err;
|
2002-12-17 10:58:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-05-15 04:42:20 +00:00
|
|
|
|
/* There is a duplicated node which satisfies the constraint,
|
2002-12-17 10:58:04 +00:00
|
|
|
|
use it to avoid infinite loop. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-12-17 10:58:04 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
|
|
|
|
|
org_dest = dfa->edests[org_node].elems[1];
|
* 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
|
|
|
|
clone_dest = duplicate_node (dfa, org_dest, constraint);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (clone_dest == -1))
|
* 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
|
|
|
|
return REG_ESPACE;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-10-12 08:34:26 +00:00
|
|
|
|
org_node = org_dest;
|
|
|
|
|
clone_node = clone_dest;
|
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-17 10:58:04 +00:00
|
|
|
|
/* Search for a node which is duplicated from the node ORG_NODE, and
|
|
|
|
|
satisfies the constraint CONSTRAINT. */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
|
|
|
|
search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
|
2005-10-13 20:40:05 +00:00
|
|
|
|
unsigned int constraint)
|
2002-12-17 10:58:04 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx;
|
2002-12-17 10:58:04 +00:00
|
|
|
|
for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx)
|
|
|
|
|
{
|
|
|
|
|
if (org_node == dfa->org_indices[idx]
|
|
|
|
|
&& constraint == dfa->nodes[idx].constraint)
|
|
|
|
|
return idx; /* Found. */
|
|
|
|
|
}
|
|
|
|
|
return -1; /* Not found. */
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
|
* 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
|
|
|
|
Return the index of the new node, or -1 if insufficient storage is
|
|
|
|
|
available. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
|
|
|
|
duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (dup_idx != -1))
|
* 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
|
|
|
|
{
|
|
|
|
|
dfa->nodes[dup_idx].constraint = constraint;
|
2008-05-15 04:42:20 +00:00
|
|
|
|
dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
|
* 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
|
|
|
|
dfa->nodes[dup_idx].duplicated = 1;
|
|
|
|
|
|
|
|
|
|
/* Store the index of the original node. */
|
|
|
|
|
dfa->org_indices[dup_idx] = org_idx;
|
|
|
|
|
}
|
|
|
|
|
return dup_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-01-27 19:08:10 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
calc_inveclosure (re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx src, idx;
|
|
|
|
|
bool ok;
|
2005-01-27 19:08:10 +00:00
|
|
|
|
for (idx = 0; idx < dfa->nodes_len; ++idx)
|
|
|
|
|
re_node_set_init_empty (dfa->inveclosures + idx);
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (src = 0; src < dfa->nodes_len; ++src)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *elems = dfa->eclosures[src].elems;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (! ok))
|
2005-01-27 19:08:10 +00:00
|
|
|
|
return REG_ESPACE;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2005-01-27 19:08:10 +00:00
|
|
|
|
|
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate "eclosure" for all the node in DFA. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
calc_eclosure (re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node_idx;
|
|
|
|
|
bool incomplete;
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (dfa->nodes_len > 0);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
incomplete = false;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* For each nodes, calculate epsilon closure. */
|
2002-10-12 08:34:26 +00:00
|
|
|
|
for (node_idx = 0; ; ++node_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set eclosure_elem;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (node_idx == dfa->nodes_len)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (!incomplete)
|
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
incomplete = false;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
node_idx = 0;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (dfa->eclosures[node_idx].nelem != -1);
|
2004-11-18 23:57:34 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* If we have already calculated, skip it. */
|
|
|
|
|
if (dfa->eclosures[node_idx].nelem != 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue;
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* Calculate epsilon closure of 'node_idx'. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
|
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
|
|
|
|
|
|
|
|
|
if (dfa->eclosures[node_idx].nelem == 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
incomplete = true;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set_free (&eclosure_elem);
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate epsilon closure of NODE. */
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
static reg_errcode_t
|
2017-12-20 11:47:44 +00:00
|
|
|
|
calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
|
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 i;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set eclosure;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool incomplete = false;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
err = re_node_set_alloc (&eclosure, dfa->edests[node].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 err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-09-21 14:47:45 +00:00
|
|
|
|
/* An epsilon closure includes itself. */
|
|
|
|
|
eclosure.elems[eclosure.nelem++] = node;
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* This indicates that we are calculating this node now.
|
|
|
|
|
We reference this value to avoid infinite loop. */
|
|
|
|
|
dfa->eclosures[node].nelem = -1;
|
|
|
|
|
|
2008-05-15 04:42:20 +00:00
|
|
|
|
/* If the current node has constraints, duplicate all nodes
|
|
|
|
|
since they must inherit the constraints. */
|
|
|
|
|
if (dfa->nodes[node].constraint
|
2004-11-10 00:50:40 +00:00
|
|
|
|
&& dfa->edests[node].nelem
|
|
|
|
|
&& !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
|
2002-10-12 08:34:26 +00:00
|
|
|
|
{
|
2008-05-15 04:42:20 +00:00
|
|
|
|
err = duplicate_node_closure (dfa, node, node, node,
|
|
|
|
|
dfa->nodes[node].constraint);
|
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-10-12 08:34:26 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Expand each epsilon destination nodes. */
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (IS_EPSILON_NODE(dfa->nodes[node].type))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (i = 0; i < dfa->edests[node].nelem; ++i)
|
|
|
|
|
{
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set eclosure_elem;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx edest = dfa->edests[node].elems[i];
|
|
|
|
|
/* If calculating the epsilon closure of 'edest' is in progress,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return intermediate result. */
|
|
|
|
|
if (dfa->eclosures[edest].nelem == -1)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
incomplete = true;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* If we haven't calculated the epsilon closure of 'edest' yet,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
calculate now. Otherwise use calculated epsilon closure. */
|
|
|
|
|
if (dfa->eclosures[edest].nelem == 0)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
eclosure_elem = dfa->eclosures[edest];
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* Merge the epsilon closure of 'edest'. */
|
2010-01-15 20:03:16 +00:00
|
|
|
|
err = re_node_set_merge (&eclosure, &eclosure_elem);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (err != REG_NOERROR))
|
2010-01-15 20:03:16 +00:00
|
|
|
|
return err;
|
2015-03-10 20:53:34 +00:00
|
|
|
|
/* If the epsilon closure of 'edest' is incomplete,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
the epsilon closure of this node is also incomplete. */
|
|
|
|
|
if (dfa->eclosures[edest].nelem == 0)
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
incomplete = true;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
re_node_set_free (&eclosure_elem);
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (incomplete && !root)
|
|
|
|
|
dfa->eclosures[node].nelem = 0;
|
|
|
|
|
else
|
|
|
|
|
dfa->eclosures[node] = eclosure;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
*new_set = eclosure;
|
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Functions for token which are used in the parser. */
|
|
|
|
|
|
|
|
|
|
/* Fetch a token from INPUT.
|
|
|
|
|
We must not use this function inside bracket expressions. */
|
|
|
|
|
|
2003-11-21 23:42:18 +00:00
|
|
|
|
static void
|
2005-10-13 20:40:05 +00:00
|
|
|
|
fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2003-11-21 23:42:18 +00:00
|
|
|
|
re_string_skip_bytes (input, peek_token (result, input, syntax));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Peek a token from INPUT, and return the length of the token.
|
|
|
|
|
We must not use this function inside bracket expressions. */
|
|
|
|
|
|
|
|
|
|
static int
|
2005-10-13 20:40:05 +00:00
|
|
|
|
peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
|
|
if (re_string_eoi (input))
|
|
|
|
|
{
|
|
|
|
|
token->type = END_OF_RE;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c = re_string_peek_byte (input, 0);
|
|
|
|
|
token->opr.c = c;
|
|
|
|
|
|
2003-11-24 19:30:51 +00:00
|
|
|
|
token->word_char = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
token->mb_partial = 0;
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
|
if (input->mb_cur_max > 1
|
|
|
|
|
&& !re_string_first_byte (input, re_string_cur_idx (input)))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
token->mb_partial = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (c == '\\')
|
|
|
|
|
{
|
|
|
|
|
unsigned char c2;
|
|
|
|
|
if (re_string_cur_idx (input) + 1 >= re_string_length (input))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
token->type = BACK_SLASH;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
c2 = re_string_peek_byte_case (input, 1);
|
|
|
|
|
token->opr.c = c2;
|
|
|
|
|
token->type = CHARACTER;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (input->mb_cur_max > 1)
|
|
|
|
|
{
|
|
|
|
|
wint_t wc = re_string_wchar_at (input,
|
|
|
|
|
re_string_cur_idx (input) + 1);
|
|
|
|
|
token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
token->word_char = IS_WORD_CHAR (c2) != 0;
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
switch (c2)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
case '|':
|
|
|
|
|
if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
|
|
|
|
|
token->type = OP_ALT;
|
|
|
|
|
break;
|
|
|
|
|
case '1': case '2': case '3': case '4': case '5':
|
|
|
|
|
case '6': case '7': case '8': case '9':
|
|
|
|
|
if (!(syntax & RE_NO_BK_REFS))
|
|
|
|
|
{
|
|
|
|
|
token->type = OP_BACK_REF;
|
2004-12-06 02:56:42 +00:00
|
|
|
|
token->opr.idx = c2 - '1';
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '<':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
{
|
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = WORD_FIRST;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '>':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
{
|
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = WORD_LAST;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'b':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
{
|
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = WORD_DELIM;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'B':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
{
|
|
|
|
|
token->type = ANCHOR;
|
2005-01-26 19:56:03 +00:00
|
|
|
|
token->opr.ctx_type = NOT_WORD_DELIM;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'w':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
token->type = OP_WORD;
|
|
|
|
|
break;
|
|
|
|
|
case 'W':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
token->type = OP_NOTWORD;
|
|
|
|
|
break;
|
2003-09-23 05:43:03 +00:00
|
|
|
|
case 's':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
token->type = OP_SPACE;
|
|
|
|
|
break;
|
|
|
|
|
case 'S':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
token->type = OP_NOTSPACE;
|
|
|
|
|
break;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
case '`':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
{
|
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = BUF_FIRST;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '\'':
|
|
|
|
|
if (!(syntax & RE_NO_GNU_OPS))
|
|
|
|
|
{
|
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = BUF_LAST;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '(':
|
|
|
|
|
if (!(syntax & RE_NO_BK_PARENS))
|
|
|
|
|
token->type = OP_OPEN_SUBEXP;
|
|
|
|
|
break;
|
|
|
|
|
case ')':
|
|
|
|
|
if (!(syntax & RE_NO_BK_PARENS))
|
|
|
|
|
token->type = OP_CLOSE_SUBEXP;
|
|
|
|
|
break;
|
|
|
|
|
case '+':
|
|
|
|
|
if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
|
|
|
|
|
token->type = OP_DUP_PLUS;
|
|
|
|
|
break;
|
|
|
|
|
case '?':
|
|
|
|
|
if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
|
|
|
|
|
token->type = OP_DUP_QUESTION;
|
|
|
|
|
break;
|
|
|
|
|
case '{':
|
|
|
|
|
if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
|
|
|
|
|
token->type = OP_OPEN_DUP_NUM;
|
|
|
|
|
break;
|
|
|
|
|
case '}':
|
|
|
|
|
if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
|
|
|
|
|
token->type = OP_CLOSE_DUP_NUM;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token->type = CHARACTER;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (input->mb_cur_max > 1)
|
|
|
|
|
{
|
|
|
|
|
wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
|
|
|
|
|
token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
token->word_char = IS_WORD_CHAR (token->opr.c);
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '\n':
|
|
|
|
|
if (syntax & RE_NEWLINE_ALT)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_ALT;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '|':
|
|
|
|
|
if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_ALT;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '*':
|
|
|
|
|
token->type = OP_DUP_ASTERISK;
|
|
|
|
|
break;
|
|
|
|
|
case '+':
|
|
|
|
|
if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_DUP_PLUS;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '?':
|
|
|
|
|
if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_DUP_QUESTION;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '{':
|
|
|
|
|
if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_OPEN_DUP_NUM;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '}':
|
|
|
|
|
if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_CLOSE_DUP_NUM;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '(':
|
|
|
|
|
if (syntax & RE_NO_BK_PARENS)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_OPEN_SUBEXP;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case ')':
|
|
|
|
|
if (syntax & RE_NO_BK_PARENS)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
token->type = OP_CLOSE_SUBEXP;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '[':
|
|
|
|
|
token->type = OP_OPEN_BRACKET;
|
|
|
|
|
break;
|
|
|
|
|
case '.':
|
|
|
|
|
token->type = OP_PERIOD;
|
|
|
|
|
break;
|
|
|
|
|
case '^':
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
|
if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE))
|
|
|
|
|
&& re_string_cur_idx (input) != 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
char prev = re_string_peek_byte (input, -1);
|
2003-10-02 22:41:11 +00:00
|
|
|
|
if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = LINE_FIRST;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case '$':
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
|
if (!(syntax & RE_CONTEXT_INDEP_ANCHORS)
|
|
|
|
|
&& re_string_cur_idx (input) + 1 != re_string_length (input))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
re_token_t next;
|
|
|
|
|
re_string_skip_bytes (input, 1);
|
|
|
|
|
peek_token (&next, input, syntax);
|
|
|
|
|
re_string_skip_bytes (input, -1);
|
|
|
|
|
if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
token->type = ANCHOR;
|
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
|
|
|
|
token->opr.ctx_type = LINE_LAST;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Peek a token from INPUT, and return the length of the token.
|
|
|
|
|
We must not use this function out of bracket expressions. */
|
|
|
|
|
|
|
|
|
|
static int
|
2005-10-13 20:40:05 +00:00
|
|
|
|
peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char c;
|
|
|
|
|
if (re_string_eoi (input))
|
|
|
|
|
{
|
|
|
|
|
token->type = END_OF_RE;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
c = re_string_peek_byte (input, 0);
|
|
|
|
|
token->opr.c = c;
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
|
if (input->mb_cur_max > 1
|
|
|
|
|
&& !re_string_first_byte (input, re_string_cur_idx (input)))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
2004-01-14 01:45:37 +00:00
|
|
|
|
if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
|
|
|
|
|
&& re_string_cur_idx (input) + 1 < re_string_length (input))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
/* In this case, '\' escape a character. */
|
|
|
|
|
unsigned char c2;
|
2002-10-21 18:19:01 +00:00
|
|
|
|
re_string_skip_bytes (input, 1);
|
|
|
|
|
c2 = re_string_peek_byte (input, 0);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
token->opr.c = c2;
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (c == '[') /* '[' is a special char in a bracket exps. */
|
|
|
|
|
{
|
|
|
|
|
unsigned char c2;
|
|
|
|
|
int token_len;
|
2004-01-14 01:45:37 +00:00
|
|
|
|
if (re_string_cur_idx (input) + 1 < re_string_length (input))
|
|
|
|
|
c2 = re_string_peek_byte (input, 1);
|
|
|
|
|
else
|
|
|
|
|
c2 = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
token->opr.c = c2;
|
|
|
|
|
token_len = 2;
|
|
|
|
|
switch (c2)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
case '.':
|
|
|
|
|
token->type = OP_OPEN_COLL_ELEM;
|
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-11-06 20:36:47 +00:00
|
|
|
|
case '=':
|
|
|
|
|
token->type = OP_OPEN_EQUIV_CLASS;
|
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-11-06 20:36:47 +00:00
|
|
|
|
case ':':
|
|
|
|
|
if (syntax & RE_CHAR_CLASSES)
|
|
|
|
|
{
|
|
|
|
|
token->type = OP_OPEN_CHAR_CLASS;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
FALLTHROUGH;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
default:
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
token->opr.c = c;
|
|
|
|
|
token_len = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return token_len;
|
|
|
|
|
}
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '-':
|
|
|
|
|
token->type = OP_CHARSET_RANGE;
|
|
|
|
|
break;
|
|
|
|
|
case ']':
|
|
|
|
|
token->type = OP_CLOSE_BRACKET;
|
|
|
|
|
break;
|
|
|
|
|
case '^':
|
|
|
|
|
token->type = OP_NON_MATCH_LIST;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Functions for parser. */
|
|
|
|
|
|
|
|
|
|
/* Entry point of the parser.
|
|
|
|
|
Parse the regular expression REGEXP and return the structure tree.
|
2015-03-10 20:53:34 +00:00
|
|
|
|
If an error occurs, ERR is set by error code, and return NULL.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
This function build the following tree, from regular expression <reg_exp>:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
CAT
|
|
|
|
|
/ \
|
|
|
|
|
/ \
|
2002-02-26 19:06:03 +00:00
|
|
|
|
<reg_exp> EOR
|
|
|
|
|
|
|
|
|
|
CAT means concatenation.
|
|
|
|
|
EOR means end of regular expression. */
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
|
|
|
|
|
reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
bin_tree_t *tree, *eor, *root;
|
|
|
|
|
re_token_t current_token;
|
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 = syntax;
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return NULL;
|
[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
|
|
|
|
eor = create_tree (dfa, NULL, NULL, END_OF_RE);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (tree != NULL)
|
[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
|
|
|
|
root = create_tree (dfa, tree, eor, CONCAT);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
|
|
|
|
root = eor;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (eor == NULL || root == NULL))
|
2002-10-12 08:34:26 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function build the following tree, from regular expression
|
|
|
|
|
<branch1>|<branch2>:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
ALT
|
|
|
|
|
/ \
|
|
|
|
|
/ \
|
2002-02-26 19:06:03 +00:00
|
|
|
|
<branch1> <branch2>
|
|
|
|
|
|
2015-03-10 20:53:34 +00:00
|
|
|
|
ALT means alternative, which represents the operator '|'. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
bin_tree_t *tree, *branch = NULL;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
tree = parse_branch (regexp, preg, token, syntax, nest, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
while (token->type == OP_ALT)
|
|
|
|
|
{
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (token->type != OP_ALT && token->type != END_OF_RE
|
2002-11-06 20:36:47 +00:00
|
|
|
|
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
|
|
|
|
|
dfa->completed_bkref_map = initial_bkref_map;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
branch = parse_branch (regexp, preg, token, syntax, nest, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL))
|
2014-06-20 10:41:27 +00:00
|
|
|
|
{
|
|
|
|
|
if (tree != NULL)
|
|
|
|
|
postorder (tree, free_tree, NULL);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa->completed_bkref_map |= accumulated_bkref_map;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-08-12 19:18:45 +00:00
|
|
|
|
else
|
|
|
|
|
branch = NULL;
|
[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
|
|
|
|
tree = create_tree (dfa, tree, branch, OP_ALT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function build the following tree, from regular expression
|
|
|
|
|
<exp1><exp2>:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
CAT
|
|
|
|
|
/ \
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/ \
|
|
|
|
|
<exp1> <exp2>
|
|
|
|
|
|
|
|
|
|
CAT means concatenation. */
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bin_tree_t *tree, *expr;
|
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
tree = parse_expression (regexp, preg, token, syntax, nest, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
while (token->type != OP_ALT && token->type != END_OF_RE
|
2002-11-06 20:36:47 +00:00
|
|
|
|
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
expr = parse_expression (regexp, preg, token, syntax, nest, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2010-10-12 13:00:33 +00:00
|
|
|
|
if (tree != NULL)
|
|
|
|
|
postorder (tree, free_tree, NULL);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (tree != NULL && expr != NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bin_tree_t *newtree = create_tree (dfa, tree, expr, CONCAT);
|
2010-10-12 02:46:44 +00:00
|
|
|
|
if (newtree == NULL)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
postorder (expr, free_tree, NULL);
|
2010-10-12 02:46:44 +00:00
|
|
|
|
postorder (tree, free_tree, NULL);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2010-10-12 02:46:44 +00:00
|
|
|
|
tree = newtree;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (tree == NULL)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
tree = expr;
|
|
|
|
|
/* Otherwise expr == NULL, we don't need to create new tree. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function build the following tree, from regular expression a*:
|
2002-11-06 20:36:47 +00:00
|
|
|
|
*
|
|
|
|
|
|
|
|
|
|
|
a
|
2002-02-26 19:06:03 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
bin_tree_t *tree;
|
|
|
|
|
switch (token->type)
|
|
|
|
|
{
|
|
|
|
|
case CHARACTER:
|
[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
|
|
|
|
tree = create_token_tree (dfa, NULL, NULL, token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#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 (dfa->mb_cur_max > 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
while (!re_string_eoi (regexp)
|
|
|
|
|
&& !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
|
|
|
|
|
{
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bin_tree_t *mbc_remain;
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax);
|
[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
|
|
|
|
mbc_remain = create_token_tree (dfa, NULL, NULL, token);
|
|
|
|
|
tree = create_tree (dfa, tree, mbc_remain, CONCAT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mbc_remain == NULL || tree == NULL))
|
2003-02-21 01:52:32 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_OPEN_SUBEXP:
|
|
|
|
|
tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_OPEN_BRACKET:
|
|
|
|
|
tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_BACK_REF:
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx)))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESUBREG;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2004-12-06 02:56:42 +00:00
|
|
|
|
dfa->used_bkref_map |= 1 << token->opr.idx;
|
[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
|
|
|
|
tree = create_token_tree (dfa, NULL, NULL, token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
++dfa->nbackref;
|
|
|
|
|
dfa->has_mb_node = 1;
|
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2003-11-13 06:01:46 +00:00
|
|
|
|
case OP_OPEN_DUP_NUM:
|
|
|
|
|
if (syntax & RE_CONTEXT_INVALID_DUP)
|
|
|
|
|
{
|
|
|
|
|
*err = REG_BADRPT;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
FALLTHROUGH;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_DUP_ASTERISK:
|
|
|
|
|
case OP_DUP_PLUS:
|
|
|
|
|
case OP_DUP_QUESTION:
|
|
|
|
|
if (syntax & RE_CONTEXT_INVALID_OPS)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_BADRPT;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (syntax & RE_CONTEXT_INDEP_OPS)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return parse_expression (regexp, preg, token, syntax, nest, err);
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
FALLTHROUGH;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_CLOSE_SUBEXP:
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
|
if ((token->type == OP_CLOSE_SUBEXP)
|
|
|
|
|
&& !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ERPAREN;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
FALLTHROUGH;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_CLOSE_DUP_NUM:
|
|
|
|
|
/* We treat it as a normal character. */
|
|
|
|
|
|
|
|
|
|
/* Then we can these characters as normal characters. */
|
|
|
|
|
token->type = CHARACTER;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
/* mb_partial and word_char bits should be initialized already
|
|
|
|
|
by peek_token. */
|
[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
|
|
|
|
tree = create_token_tree (dfa, NULL, NULL, token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case ANCHOR:
|
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 ((token->opr.ctx_type
|
2005-01-26 19:56:03 +00:00
|
|
|
|
& (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
|
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->word_ops_used == 0)
|
|
|
|
|
init_word_char (dfa);
|
2005-01-26 19:56:03 +00:00
|
|
|
|
if (token->opr.ctx_type == WORD_DELIM
|
2010-01-15 05:35:15 +00:00
|
|
|
|
|| token->opr.ctx_type == NOT_WORD_DELIM)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
bin_tree_t *tree_first, *tree_last;
|
2005-01-26 19:56:03 +00:00
|
|
|
|
if (token->opr.ctx_type == WORD_DELIM)
|
|
|
|
|
{
|
|
|
|
|
token->opr.ctx_type = WORD_FIRST;
|
[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
|
|
|
|
tree_first = create_token_tree (dfa, NULL, NULL, token);
|
2005-01-26 19:56:03 +00:00
|
|
|
|
token->opr.ctx_type = WORD_LAST;
|
2010-01-15 05:35:15 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-01-26 19:56:03 +00:00
|
|
|
|
token->opr.ctx_type = INSIDE_WORD;
|
[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
|
|
|
|
tree_first = create_token_tree (dfa, NULL, NULL, token);
|
2005-01-26 19:56:03 +00:00
|
|
|
|
token->opr.ctx_type = INSIDE_NOTWORD;
|
2010-01-15 05:35:15 +00:00
|
|
|
|
}
|
[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
|
|
|
|
tree_last = create_token_tree (dfa, NULL, NULL, token);
|
|
|
|
|
tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree_first == NULL || tree_last == NULL
|
|
|
|
|
|| tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
[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
|
|
|
|
tree = create_token_tree (dfa, NULL, NULL, token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2003-02-21 01:52:32 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* We must return here, since ANCHORs can't be followed
|
2002-11-06 20:36:47 +00:00
|
|
|
|
by repetition operators.
|
|
|
|
|
eg. RE"^*" is invalid or "<ANCHOR(^)><CHAR(*)>",
|
|
|
|
|
it must not be "<ANCHOR(^)><REPEAT(*)>". */
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return tree;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_PERIOD:
|
[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
|
|
|
|
tree = create_token_tree (dfa, NULL, NULL, token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
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 (dfa->mb_cur_max > 1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
dfa->has_mb_node = 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_WORD:
|
|
|
|
|
case OP_NOTWORD:
|
2004-02-26 20:33:23 +00:00
|
|
|
|
tree = build_charclass_op (dfa, regexp->trans,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
"alnum",
|
|
|
|
|
"_",
|
2004-02-26 20:33:23 +00:00
|
|
|
|
token->type == OP_NOTWORD, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2003-09-23 05:43:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2003-09-23 05:43:03 +00:00
|
|
|
|
case OP_SPACE:
|
|
|
|
|
case OP_NOTSPACE:
|
2004-02-26 20:33:23 +00:00
|
|
|
|
tree = build_charclass_op (dfa, regexp->trans,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
"space",
|
|
|
|
|
"",
|
2004-02-26 20:33:23 +00:00
|
|
|
|
token->type == OP_NOTSPACE, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
break;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case OP_ALT:
|
|
|
|
|
case END_OF_RE:
|
|
|
|
|
return NULL;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
case BACK_SLASH:
|
|
|
|
|
*err = REG_EESCAPE;
|
|
|
|
|
return NULL;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
default:
|
|
|
|
|
/* Must not happen? */
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (false);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
|
2002-11-06 20:36:47 +00:00
|
|
|
|
|| token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
|
|
|
|
|
syntax, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL))
|
2014-06-19 13:38:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (tree != NULL)
|
|
|
|
|
postorder (tree, free_tree, NULL);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
tree = dup_tree;
|
2003-11-13 09:54:39 +00:00
|
|
|
|
/* In BRE consecutive duplications are not allowed. */
|
|
|
|
|
if ((syntax & RE_CONTEXT_INVALID_DUP)
|
|
|
|
|
&& (token->type == OP_DUP_ASTERISK
|
|
|
|
|
|| token->type == OP_OPEN_DUP_NUM))
|
|
|
|
|
{
|
2014-06-19 13:38:03 +00:00
|
|
|
|
if (tree != NULL)
|
|
|
|
|
postorder (tree, free_tree, NULL);
|
2003-11-13 09:54:39 +00:00
|
|
|
|
*err = REG_BADRPT;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function build the following tree, from regular expression
|
|
|
|
|
(<reg_exp>):
|
2002-11-06 20:36:47 +00:00
|
|
|
|
SUBEXP
|
|
|
|
|
|
|
|
|
|
|
<reg_exp>
|
2002-02-26 19:06:03 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_dfa_t *dfa = preg->buffer;
|
[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
|
|
|
|
bin_tree_t *tree;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
size_t cur_nsub;
|
|
|
|
|
cur_nsub = preg->re_nsub++;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* The subexpression may be a null string. */
|
|
|
|
|
if (token->type == OP_CLOSE_SUBEXP)
|
2002-07-10 23:09:16 +00:00
|
|
|
|
tree = NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err == REG_NOERROR
|
|
|
|
|
&& token->type != OP_CLOSE_SUBEXP))
|
2010-10-11 15:46:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (tree != NULL)
|
2010-10-12 02:46:44 +00:00
|
|
|
|
postorder (tree, free_tree, NULL);
|
2010-10-11 15:46:22 +00:00
|
|
|
|
*err = REG_EPAREN;
|
|
|
|
|
}
|
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-02-26 19:06:03 +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
|
|
|
|
|
|
|
|
|
if (cur_nsub <= '9' - '1')
|
|
|
|
|
dfa->completed_bkref_map |= 1 << cur_nsub;
|
[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
|
|
|
|
|
|
|
|
|
tree = create_tree (dfa, tree, NULL, SUBEXP);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-10-12 08:34:26 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
[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
|
|
|
|
tree->token.opr.idx = cur_nsub;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function parse repetition operators like "*", "+", "{1,3}" etc. */
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
|
|
|
|
|
re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-11-25 22:32:18 +00:00
|
|
|
|
bin_tree_t *tree = NULL, *old_tree = NULL;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx i, start, end, start_idx = re_string_cur_idx (regexp);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_token_t start_token = *token;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (token->type == OP_OPEN_DUP_NUM)
|
|
|
|
|
{
|
2003-12-27 23:40:06 +00:00
|
|
|
|
end = 0;
|
|
|
|
|
start = fetch_number (regexp, token, syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (start == -1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (token->type == CHARACTER && token->opr.c == ',')
|
|
|
|
|
start = 0; /* We treat "{,m}" as "{0,m}". */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*err = REG_BADBR; /* <re>{} is invalid. */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (start != -2))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* We treat "{n}" as "{n,n}". */
|
|
|
|
|
end = ((token->type == OP_CLOSE_DUP_NUM) ? start
|
|
|
|
|
: ((token->type == CHARACTER && token->opr.c == ',')
|
|
|
|
|
? fetch_number (regexp, token, syntax) : -2));
|
|
|
|
|
}
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (start == -2 || end == -2))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* Invalid sequence. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD)))
|
2003-12-27 23:40:06 +00:00
|
|
|
|
{
|
|
|
|
|
if (token->type == END_OF_RE)
|
|
|
|
|
*err = REG_EBRACE;
|
|
|
|
|
else
|
|
|
|
|
*err = REG_BADBR;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the syntax bit is set, rollback. */
|
|
|
|
|
re_string_set_index (regexp, start_idx);
|
|
|
|
|
*token = start_token;
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
/* mb_partial and word_char bits should be already initialized by
|
|
|
|
|
peek_token. */
|
|
|
|
|
return elem;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely ((end != -1 && start > end)
|
|
|
|
|
|| token->type != OP_CLOSE_DUP_NUM))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-12-27 23:40:06 +00:00
|
|
|
|
/* First number greater than second. */
|
|
|
|
|
*err = REG_BADBR;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end)))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESIZE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-12-27 23:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
start = (token->type == OP_DUP_PLUS) ? 1 : 0;
|
|
|
|
|
end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-25 22:32:18 +00:00
|
|
|
|
fetch_token (token, regexp, syntax);
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (elem == NULL))
|
2004-11-25 22:32:18 +00:00
|
|
|
|
return NULL;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (start == 0 && end == 0))
|
[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
|
|
|
|
{
|
|
|
|
|
postorder (elem, free_tree, NULL);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-04-20 00:57:03 +00:00
|
|
|
|
|
2003-12-27 23:40:06 +00:00
|
|
|
|
/* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (start > 0))
|
2003-12-27 23:40:06 +00:00
|
|
|
|
{
|
|
|
|
|
tree = elem;
|
|
|
|
|
for (i = 2; i <= start; ++i)
|
2003-12-22 06:45:04 +00:00
|
|
|
|
{
|
2003-12-27 23:40:06 +00:00
|
|
|
|
elem = duplicate_tree (elem, dfa);
|
[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
|
|
|
|
tree = create_tree (dfa, tree, elem, CONCAT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (elem == NULL || tree == NULL))
|
2003-12-22 06:45:04 +00:00
|
|
|
|
goto parse_dup_op_espace;
|
|
|
|
|
}
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2004-11-25 22:32:18 +00:00
|
|
|
|
if (start == end)
|
|
|
|
|
return tree;
|
2003-12-29 00:42:16 +00:00
|
|
|
|
|
2004-11-25 22:32:18 +00:00
|
|
|
|
/* Duplicate ELEM before it is marked optional. */
|
|
|
|
|
elem = duplicate_tree (elem, dfa);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (elem == NULL))
|
2014-07-13 00:07:21 +00:00
|
|
|
|
goto parse_dup_op_espace;
|
2004-11-25 22:32:18 +00:00
|
|
|
|
old_tree = tree;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
old_tree = NULL;
|
|
|
|
|
|
[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 (elem->token.type == SUBEXP)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
{
|
|
|
|
|
uintptr_t subidx = elem->token.opr.idx;
|
|
|
|
|
postorder (elem, mark_opt_subexp, (void *) subidx);
|
|
|
|
|
}
|
[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
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
tree = create_tree (dfa, elem, NULL,
|
|
|
|
|
(end == -1 ? OP_DUP_ASTERISK : OP_ALT));
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2004-11-25 22:32:18 +00:00
|
|
|
|
goto parse_dup_op_espace;
|
|
|
|
|
|
|
|
|
|
/* This loop is actually executed only when end != -1,
|
|
|
|
|
to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
|
|
|
|
|
already created the start+1-th copy. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (TYPE_SIGNED (Idx) || end != -1)
|
|
|
|
|
for (i = start + 2; i <= end; ++i)
|
|
|
|
|
{
|
|
|
|
|
elem = duplicate_tree (elem, dfa);
|
|
|
|
|
tree = create_tree (dfa, tree, elem, CONCAT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (elem == NULL || tree == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
goto parse_dup_op_espace;
|
|
|
|
|
|
|
|
|
|
tree = create_tree (dfa, tree, NULL, OP_ALT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
goto parse_dup_op_espace;
|
|
|
|
|
}
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
2004-11-25 22:32:18 +00:00
|
|
|
|
if (old_tree)
|
[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
|
|
|
|
tree = create_tree (dfa, old_tree, tree, CONCAT);
|
2004-11-25 22:32:18 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return tree;
|
|
|
|
|
|
|
|
|
|
parse_dup_op_espace:
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Size of the names for collating symbol/equivalence_class/character_class.
|
|
|
|
|
I'm not sure, but maybe enough. */
|
|
|
|
|
#define BRACKET_NAME_BUF_SIZE 32
|
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#ifndef _LIBC
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
|
|
|
|
# ifdef RE_ENABLE_I18N
|
|
|
|
|
/* Convert the byte B to the corresponding wide character. In a
|
2018-08-10 21:19:05 +00:00
|
|
|
|
unibyte locale, treat B as itself. In a multibyte locale, return
|
|
|
|
|
WEOF if B is an encoding error. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static wint_t
|
|
|
|
|
parse_byte (unsigned char b, re_charset_t *mbcset)
|
|
|
|
|
{
|
2018-08-10 21:19:05 +00:00
|
|
|
|
return mbcset == NULL ? b : __btowc (b);
|
2017-12-20 11:47:44 +00:00
|
|
|
|
}
|
2018-08-10 21:19:05 +00:00
|
|
|
|
# endif
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
/* Local function for parse_bracket_exp only used in case of NOT _LIBC.
|
|
|
|
|
Build the range expression which starts from START_ELEM, and ends
|
|
|
|
|
at END_ELEM. The result are written to MBCSET and SBCSET.
|
|
|
|
|
RANGE_ALLOC is the allocated size of mbcset->range_starts, and
|
2015-03-10 20:53:34 +00:00
|
|
|
|
mbcset->range_ends, is a pointer argument since we may
|
2002-04-26 20:52:02 +00:00
|
|
|
|
update it. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
build_range_exp (const reg_syntax_t syntax,
|
|
|
|
|
bitset_t sbcset,
|
|
|
|
|
re_charset_t *mbcset,
|
|
|
|
|
Idx *range_alloc,
|
|
|
|
|
const bracket_elem_t *start_elem,
|
|
|
|
|
const bracket_elem_t *end_elem)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# else /* not RE_ENABLE_I18N */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
build_range_exp (const reg_syntax_t syntax,
|
|
|
|
|
bitset_t sbcset,
|
|
|
|
|
const bracket_elem_t *start_elem,
|
|
|
|
|
const bracket_elem_t *end_elem)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# endif /* not RE_ENABLE_I18N */
|
2002-04-26 20:52:02 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int start_ch, end_ch;
|
|
|
|
|
/* Equivalence Classes and Character Classes can't be a range start/end. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
|
|
|
|
|
|| start_elem->type == CHAR_CLASS
|
|
|
|
|
|| end_elem->type == EQUIV_CLASS
|
|
|
|
|
|| end_elem->type == CHAR_CLASS))
|
2002-04-26 20:52:02 +00:00
|
|
|
|
return REG_ERANGE;
|
|
|
|
|
|
|
|
|
|
/* We can handle no multi character collating elements without libc
|
|
|
|
|
support. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely ((start_elem->type == COLL_SYM
|
|
|
|
|
&& strlen ((char *) start_elem->opr.name) > 1)
|
|
|
|
|
|| (end_elem->type == COLL_SYM
|
|
|
|
|
&& strlen ((char *) end_elem->opr.name) > 1)))
|
2002-04-26 20:52:02 +00:00
|
|
|
|
return REG_ECOLLATE;
|
|
|
|
|
|
|
|
|
|
# ifdef RE_ENABLE_I18N
|
|
|
|
|
{
|
* 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
|
|
|
|
wchar_t wc;
|
|
|
|
|
wint_t start_wc;
|
|
|
|
|
wint_t end_wc;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
|
|
|
|
|
start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
|
|
|
|
|
: 0));
|
2002-04-26 20:52:02 +00:00
|
|
|
|
end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
|
|
|
|
|
: 0));
|
2002-04-26 20:52:02 +00:00
|
|
|
|
start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
? parse_byte (start_ch, mbcset) : start_elem->opr.wch);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
? parse_byte (end_ch, mbcset) : end_elem->opr.wch);
|
2004-01-30 05:19:45 +00:00
|
|
|
|
if (start_wc == WEOF || end_wc == WEOF)
|
|
|
|
|
return REG_ECOLLATE;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
|
|
|
|
|
&& start_wc > end_wc))
|
2002-04-26 20:52:02 +00:00
|
|
|
|
return REG_ERANGE;
|
|
|
|
|
|
2004-01-14 02:42:20 +00:00
|
|
|
|
/* Got valid collation sequence values, add them as a new entry.
|
|
|
|
|
However, for !_LIBC we have no collation elements: if the
|
|
|
|
|
character set is single byte, the single byte character set
|
|
|
|
|
that we build below suffices. parse_bracket_exp passes
|
|
|
|
|
no MBCSET if dfa->mb_cur_max == 1. */
|
|
|
|
|
if (mbcset)
|
2002-04-26 20:52:02 +00:00
|
|
|
|
{
|
2010-01-15 05:35:15 +00:00
|
|
|
|
/* Check the space of the arrays. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*range_alloc == mbcset->nranges))
|
2010-01-15 05:35:15 +00:00
|
|
|
|
{
|
2004-01-14 02:42:20 +00:00
|
|
|
|
/* There is not enough space, need realloc. */
|
|
|
|
|
wchar_t *new_array_start, *new_array_end;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx new_nranges;
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
|
|
|
|
/* +1 in case of mbcset->nranges is 0. */
|
|
|
|
|
new_nranges = 2 * mbcset->nranges + 1;
|
|
|
|
|
/* Use realloc since mbcset->range_starts and mbcset->range_ends
|
|
|
|
|
are NULL if *range_alloc == 0. */
|
|
|
|
|
new_array_start = re_realloc (mbcset->range_starts, wchar_t,
|
2010-01-15 05:35:15 +00:00
|
|
|
|
new_nranges);
|
2004-01-14 02:42:20 +00:00
|
|
|
|
new_array_end = re_realloc (mbcset->range_ends, wchar_t,
|
2010-01-15 05:35:15 +00:00
|
|
|
|
new_nranges);
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_array_start == NULL
|
|
|
|
|
|| new_array_end == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (new_array_start);
|
|
|
|
|
re_free (new_array_end);
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
|
|
|
|
mbcset->range_starts = new_array_start;
|
|
|
|
|
mbcset->range_ends = new_array_end;
|
|
|
|
|
*range_alloc = new_nranges;
|
2010-01-15 05:35:15 +00:00
|
|
|
|
}
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
2010-01-15 05:35:15 +00:00
|
|
|
|
mbcset->range_starts[mbcset->nranges] = start_wc;
|
|
|
|
|
mbcset->range_ends[mbcset->nranges++] = end_wc;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Build the table for single byte characters. */
|
2004-02-06 18:30:34 +00:00
|
|
|
|
for (wc = 0; wc < SBC_MAX; ++wc)
|
2002-04-26 20:52:02 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (start_wc <= wc && wc <= end_wc)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bitset_set (sbcset, wc);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# else /* not RE_ENABLE_I18N */
|
|
|
|
|
{
|
|
|
|
|
unsigned int ch;
|
|
|
|
|
start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
|
|
|
|
|
: 0));
|
2002-04-26 20:52:02 +00:00
|
|
|
|
end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
|
2002-11-06 20:36:47 +00:00
|
|
|
|
: ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
|
|
|
|
|
: 0));
|
2002-04-26 20:52:02 +00:00
|
|
|
|
if (start_ch > end_ch)
|
|
|
|
|
return REG_ERANGE;
|
|
|
|
|
/* Build the table for single byte characters. */
|
2004-02-06 18:30:34 +00:00
|
|
|
|
for (ch = 0; ch < SBC_MAX; ++ch)
|
2002-04-26 20:52:02 +00:00
|
|
|
|
if (start_ch <= ch && ch <= end_ch)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
bitset_set (sbcset, ch);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
}
|
|
|
|
|
# endif /* not RE_ENABLE_I18N */
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
#endif /* not _LIBC */
|
|
|
|
|
|
|
|
|
|
#ifndef _LIBC
|
|
|
|
|
/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
|
|
|
|
|
Build the collating element which is represented by NAME.
|
|
|
|
|
The result are written to MBCSET and SBCSET.
|
|
|
|
|
COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
|
|
|
|
|
pointer argument since we may update it. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef RE_ENABLE_I18N
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *coll_sym_alloc, const unsigned char *name)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# else /* not RE_ENABLE_I18N */
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_collating_symbol (bitset_t sbcset, const unsigned char *name)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# endif /* not RE_ENABLE_I18N */
|
2002-04-26 20:52:02 +00:00
|
|
|
|
{
|
2002-09-10 17:39:58 +00:00
|
|
|
|
size_t name_len = strlen ((const char *) name);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (name_len != 1))
|
2002-04-26 20:52:02 +00:00
|
|
|
|
return REG_ECOLLATE;
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-09-10 17:39:58 +00:00
|
|
|
|
bitset_set (sbcset, name[0]);
|
2002-04-26 20:52:02 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* not _LIBC */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef _LIBC
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* Local function for parse_bracket_exp used in _LIBC environment.
|
|
|
|
|
Seek the collating symbol entry corresponding to NAME.
|
|
|
|
|
Return the index of the symbol in the SYMB_TABLE,
|
|
|
|
|
or -1 if not found. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
static inline int32_t
|
|
|
|
|
__attribute__ ((always_inline))
|
|
|
|
|
seek_collating_symbol_entry (const unsigned char *name, size_t name_len,
|
|
|
|
|
const int32_t *symb_table, int32_t table_size,
|
|
|
|
|
const unsigned char *extra)
|
|
|
|
|
{
|
|
|
|
|
int32_t elem;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
for (elem = 0; elem < table_size; elem++)
|
|
|
|
|
if (symb_table[2 * elem] != 0)
|
|
|
|
|
{
|
|
|
|
|
int32_t idx = symb_table[2 * elem + 1];
|
|
|
|
|
/* Skip the name of collating element name. */
|
|
|
|
|
idx += 1 + extra[idx];
|
|
|
|
|
if (/* Compare the length of the name. */
|
|
|
|
|
name_len == extra[idx]
|
|
|
|
|
/* Compare the name. */
|
|
|
|
|
&& memcmp (name, &extra[idx + 1], name_len) == 0)
|
|
|
|
|
/* Yep, this is the entry. */
|
|
|
|
|
return elem;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* Local function for parse_bracket_exp used in _LIBC environment.
|
|
|
|
|
Look up the collation sequence value of BR_ELEM.
|
|
|
|
|
Return the value if succeeded, UINT_MAX otherwise. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
static inline unsigned int
|
|
|
|
|
__attribute__ ((always_inline))
|
|
|
|
|
lookup_collation_sequence_value (bracket_elem_t *br_elem, uint32_t nrules,
|
|
|
|
|
const unsigned char *collseqmb,
|
|
|
|
|
const char *collseqwc, int32_t table_size,
|
|
|
|
|
const int32_t *symb_table,
|
|
|
|
|
const unsigned char *extra)
|
|
|
|
|
{
|
|
|
|
|
if (br_elem->type == SB_CHAR)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* if (MB_CUR_MAX == 1) */
|
|
|
|
|
if (nrules == 0)
|
|
|
|
|
return collseqmb[br_elem->opr.ch];
|
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
wint_t wc = __btowc (br_elem->opr.ch);
|
|
|
|
|
return __collseq_table_lookup (collseqwc, wc);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2021-11-02 17:07:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (br_elem->type == MB_CHAR)
|
|
|
|
|
{
|
|
|
|
|
if (nrules != 0)
|
|
|
|
|
return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
|
|
|
|
|
}
|
|
|
|
|
else if (br_elem->type == COLL_SYM)
|
|
|
|
|
{
|
|
|
|
|
size_t sym_name_len = strlen ((char *) br_elem->opr.name);
|
|
|
|
|
if (nrules != 0)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
int32_t elem, idx;
|
|
|
|
|
elem = seek_collating_symbol_entry (br_elem->opr.name,
|
|
|
|
|
sym_name_len,
|
|
|
|
|
symb_table, table_size,
|
|
|
|
|
extra);
|
|
|
|
|
if (elem != -1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* We found the entry. */
|
|
|
|
|
idx = symb_table[2 * elem + 1];
|
|
|
|
|
/* Skip the name of collating element name. */
|
|
|
|
|
idx += 1 + extra[idx];
|
|
|
|
|
/* Skip the byte sequence of the collating element. */
|
|
|
|
|
idx += 1 + extra[idx];
|
|
|
|
|
/* Adjust for the alignment. */
|
|
|
|
|
idx = (idx + 3) & ~3;
|
|
|
|
|
/* Skip the multibyte collation sequence value. */
|
|
|
|
|
idx += sizeof (unsigned int);
|
|
|
|
|
/* Skip the wide char sequence of the collating element. */
|
|
|
|
|
idx += sizeof (unsigned int) *
|
|
|
|
|
(1 + *(unsigned int *) (extra + idx));
|
|
|
|
|
/* Return the collation sequence value. */
|
|
|
|
|
return *(unsigned int *) (extra + idx);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sym_name_len == 1)
|
2021-11-02 17:07:59 +00:00
|
|
|
|
{
|
|
|
|
|
/* No valid character. Match it as a single byte
|
|
|
|
|
character. */
|
|
|
|
|
return collseqmb[br_elem->opr.name[0]];
|
|
|
|
|
}
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2021-11-02 17:07:59 +00:00
|
|
|
|
else if (sym_name_len == 1)
|
|
|
|
|
return collseqmb[br_elem->opr.name[0]];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2021-11-02 17:07:59 +00:00
|
|
|
|
return UINT_MAX;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* Local function for parse_bracket_exp used in _LIBC environment.
|
|
|
|
|
Build the range expression which starts from START_ELEM, and ends
|
|
|
|
|
at END_ELEM. The result are written to MBCSET and SBCSET.
|
|
|
|
|
RANGE_ALLOC is the allocated size of mbcset->range_starts, and
|
|
|
|
|
mbcset->range_ends, is a pointer argument since we may
|
|
|
|
|
update it. */
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
static inline reg_errcode_t
|
|
|
|
|
__attribute__ ((always_inline))
|
|
|
|
|
build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
|
|
|
|
|
bracket_elem_t *start_elem, bracket_elem_t *end_elem,
|
|
|
|
|
re_dfa_t *dfa, reg_syntax_t syntax, uint32_t nrules,
|
|
|
|
|
const unsigned char *collseqmb, const char *collseqwc,
|
|
|
|
|
int32_t table_size, const int32_t *symb_table,
|
|
|
|
|
const unsigned char *extra)
|
|
|
|
|
{
|
|
|
|
|
unsigned int ch;
|
|
|
|
|
uint32_t start_collseq;
|
|
|
|
|
uint32_t end_collseq;
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* Equivalence Classes and Character Classes can't be a range
|
|
|
|
|
start/end. */
|
|
|
|
|
if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
|
|
|
|
|
|| start_elem->type == CHAR_CLASS
|
|
|
|
|
|| end_elem->type == EQUIV_CLASS
|
|
|
|
|
|| end_elem->type == CHAR_CLASS))
|
|
|
|
|
return REG_ERANGE;
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* FIXME: Implement rational ranges here, too. */
|
|
|
|
|
start_collseq = lookup_collation_sequence_value (start_elem, nrules, collseqmb, collseqwc,
|
|
|
|
|
table_size, symb_table, extra);
|
|
|
|
|
end_collseq = lookup_collation_sequence_value (end_elem, nrules, collseqmb, collseqwc,
|
|
|
|
|
table_size, symb_table, extra);
|
|
|
|
|
/* Check start/end collation sequence values. */
|
|
|
|
|
if (__glibc_unlikely (start_collseq == UINT_MAX
|
|
|
|
|
|| end_collseq == UINT_MAX))
|
|
|
|
|
return REG_ECOLLATE;
|
|
|
|
|
if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
|
|
|
|
|
&& start_collseq > end_collseq))
|
|
|
|
|
return REG_ERANGE;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* Got valid collation sequence values, add them as a new entry.
|
|
|
|
|
However, if we have no collation elements, and the character set
|
|
|
|
|
is single byte, the single byte character set that we
|
|
|
|
|
build below suffices. */
|
|
|
|
|
if (nrules > 0 || dfa->mb_cur_max > 1)
|
|
|
|
|
{
|
|
|
|
|
/* Check the space of the arrays. */
|
|
|
|
|
if (__glibc_unlikely (*range_alloc == mbcset->nranges))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* There is not enough space, need realloc. */
|
|
|
|
|
uint32_t *new_array_start;
|
|
|
|
|
uint32_t *new_array_end;
|
|
|
|
|
int new_nranges;
|
|
|
|
|
|
|
|
|
|
/* +1 in case of mbcset->nranges is 0. */
|
|
|
|
|
new_nranges = 2 * mbcset->nranges + 1;
|
|
|
|
|
new_array_start = re_realloc (mbcset->range_starts, uint32_t,
|
|
|
|
|
new_nranges);
|
|
|
|
|
new_array_end = re_realloc (mbcset->range_ends, uint32_t,
|
|
|
|
|
new_nranges);
|
|
|
|
|
|
|
|
|
|
if (__glibc_unlikely (new_array_start == NULL
|
|
|
|
|
|| new_array_end == NULL))
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
|
|
|
|
|
mbcset->range_starts = new_array_start;
|
|
|
|
|
mbcset->range_ends = new_array_end;
|
|
|
|
|
*range_alloc = new_nranges;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2021-11-02 17:07:59 +00:00
|
|
|
|
|
|
|
|
|
mbcset->range_starts[mbcset->nranges] = start_collseq;
|
|
|
|
|
mbcset->range_ends[mbcset->nranges++] = end_collseq;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* Build the table for single byte characters. */
|
|
|
|
|
for (ch = 0; ch < SBC_MAX; ch++)
|
|
|
|
|
{
|
|
|
|
|
uint32_t ch_collseq;
|
|
|
|
|
/* if (MB_CUR_MAX == 1) */
|
|
|
|
|
if (nrules == 0)
|
|
|
|
|
ch_collseq = collseqmb[ch];
|
|
|
|
|
else
|
|
|
|
|
ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
|
|
|
|
|
if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
|
|
|
|
|
bitset_set (sbcset, ch);
|
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Local function for parse_bracket_exp used in _LIBC environment.
|
|
|
|
|
Build the collating element which is represented by NAME.
|
|
|
|
|
The result are written to MBCSET and SBCSET.
|
|
|
|
|
COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
|
|
|
|
|
pointer argument since we may update it. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2021-11-02 17:07:59 +00:00
|
|
|
|
static inline reg_errcode_t
|
|
|
|
|
__attribute__ ((always_inline))
|
|
|
|
|
build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
|
|
|
|
|
int *coll_sym_alloc, const unsigned char *name,
|
|
|
|
|
uint32_t nrules, int32_t table_size,
|
|
|
|
|
const int32_t *symb_table, const unsigned char *extra)
|
|
|
|
|
{
|
|
|
|
|
int32_t elem, idx;
|
|
|
|
|
size_t name_len = strlen ((const char *) name);
|
|
|
|
|
if (nrules != 0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
elem = seek_collating_symbol_entry (name, name_len, symb_table,
|
|
|
|
|
table_size, extra);
|
|
|
|
|
if (elem != -1)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
/* We found the entry. */
|
|
|
|
|
idx = symb_table[2 * elem + 1];
|
|
|
|
|
/* Skip the name of collating element name. */
|
|
|
|
|
idx += 1 + extra[idx];
|
|
|
|
|
}
|
|
|
|
|
else if (name_len == 1)
|
|
|
|
|
{
|
|
|
|
|
/* No valid character, treat it as a normal
|
|
|
|
|
character. */
|
|
|
|
|
bitset_set (sbcset, name[0]);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
2021-11-02 17:07:59 +00:00
|
|
|
|
else
|
|
|
|
|
return REG_ECOLLATE;
|
|
|
|
|
|
|
|
|
|
/* Got valid collation sequence, add it as a new entry. */
|
|
|
|
|
/* Check the space of the arrays. */
|
|
|
|
|
if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
|
|
|
|
|
{
|
|
|
|
|
/* Not enough, realloc it. */
|
|
|
|
|
/* +1 in case of mbcset->ncoll_syms is 0. */
|
|
|
|
|
int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
|
|
|
|
|
/* Use realloc since mbcset->coll_syms is NULL
|
|
|
|
|
if *alloc == 0. */
|
|
|
|
|
int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
|
|
|
|
|
new_coll_sym_alloc);
|
|
|
|
|
if (__glibc_unlikely (new_coll_syms == NULL))
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
mbcset->coll_syms = new_coll_syms;
|
|
|
|
|
*coll_sym_alloc = new_coll_sym_alloc;
|
|
|
|
|
}
|
|
|
|
|
mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (__glibc_unlikely (name_len != 1))
|
|
|
|
|
return REG_ECOLLATE;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2021-11-02 17:07:59 +00:00
|
|
|
|
bitset_set (sbcset, name[0]);
|
|
|
|
|
return REG_NOERROR;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2021-11-02 17:07:59 +00:00
|
|
|
|
}
|
|
|
|
|
#endif /* _LIBC */
|
|
|
|
|
|
|
|
|
|
/* This function parse bracket expression like "[abc]", "[a-c]",
|
|
|
|
|
"[[.a-a.]]" etc. */
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
|
|
|
|
parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
|
|
|
|
|
reg_syntax_t syntax, reg_errcode_t *err)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
const unsigned char *collseqmb;
|
|
|
|
|
const char *collseqwc = NULL;
|
|
|
|
|
uint32_t nrules;
|
|
|
|
|
int32_t table_size = 0;
|
|
|
|
|
const int32_t *symb_table = NULL;
|
|
|
|
|
const unsigned char *extra = NULL;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_token_t br_token;
|
|
|
|
|
re_bitset_ptr_t sbcset;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_charset_t *mbcset;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
|
|
|
|
|
Idx equiv_class_alloc = 0, char_class_alloc = 0;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool non_match = false;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
bin_tree_t *work_tree;
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
int token_len;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
bool first_round = true;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef _LIBC
|
2002-09-10 17:39:58 +00:00
|
|
|
|
collseqmb = (const unsigned char *)
|
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
|
|
|
|
if (nrules)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
if (MB_CUR_MAX > 1)
|
|
|
|
|
*/
|
2005-10-14 22:56:25 +00:00
|
|
|
|
collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
|
|
|
|
|
symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
_NL_COLLATE_SYMB_TABLEMB);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
_NL_COLLATE_SYMB_EXTRAMB);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
#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
|
|
|
|
sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#else
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (sbcset == NULL))
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2010-10-11 15:46:22 +00:00
|
|
|
|
re_free (sbcset);
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
re_free (mbcset);
|
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token_len = peek_token_bracket (token, regexp, syntax);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token->type == END_OF_RE))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_BADPAT;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
goto parse_bracket_exp_free_return;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
if (token->type == OP_NON_MATCH_LIST)
|
|
|
|
|
{
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mbcset->non_match = 1;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
non_match = true;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
|
2007-02-05 15:23:55 +00:00
|
|
|
|
bitset_set (sbcset, '\n');
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_string_skip_bytes (regexp, token_len); /* Skip a token. */
|
|
|
|
|
token_len = peek_token_bracket (token, regexp, syntax);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token->type == END_OF_RE))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_BADPAT;
|
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We treat the first ']' as a normal character. */
|
|
|
|
|
if (token->type == OP_CLOSE_BRACKET)
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
bracket_elem_t start_elem, end_elem;
|
2002-09-10 17:39:58 +00:00
|
|
|
|
unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE];
|
|
|
|
|
unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
reg_errcode_t ret;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
int token_len2 = 0;
|
|
|
|
|
bool is_range_exp = false;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_token_t token2;
|
|
|
|
|
|
|
|
|
|
start_elem.opr.name = start_name_buf;
|
2015-01-07 17:29:26 +00:00
|
|
|
|
start_elem.type = COLL_SYM;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
|
2003-11-13 20:04:16 +00:00
|
|
|
|
syntax, first_round);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = ret;
|
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
first_round = false;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2003-11-13 20:04:16 +00:00
|
|
|
|
/* Get information about the next token. We need it in any case. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
token_len = peek_token_bracket (token, regexp, syntax);
|
2003-11-13 20:04:16 +00:00
|
|
|
|
|
|
|
|
|
/* Do not check for ranges if we know they are not allowed. */
|
|
|
|
|
if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token->type == END_OF_RE))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-11-13 20:04:16 +00:00
|
|
|
|
*err = REG_EBRACK;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
2003-11-13 20:04:16 +00:00
|
|
|
|
if (token->type == OP_CHARSET_RANGE)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-11-13 20:04:16 +00:00
|
|
|
|
re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
|
|
|
|
|
token_len2 = peek_token_bracket (&token2, regexp, syntax);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token2.type == END_OF_RE))
|
2003-11-13 20:04:16 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_EBRACK;
|
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
|
|
|
|
if (token2.type == OP_CLOSE_BRACKET)
|
|
|
|
|
{
|
|
|
|
|
/* We treat the last '-' as a normal character. */
|
|
|
|
|
re_string_skip_bytes (regexp, -token_len);
|
|
|
|
|
token->type = CHARACTER;
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
is_range_exp = true;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (is_range_exp == true)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
end_elem.opr.name = end_name_buf;
|
2015-01-07 17:29:26 +00:00
|
|
|
|
end_elem.type = COLL_SYM;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
dfa, syntax, true);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
*err = ret;
|
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token_len = peek_token_bracket (token, regexp, syntax);
|
2003-11-13 20:04:16 +00:00
|
|
|
|
|
2004-01-14 02:42:20 +00:00
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
*err = build_range_exp (sbcset, mbcset, &range_alloc,
|
2021-11-02 17:07:59 +00:00
|
|
|
|
&start_elem, &end_elem,
|
|
|
|
|
dfa, syntax, nrules, collseqmb, collseqwc,
|
|
|
|
|
table_size, symb_table, extra);
|
2004-01-14 02:42:20 +00:00
|
|
|
|
#else
|
|
|
|
|
# ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
*err = build_range_exp (syntax, sbcset,
|
2004-01-14 02:42:20 +00:00
|
|
|
|
dfa->mb_cur_max > 1 ? mbcset : NULL,
|
|
|
|
|
&range_alloc, &start_elem, &end_elem);
|
|
|
|
|
# else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
*err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
|
2004-01-14 02:42:20 +00:00
|
|
|
|
# endif
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
switch (start_elem.type)
|
|
|
|
|
{
|
|
|
|
|
case SB_CHAR:
|
|
|
|
|
bitset_set (sbcset, start_elem.opr.ch);
|
|
|
|
|
break;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-11-06 20:36:47 +00:00
|
|
|
|
case MB_CHAR:
|
|
|
|
|
/* Check whether the array has enough space. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
2003-11-23 19:21:23 +00:00
|
|
|
|
wchar_t *new_mbchars;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* Not enough, realloc it. */
|
|
|
|
|
/* +1 in case of mbcset->nmbchars is 0. */
|
|
|
|
|
mbchar_alloc = 2 * mbcset->nmbchars + 1;
|
|
|
|
|
/* Use realloc since array is NULL if *alloc == 0. */
|
2003-11-23 19:21:23 +00:00
|
|
|
|
new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
|
|
|
|
|
mbchar_alloc);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_mbchars == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto parse_bracket_exp_espace;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
mbcset->mbchars = new_mbchars;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
|
|
|
|
|
break;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-11-06 20:36:47 +00:00
|
|
|
|
case EQUIV_CLASS:
|
|
|
|
|
*err = build_equiv_class (sbcset,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-11-06 20:36:47 +00:00
|
|
|
|
mbcset, &equiv_class_alloc,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
start_elem.opr.name);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
break;
|
|
|
|
|
case COLL_SYM:
|
|
|
|
|
*err = build_collating_symbol (sbcset,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-11-06 20:36:47 +00:00
|
|
|
|
mbcset, &coll_sym_alloc,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2021-11-02 17:07:59 +00:00
|
|
|
|
start_elem.opr.name,
|
|
|
|
|
nrules, table_size, symb_table, extra);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
break;
|
|
|
|
|
case CHAR_CLASS:
|
2003-06-12 18:29:52 +00:00
|
|
|
|
*err = build_charclass (regexp->trans, sbcset,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2003-01-16 19:20:36 +00:00
|
|
|
|
mbcset, &char_class_alloc,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
(const char *) start_elem.opr.name,
|
|
|
|
|
syntax);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*err != REG_NOERROR))
|
2003-01-16 19:20:36 +00:00
|
|
|
|
goto parse_bracket_exp_free_return;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-11-04 19:47:11 +00:00
|
|
|
|
DEBUG_ASSERT (false);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token->type == END_OF_RE))
|
2003-11-13 20:04:16 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_EBRACK;
|
|
|
|
|
goto parse_bracket_exp_free_return;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (token->type == OP_CLOSE_BRACKET)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
re_string_skip_bytes (regexp, token_len); /* Skip a token. */
|
|
|
|
|
|
|
|
|
|
/* If it is non-matching list. */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
if (non_match)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
bitset_not (sbcset);
|
2004-01-14 02:42:20 +00:00
|
|
|
|
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* Ensure only single byte characters are set. */
|
|
|
|
|
if (dfa->mb_cur_max > 1)
|
|
|
|
|
bitset_mask (sbcset, dfa->sb_char);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes
|
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
|
|
|
|
|| mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes
|
|
|
|
|
|| mbcset->non_match)))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
bin_tree_t *mbc_tree;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
int sbc_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Build a tree for complex bracket. */
|
2003-11-18 23:40:59 +00:00
|
|
|
|
dfa->has_mb_node = 1;
|
[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
|
|
|
|
br_token.type = COMPLEX_BRACKET;
|
|
|
|
|
br_token.opr.mbcset = mbcset;
|
|
|
|
|
mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mbc_tree == NULL))
|
[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
|
|
|
|
goto parse_bracket_exp_espace;
|
[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 (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
|
2003-11-18 23:40:59 +00:00
|
|
|
|
if (sbcset[sbc_idx])
|
|
|
|
|
break;
|
|
|
|
|
/* If there are no bits set in sbcset, there is no point
|
|
|
|
|
of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */
|
[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 (sbc_idx < BITSET_WORDS)
|
[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
|
|
|
|
{
|
2010-01-15 05:35:15 +00:00
|
|
|
|
/* Build a tree for simple bracket. */
|
|
|
|
|
br_token.type = SIMPLE_BRACKET;
|
|
|
|
|
br_token.opr.sbcset = sbcset;
|
|
|
|
|
work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (work_tree == NULL))
|
2010-01-15 05:35:15 +00:00
|
|
|
|
goto parse_bracket_exp_espace;
|
[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
|
|
|
|
|
2010-01-15 05:35:15 +00:00
|
|
|
|
/* Then join them by ALT node. */
|
|
|
|
|
work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (work_tree == NULL))
|
2010-01-15 05:35:15 +00:00
|
|
|
|
goto parse_bracket_exp_espace;
|
[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
|
|
|
|
}
|
|
|
|
|
else
|
2003-11-18 23:40:59 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (sbcset);
|
[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
|
|
|
|
work_tree = mbc_tree;
|
2003-11-18 23:40:59 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2005-01-27 19:08:10 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-01-27 19:08:10 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
free_charset (mbcset);
|
|
|
|
|
#endif
|
[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
|
|
|
|
/* Build a tree for simple bracket. */
|
|
|
|
|
br_token.type = SIMPLE_BRACKET;
|
|
|
|
|
br_token.opr.sbcset = sbcset;
|
|
|
|
|
work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (work_tree == NULL))
|
2010-01-15 05:35:15 +00:00
|
|
|
|
goto parse_bracket_exp_espace;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
[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
|
|
|
|
return work_tree;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
parse_bracket_exp_espace:
|
|
|
|
|
*err = REG_ESPACE;
|
2002-04-26 20:52:02 +00:00
|
|
|
|
parse_bracket_exp_free_return:
|
|
|
|
|
re_free (sbcset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-04-26 20:52:02 +00:00
|
|
|
|
free_charset (mbcset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
/* Parse an element in the bracket expression. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
|
|
|
|
|
re_token_t *token, int token_len, re_dfa_t *dfa,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
reg_syntax_t syntax, bool accept_hyphen)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
int cur_char_size;
|
|
|
|
|
cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
|
|
|
|
|
if (cur_char_size > 1)
|
|
|
|
|
{
|
|
|
|
|
elem->type = MB_CHAR;
|
|
|
|
|
elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp));
|
|
|
|
|
re_string_skip_bytes (regexp, cur_char_size);
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
re_string_skip_bytes (regexp, token_len); /* Skip a token. */
|
|
|
|
|
if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
|
|
|
|
|
|| token->type == OP_OPEN_EQUIV_CLASS)
|
|
|
|
|
return parse_bracket_symbol (elem, regexp, token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen)
|
2003-11-13 20:04:16 +00:00
|
|
|
|
{
|
|
|
|
|
/* A '-' must only appear as anything but a range indicator before
|
|
|
|
|
the closing bracket. Everything else is an error. */
|
|
|
|
|
re_token_t token2;
|
|
|
|
|
(void) peek_token_bracket (&token2, regexp, syntax);
|
|
|
|
|
if (token2.type != OP_CLOSE_BRACKET)
|
|
|
|
|
/* The actual error value is not standardized since this whole
|
|
|
|
|
case is undefined. But ERANGE makes good sense. */
|
|
|
|
|
return REG_ERANGE;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
elem->type = SB_CHAR;
|
|
|
|
|
elem->opr.ch = token->opr.c;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-26 20:52:02 +00:00
|
|
|
|
/* Parse a bracket symbol in the bracket expression. Bracket symbols are
|
|
|
|
|
such as [:<character_class>:], [.<collating_element>.], and
|
|
|
|
|
[=<equivalent_class>=]. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
|
|
|
|
|
re_token_t *token)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char ch, delim = token->opr.c;
|
|
|
|
|
int i = 0;
|
2004-01-14 01:45:37 +00:00
|
|
|
|
if (re_string_eoi(regexp))
|
|
|
|
|
return REG_EBRACK;
|
2002-04-20 00:57:03 +00:00
|
|
|
|
for (;; ++i)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-01-14 01:45:37 +00:00
|
|
|
|
if (i >= BRACKET_NAME_BUF_SIZE)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_EBRACK;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (token->type == OP_OPEN_CHAR_CLASS)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
ch = re_string_fetch_byte_case (regexp);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 20:36:47 +00:00
|
|
|
|
ch = re_string_fetch_byte (regexp);
|
2004-01-14 01:45:37 +00:00
|
|
|
|
if (re_string_eoi(regexp))
|
|
|
|
|
return REG_EBRACK;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (ch == delim && re_string_peek_byte (regexp, 0) == ']')
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
elem->opr.name[i] = ch;
|
|
|
|
|
}
|
|
|
|
|
re_string_skip_bytes (regexp, 1);
|
|
|
|
|
elem->opr.name[i] = '\0';
|
|
|
|
|
switch (token->type)
|
|
|
|
|
{
|
|
|
|
|
case OP_OPEN_COLL_ELEM:
|
|
|
|
|
elem->type = COLL_SYM;
|
|
|
|
|
break;
|
|
|
|
|
case OP_OPEN_EQUIV_CLASS:
|
|
|
|
|
elem->type = EQUIV_CLASS;
|
|
|
|
|
break;
|
|
|
|
|
case OP_OPEN_CHAR_CLASS:
|
|
|
|
|
elem->type = CHAR_CLASS;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for parse_bracket_exp.
|
|
|
|
|
Build the equivalence class which is represented by NAME.
|
|
|
|
|
The result are written to MBCSET and SBCSET.
|
|
|
|
|
EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
|
2015-03-10 20:53:34 +00:00
|
|
|
|
is a pointer argument since we may update it. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *equiv_class_alloc, const unsigned char *name)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#else /* not RE_ENABLE_I18N */
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_equiv_class (bitset_t sbcset, const unsigned char *name)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2005-10-13 20:40:05 +00:00
|
|
|
|
#ifdef _LIBC
|
2002-02-26 19:06:03 +00:00
|
|
|
|
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
|
|
|
|
if (nrules != 0)
|
|
|
|
|
{
|
|
|
|
|
const int32_t *table, *indirect;
|
|
|
|
|
const unsigned char *weights, *extra, *cp;
|
2002-09-10 17:39:58 +00:00
|
|
|
|
unsigned char char_buf[2];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int32_t idx1, idx2;
|
|
|
|
|
unsigned int ch;
|
|
|
|
|
size_t len;
|
|
|
|
|
/* Calculate the index for equivalence class. */
|
2002-09-10 17:39:58 +00:00
|
|
|
|
cp = name;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
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,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
_NL_COLLATE_EXTRAMB);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
|
2002-11-06 20:36:47 +00:00
|
|
|
|
_NL_COLLATE_INDIRECTMB);
|
2014-09-11 23:02:17 +00:00
|
|
|
|
idx1 = findidx (table, indirect, extra, &cp, -1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (idx1 == 0 || *cp != '\0'))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* This isn't a valid character. */
|
|
|
|
|
return REG_ECOLLATE;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 03:26:08 +00:00
|
|
|
|
/* Build single byte matching table for this equivalence class. */
|
2007-10-12 17:47:19 +00:00
|
|
|
|
len = weights[idx1 & 0xffffff];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (ch = 0; ch < SBC_MAX; ++ch)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
char_buf[0] = ch;
|
|
|
|
|
cp = char_buf;
|
2014-09-11 23:02:17 +00:00
|
|
|
|
idx2 = findidx (table, indirect, extra, &cp, 1);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/*
|
2002-11-06 20:36:47 +00:00
|
|
|
|
idx2 = table[ch];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
*/
|
2002-11-06 20:36:47 +00:00
|
|
|
|
if (idx2 == 0)
|
|
|
|
|
/* This isn't a valid character. */
|
|
|
|
|
continue;
|
2007-10-12 17:47:19 +00:00
|
|
|
|
/* Compare only if the length matches and the collation rule
|
|
|
|
|
index is the same. */
|
2018-07-20 09:58:51 +00:00
|
|
|
|
if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)
|
|
|
|
|
&& memcmp (weights + (idx1 & 0xffffff) + 1,
|
|
|
|
|
weights + (idx2 & 0xffffff) + 1, len) == 0)
|
|
|
|
|
bitset_set (sbcset, ch);
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Check whether the array has enough space. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
/* Not enough, realloc it. */
|
|
|
|
|
/* +1 in case of mbcset->nequiv_classes is 0. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
/* Use realloc since the array is NULL if *alloc == 0. */
|
2003-11-23 19:21:23 +00:00
|
|
|
|
int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
|
|
|
|
|
int32_t,
|
|
|
|
|
new_equiv_class_alloc);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_equiv_classes == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
mbcset->equiv_classes = new_equiv_classes;
|
|
|
|
|
*equiv_class_alloc = new_equiv_class_alloc;
|
2002-11-06 20:36:47 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1;
|
|
|
|
|
}
|
|
|
|
|
else
|
2004-01-14 02:42:20 +00:00
|
|
|
|
#endif /* _LIBC */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (strlen ((const char *) name) != 1))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ECOLLATE;
|
2002-09-10 17:39:58 +00:00
|
|
|
|
bitset_set (sbcset, *name);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for parse_bracket_exp.
|
|
|
|
|
Build the character class which is represented by NAME.
|
|
|
|
|
The result are written to MBCSET and SBCSET.
|
|
|
|
|
CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes,
|
2015-03-10 20:53:34 +00:00
|
|
|
|
is a pointer argument since we may update it. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_charset_t *mbcset, Idx *char_class_alloc,
|
|
|
|
|
const char *class_name, reg_syntax_t syntax)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#else /* not RE_ENABLE_I18N */
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *class_name, reg_syntax_t syntax)
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *name = class_name;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
|
|
|
|
|
/* In case of REG_ICASE "upper" and "lower" match the both of
|
|
|
|
|
upper and lower cases. */
|
|
|
|
|
if ((syntax & RE_ICASE)
|
|
|
|
|
&& (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
|
|
|
|
|
name = "alpha";
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Check the space of the arrays. */
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
{
|
|
|
|
|
/* Not enough, realloc it. */
|
|
|
|
|
/* +1 in case of mbcset->nchar_classes is 0. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx new_char_class_alloc = 2 * mbcset->nchar_classes + 1;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Use realloc since array is NULL if *alloc == 0. */
|
2003-11-23 19:21:23 +00:00
|
|
|
|
wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
|
|
|
|
|
new_char_class_alloc);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (new_char_classes == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return REG_ESPACE;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
mbcset->char_classes = new_char_classes;
|
|
|
|
|
*char_class_alloc = new_char_class_alloc;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2003-06-12 18:29:52 +00:00
|
|
|
|
#define BUILD_CHARCLASS_LOOP(ctype_func) \
|
2005-10-14 05:54:47 +00:00
|
|
|
|
do { \
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (trans != NULL)) \
|
2007-07-12 18:26:36 +00:00
|
|
|
|
{ \
|
2005-10-14 05:54:47 +00:00
|
|
|
|
for (i = 0; i < SBC_MAX; ++i) \
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (ctype_func (i)) \
|
2005-10-14 05:54:47 +00:00
|
|
|
|
bitset_set (sbcset, trans[i]); \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
for (i = 0; i < SBC_MAX; ++i) \
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (ctype_func (i)) \
|
2005-10-14 05:54:47 +00:00
|
|
|
|
bitset_set (sbcset, i); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (strcmp (name, "alnum") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isalnum);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "cntrl") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (iscntrl);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "lower") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (islower);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "space") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isspace);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "alpha") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isalpha);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "digit") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isdigit);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "print") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isprint);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "upper") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isupper);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "blank") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isblank);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "graph") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isgraph);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "punct") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (ispunct);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (strcmp (name, "xdigit") == 0)
|
2005-10-14 05:54:47 +00:00
|
|
|
|
BUILD_CHARCLASS_LOOP (isxdigit);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
|
|
|
|
return REG_ECTYPE;
|
|
|
|
|
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
|
2017-12-20 11:47:44 +00:00
|
|
|
|
const char *class_name,
|
|
|
|
|
const char *extra, bool non_match,
|
2005-10-13 20:40:05 +00:00
|
|
|
|
reg_errcode_t *err)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
re_bitset_ptr_t sbcset;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_charset_t *mbcset;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx alloc = 0;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
reg_errcode_t ret;
|
|
|
|
|
bin_tree_t *tree;
|
|
|
|
|
|
[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
|
|
|
|
sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (sbcset == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mbcset == NULL))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (sbcset);
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2017-12-20 11:47:44 +00:00
|
|
|
|
mbcset->non_match = non_match;
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-20 00:57:03 +00:00
|
|
|
|
/* We don't care the syntax in this case. */
|
2003-06-12 18:29:52 +00:00
|
|
|
|
ret = build_charclass (trans, sbcset,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-11-06 20:36:47 +00:00
|
|
|
|
mbcset, &alloc,
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2003-09-23 05:43:03 +00:00
|
|
|
|
class_name, 0);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (ret != REG_NOERROR))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
re_free (sbcset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
free_charset (mbcset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2003-01-16 19:20:36 +00:00
|
|
|
|
*err = ret;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-04-26 20:52:02 +00:00
|
|
|
|
/* \w match '_' also. */
|
2003-09-23 05:43:03 +00:00
|
|
|
|
for (; *extra; extra++)
|
|
|
|
|
bitset_set (sbcset, *extra);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* If it is non-matching list. */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
if (non_match)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
bitset_not (sbcset);
|
|
|
|
|
|
2003-11-24 19:30:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* Ensure only single byte characters are set. */
|
|
|
|
|
if (dfa->mb_cur_max > 1)
|
|
|
|
|
bitset_mask (sbcset, dfa->sb_char);
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Build a tree for simple bracket. */
|
2019-11-04 19:47:11 +00:00
|
|
|
|
re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
|
[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
|
|
|
|
tree = create_token_tree (dfa, NULL, NULL, &br_token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (tree == NULL))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
goto build_word_op_espace;
|
|
|
|
|
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#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 (dfa->mb_cur_max > 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
bin_tree_t *mbc_tree;
|
|
|
|
|
/* Build a tree for complex bracket. */
|
|
|
|
|
br_token.type = COMPLEX_BRACKET;
|
|
|
|
|
br_token.opr.mbcset = mbcset;
|
|
|
|
|
dfa->has_mb_node = 1;
|
[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
|
|
|
|
mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (mbc_tree == NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
goto build_word_op_espace;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Then join them by ALT node. */
|
[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
|
|
|
|
tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_likely (mbc_tree != NULL))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return tree;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
free_charset (mbcset);
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#else /* not RE_ENABLE_I18N */
|
|
|
|
|
return tree;
|
|
|
|
|
#endif /* not RE_ENABLE_I18N */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
build_word_op_espace:
|
|
|
|
|
re_free (sbcset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
free_charset (mbcset);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This is intended for the expressions like "a{1,3}".
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Fetch a number from 'input', and return the number.
|
|
|
|
|
Return -1 if the number field is empty like "{,1}".
|
|
|
|
|
Return RE_DUP_MAX + 1 if the number field is too large.
|
|
|
|
|
Return -2 if an error occurred. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static Idx
|
2005-10-13 20:40:05 +00:00
|
|
|
|
fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx num = -1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned char c;
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2003-11-21 23:42:18 +00:00
|
|
|
|
fetch_token (token, input, syntax);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
c = token->opr.c;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (token->type == END_OF_RE))
|
2002-11-06 20:36:47 +00:00
|
|
|
|
return -2;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (token->type == OP_CLOSE_DUP_NUM || c == ',')
|
2002-11-06 20:36:47 +00:00
|
|
|
|
break;
|
2002-04-20 00:57:03 +00:00
|
|
|
|
num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
|
2017-12-20 11:47:44 +00:00
|
|
|
|
? -2
|
|
|
|
|
: num == -1
|
|
|
|
|
? c - '0'
|
|
|
|
|
: MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static void
|
|
|
|
|
free_charset (re_charset_t *cset)
|
|
|
|
|
{
|
|
|
|
|
re_free (cset->mbchars);
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef _LIBC
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_free (cset->coll_syms);
|
|
|
|
|
re_free (cset->equiv_classes);
|
2018-08-01 20:22:16 +00:00
|
|
|
|
# endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_free (cset->range_starts);
|
|
|
|
|
re_free (cset->range_ends);
|
|
|
|
|
re_free (cset->char_classes);
|
|
|
|
|
re_free (cset);
|
|
|
|
|
}
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Functions for binary tree operation. */
|
|
|
|
|
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
/* Create a tree node. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
|
|
|
|
|
re_token_type_t type)
|
[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
|
|
|
|
{
|
2019-11-04 19:47:11 +00:00
|
|
|
|
re_token_t t = { .type = type };
|
[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
|
|
|
|
return create_token_tree (dfa, left, right, &t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
|
|
|
|
|
const re_token_t *token)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
bin_tree_t *tree;
|
2018-10-15 03:20:08 +00:00
|
|
|
|
if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
|
|
|
|
|
|
|
|
|
|
if (storage == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
storage->next = dfa->str_tree_storage;
|
|
|
|
|
dfa->str_tree_storage = storage;
|
|
|
|
|
dfa->str_tree_storage_idx = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++];
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
tree->parent = NULL;
|
|
|
|
|
tree->left = left;
|
|
|
|
|
tree->right = right;
|
[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
|
|
|
|
tree->token = *token;
|
|
|
|
|
tree->token.duplicated = 0;
|
|
|
|
|
tree->token.opt_subexp = 0;
|
|
|
|
|
tree->first = NULL;
|
|
|
|
|
tree->next = NULL;
|
|
|
|
|
tree->node_idx = -1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (left != NULL)
|
|
|
|
|
left->parent = tree;
|
|
|
|
|
if (right != NULL)
|
|
|
|
|
right->parent = tree;
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
/* Mark the tree SRC as an optional subexpression.
|
|
|
|
|
To be called from preorder or postorder. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[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
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:40:05 +00:00
|
|
|
|
mark_opt_subexp (void *extra, bin_tree_t *node)
|
2003-11-21 23:42:18 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx = (uintptr_t) extra;
|
[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 (node->token.type == SUBEXP && node->token.opr.idx == idx)
|
|
|
|
|
node->token.opt_subexp = 1;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
|
[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
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
/* Free the allocated memory inside NODE. */
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
|
|
|
|
static void
|
[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
|
|
|
|
free_token (re_token_t *node)
|
2003-12-27 23:40:06 +00:00
|
|
|
|
{
|
[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
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
|
|
|
|
|
free_charset (node->opr.mbcset);
|
|
|
|
|
else
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
|
|
|
|
|
re_free (node->opr.sbcset);
|
2003-12-27 23:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
[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
|
|
|
|
/* Worker function for tree walking. Free the allocated memory inside NODE
|
|
|
|
|
and its children. */
|
2003-12-27 23:40:06 +00:00
|
|
|
|
|
[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
|
|
|
|
static reg_errcode_t
|
|
|
|
|
free_tree (void *extra, bin_tree_t *node)
|
2003-12-27 23:40:06 +00:00
|
|
|
|
{
|
[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
|
|
|
|
free_token (&node->token);
|
|
|
|
|
return REG_NOERROR;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
|
[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
|
|
|
|
/* Duplicate the node SRC, and return new node. This is a preorder
|
|
|
|
|
visit similar to the one implemented by the generic visitor, but
|
|
|
|
|
we need more infrastructure to maintain two parallel trees --- so,
|
|
|
|
|
it's easier to duplicate. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static bin_tree_t *
|
2005-10-13 20:40:05 +00:00
|
|
|
|
duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
[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
|
|
|
|
const bin_tree_t *node;
|
|
|
|
|
bin_tree_t *dup_root;
|
|
|
|
|
bin_tree_t **p_new = &dup_root, *dup_node = root->parent;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[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
|
|
|
|
for (node = root; ; )
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
[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
|
|
|
|
/* Create a new tree and link it back to the current parent. */
|
|
|
|
|
*p_new = create_token_tree (dfa, NULL, NULL, &node->token);
|
|
|
|
|
if (*p_new == NULL)
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
return NULL;
|
[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
|
|
|
|
(*p_new)->parent = dup_node;
|
|
|
|
|
(*p_new)->token.duplicated = 1;
|
|
|
|
|
dup_node = *p_new;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[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
|
|
|
|
/* Go to the left node, or up and to the right. */
|
|
|
|
|
if (node->left)
|
|
|
|
|
{
|
|
|
|
|
node = node->left;
|
|
|
|
|
p_new = &dup_node->left;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const bin_tree_t *prev = NULL;
|
|
|
|
|
while (node->right == prev || node->right == NULL)
|
|
|
|
|
{
|
|
|
|
|
prev = node;
|
|
|
|
|
node = node->parent;
|
|
|
|
|
dup_node = dup_node->parent;
|
|
|
|
|
if (!node)
|
2010-01-15 05:35:15 +00:00
|
|
|
|
return dup_root;
|
[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
|
|
|
|
}
|
|
|
|
|
node = node->right;
|
|
|
|
|
p_new = &dup_node->right;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|