2002-02-26 19:06:03 +00:00
|
|
|
|
/* Extended regular expression matching and search library.
|
2006-01-15 17:59:52 +00:00
|
|
|
|
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
|
02111-1307 USA. */
|
|
|
|
|
|
2002-09-05 10:28:51 +00:00
|
|
|
|
static void re_string_construct_common (const char *str, int len,
|
2002-11-06 19:57:50 +00:00
|
|
|
|
re_string_t *pstr,
|
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
|
|
|
|
RE_TRANSLATE_TYPE trans, int icase,
|
Update.
2003-12-22 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c: Remove C99-ism.
* posix/tst-rxspencer.c: Likewise.
Based on a patch by Alex Davis <alex14641@yahoo.com>.
2002-12-17 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h [!_LIBC] (internal_function): Define.
(re_string_allocate, re_string_construct, re_string_reconstruct,
re_string_realloc_buffers, build_wcs_buffer,
build_wcs_upper_buffer, build_upper_buffer,
re_string_translate_buffer, re_string_destruct,
re_string_elem_size_at, re_string_char_size_at,
re_string_wchar_at, re_string_context_at,
re_node_set_alloc, re_node_set_init_1
re_node_set_init_2, re_node_set_init_copy,
re_node_set_add_intersect, re_node_set_init_union,
re_node_set_merge, re_node_set_insert
re_node_set_compare, re_node_set_contains
re_node_set_remove_at, re_dfa_add_node,
re_acquire_state, re_acquire_state_context,
free_state): Add internal_function to declaration.
* posix/regexec.c (match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
* posix/regex_internal.c (re_string_construct_common,
re_string_skip_chars, create_newstate_common,
register_state, create_ci_newstate, create_cd_newstate,
calc_state_hash): Likewise.
(re_string_peek_byte_case, re_fetch_byte_case): Change
declaration from ANSI to K&R.
2002-12-16 Paolo Bonzini <bonzini@gnu.org>
* posix/regexec.c (build_trtable): Don't allocate the trtable
until state->word_trtable is known. Don't hardcode UINT_BITS
iterations on each bitset item.
2003-12-23 02:29:44 +00:00
|
|
|
|
const re_dfa_t *dfa) internal_function;
|
* 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 re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
|
2002-11-06 19:57:50 +00:00
|
|
|
|
const re_node_set *nodes,
|
Update.
2003-12-22 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c: Remove C99-ism.
* posix/tst-rxspencer.c: Likewise.
Based on a patch by Alex Davis <alex14641@yahoo.com>.
2002-12-17 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h [!_LIBC] (internal_function): Define.
(re_string_allocate, re_string_construct, re_string_reconstruct,
re_string_realloc_buffers, build_wcs_buffer,
build_wcs_upper_buffer, build_upper_buffer,
re_string_translate_buffer, re_string_destruct,
re_string_elem_size_at, re_string_char_size_at,
re_string_wchar_at, re_string_context_at,
re_node_set_alloc, re_node_set_init_1
re_node_set_init_2, re_node_set_init_copy,
re_node_set_add_intersect, re_node_set_init_union,
re_node_set_merge, re_node_set_insert
re_node_set_compare, re_node_set_contains
re_node_set_remove_at, re_dfa_add_node,
re_acquire_state, re_acquire_state_context,
free_state): Add internal_function to declaration.
* posix/regexec.c (match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
* posix/regex_internal.c (re_string_construct_common,
re_string_skip_chars, create_newstate_common,
register_state, create_ci_newstate, create_cd_newstate,
calc_state_hash): Likewise.
(re_string_peek_byte_case, re_fetch_byte_case): Change
declaration from ANSI to K&R.
2002-12-16 Paolo Bonzini <bonzini@gnu.org>
* posix/regexec.c (build_trtable): Don't allocate the trtable
until state->word_trtable is known. Don't hardcode UINT_BITS
iterations on each bitset item.
2003-12-23 02:29:44 +00:00
|
|
|
|
unsigned int hash) internal_function;
|
* 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 re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
|
2002-11-06 19:57:50 +00:00
|
|
|
|
const re_node_set *nodes,
|
|
|
|
|
unsigned int context,
|
Update.
2003-12-22 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c: Remove C99-ism.
* posix/tst-rxspencer.c: Likewise.
Based on a patch by Alex Davis <alex14641@yahoo.com>.
2002-12-17 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h [!_LIBC] (internal_function): Define.
(re_string_allocate, re_string_construct, re_string_reconstruct,
re_string_realloc_buffers, build_wcs_buffer,
build_wcs_upper_buffer, build_upper_buffer,
re_string_translate_buffer, re_string_destruct,
re_string_elem_size_at, re_string_char_size_at,
re_string_wchar_at, re_string_context_at,
re_node_set_alloc, re_node_set_init_1
re_node_set_init_2, re_node_set_init_copy,
re_node_set_add_intersect, re_node_set_init_union,
re_node_set_merge, re_node_set_insert
re_node_set_compare, re_node_set_contains
re_node_set_remove_at, re_dfa_add_node,
re_acquire_state, re_acquire_state_context,
free_state): Add internal_function to declaration.
* posix/regexec.c (match_ctx_init, match_ctx_clean,
match_ctx_free, match_ctx_free_subtops,
match_ctx_add_entry, search_cur_bkref_entry,
match_ctx_clear_flag, match_ctx_add_subtop,
match_ctx_add_sublast, sift_ctx_init,
re_search_internal, re_search_2_stub, re_search_stub,
re_copy_regs, acquire_init_state_context,
prune_impossible_nodes, check_matching,
check_halt_node_context, check_halt_state_context
update_regs, proceed_next_node, push_fail_stack,
pop_fail_stack, set_regs, free_fail_stack_return,
sift_states_iter_mb, sift_states_backward
update_cur_sifted_state, add_epsilon_src_nodes,
sub_epsilon_src_nodes, check_dst_limits,
check_dst_limits_calc_pos, check_subexp_limits,
sift_states_bkref, clean_state_log_if_need,
merge_state_array, transit_state,
check_subexp_matching_top, transit_state_sb,
transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, find_subexp_node,
check_arrival, check_arrival_add_next_nodes,
find_collation_sequence_value, check_arrival_expand_ecl,
check_arrival_expand_ecl_sub, expand_bkref_cache,
build_trtable, check_node_accept_bytes, extend_buffers,
group_nodes_into_DFAstates, check_node_accept): Likewise.
* posix/regex_internal.c (re_string_construct_common,
re_string_skip_chars, create_newstate_common,
register_state, create_ci_newstate, create_cd_newstate,
calc_state_hash): Likewise.
(re_string_peek_byte_case, re_fetch_byte_case): Change
declaration from ANSI to K&R.
2002-12-16 Paolo Bonzini <bonzini@gnu.org>
* posix/regexec.c (build_trtable): Don't allocate the trtable
until state->word_trtable is known. Don't hardcode UINT_BITS
iterations on each bitset item.
2003-12-23 02:29:44 +00:00
|
|
|
|
unsigned int hash) internal_function;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Functions for string operation. */
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* This function allocate the buffers. It is necessary to call
|
|
|
|
|
re_string_reconstruct before using the object. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
|
|
|
|
|
RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t ret;
|
2003-11-26 03:24:15 +00:00
|
|
|
|
int init_buf_len;
|
|
|
|
|
|
|
|
|
|
/* Ensure at least one character fits into the buffers. */
|
|
|
|
|
if (init_len < dfa->mb_cur_max)
|
|
|
|
|
init_len = dfa->mb_cur_max;
|
|
|
|
|
init_buf_len = (len + 1 < init_len) ? len + 1: init_len;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
re_string_construct_common (str, len, pstr, trans, icase, dfa);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
ret = re_string_realloc_buffers (pstr, init_buf_len);
|
|
|
|
|
if (BE (ret != REG_NOERROR, 0))
|
|
|
|
|
return ret;
|
|
|
|
|
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
pstr->word_char = dfa->word_char;
|
|
|
|
|
pstr->word_ops_used = dfa->word_ops_used;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
|
|
|
|
|
pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
|
|
|
|
|
pstr->valid_raw_len = pstr->valid_len;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function allocate the buffers, and initialize them. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_construct (re_string_t *pstr, const char *str, int len,
|
|
|
|
|
RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
reg_errcode_t ret;
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
memset (pstr, '\0', sizeof (re_string_t));
|
2003-11-16 07:14:28 +00:00
|
|
|
|
re_string_construct_common (str, len, pstr, trans, icase, dfa);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
if (len > 0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
ret = re_string_realloc_buffers (pstr, len + 1);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (ret != REG_NOERROR, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return ret;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
if (icase)
|
|
|
|
|
{
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2003-11-16 07:14:28 +00:00
|
|
|
|
if (dfa->mb_cur_max > 1)
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
ret = build_wcs_upper_buffer (pstr);
|
|
|
|
|
if (BE (ret != REG_NOERROR, 0))
|
|
|
|
|
return ret;
|
|
|
|
|
if (pstr->valid_raw_len >= len)
|
|
|
|
|
break;
|
|
|
|
|
if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
|
|
|
|
|
break;
|
|
|
|
|
ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
|
|
|
|
|
if (BE (ret != REG_NOERROR, 0))
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-11-06 19:57:50 +00:00
|
|
|
|
build_upper_buffer (pstr);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2003-11-16 07:14:28 +00:00
|
|
|
|
if (dfa->mb_cur_max > 1)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
build_wcs_buffer (pstr);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (trans != NULL)
|
|
|
|
|
re_string_translate_buffer (pstr);
|
|
|
|
|
else
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
|
|
|
|
pstr->valid_len = pstr->bufs_len;
|
|
|
|
|
pstr->valid_raw_len = pstr->bufs_len;
|
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Helper functions for re_string_allocate, and re_string_construct. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_realloc_buffers (re_string_t *pstr, int new_buf_len)
|
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 (pstr->mb_cur_max > 1)
|
2002-02-26 19:06:03 +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 *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
|
|
|
|
|
if (BE (new_wcs == NULL, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return REG_ESPACE;
|
* 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
|
|
|
|
pstr->wcs = new_wcs;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (pstr->offsets != NULL)
|
|
|
|
|
{
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len);
|
|
|
|
|
if (BE (new_offsets == NULL, 0))
|
2003-11-29 06:40:52 +00:00
|
|
|
|
return REG_ESPACE;
|
* 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
|
|
|
|
pstr->offsets = new_offsets;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (pstr->mbs_allocated)
|
2002-02-26 19:06:03 +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
|
|
|
|
unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
|
|
|
|
|
new_buf_len);
|
|
|
|
|
if (BE (new_mbs == NULL, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return REG_ESPACE;
|
* 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
|
|
|
|
pstr->mbs = new_mbs;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->bufs_len = new_buf_len;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static void
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_construct_common (const char *str, int len, re_string_t *pstr,
|
|
|
|
|
RE_TRANSLATE_TYPE trans, int icase,
|
|
|
|
|
const re_dfa_t *dfa)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-09-10 18:40:35 +00:00
|
|
|
|
pstr->raw_mbs = (const unsigned char *) str;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
pstr->len = len;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->raw_len = len;
|
2005-09-23 06:11:29 +00:00
|
|
|
|
pstr->trans = trans;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->icase = icase ? 1 : 0;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->mbs_allocated = (trans != NULL || icase);
|
2003-11-16 07:14:28 +00:00
|
|
|
|
pstr->mb_cur_max = dfa->mb_cur_max;
|
|
|
|
|
pstr->is_utf8 = dfa->is_utf8;
|
|
|
|
|
pstr->map_notascii = dfa->map_notascii;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->stop = pstr->len;
|
|
|
|
|
pstr->raw_stop = pstr->stop;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Build wide character buffer PSTR->WCS.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
If the byte sequence of the string are:
|
|
|
|
|
<mb1>(0), <mb1>(1), <mb2>(0), <mb2>(1), <sb3>
|
|
|
|
|
Then wide character buffer will be:
|
|
|
|
|
<wc1> , WEOF , <wc2> , WEOF , <wc3>
|
|
|
|
|
We use WEOF for padding, they indicate that the position isn't
|
2002-04-24 21:54:53 +00:00
|
|
|
|
a first byte of a multibyte character.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
Note that this function assumes PSTR->VALID_LEN elements are already
|
|
|
|
|
built and starts from PSTR->VALID_LEN. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
build_wcs_buffer (re_string_t *pstr)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
#ifdef _LIBC
|
2005-07-05 22:01:42 +00:00
|
|
|
|
unsigned char buf[MB_LEN_MAX];
|
|
|
|
|
assert (MB_LEN_MAX >= pstr->mb_cur_max);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
#else
|
|
|
|
|
unsigned char buf[64];
|
|
|
|
|
#endif
|
2002-04-24 21:54:53 +00:00
|
|
|
|
mbstate_t prev_st;
|
[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
|
|
|
|
int byte_idx, end_idx, remain_len;
|
|
|
|
|
size_t mbclen;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Build the buffers from pstr->valid_len to either pstr->len or
|
|
|
|
|
pstr->bufs_len. */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
for (byte_idx = pstr->valid_len; byte_idx < end_idx;)
|
|
|
|
|
{
|
|
|
|
|
wchar_t wc;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
const char *p;
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
remain_len = end_idx - byte_idx;
|
|
|
|
|
prev_st = pstr->cur_state;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
/* Apply the translation if we need. */
|
|
|
|
|
if (BE (pstr->trans != NULL, 0))
|
|
|
|
|
{
|
|
|
|
|
int i, ch;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
|
|
|
|
|
{
|
|
|
|
|
ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i];
|
2004-05-17 18:59:35 +00:00
|
|
|
|
buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch];
|
2003-11-29 06:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
p = (const char *) buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
|
2009-01-08 00:23:09 +00:00
|
|
|
|
mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
if (BE (mbclen == (size_t) -2, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
/* The buffer doesn't have enough space, finish to build. */
|
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
/* We treat these cases as a singlebyte character. */
|
|
|
|
|
mbclen = 1;
|
|
|
|
|
wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (BE (pstr->trans != NULL, 0))
|
|
|
|
|
wc = pstr->trans[wc];
|
2002-11-06 19:57:50 +00:00
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Write wide character and padding. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->wcs[byte_idx++] = wc;
|
|
|
|
|
/* Write paddings. */
|
|
|
|
|
for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
pstr->wcs[byte_idx++] = WEOF;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->valid_len = byte_idx;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->valid_raw_len = byte_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Build wide character buffer PSTR->WCS like build_wcs_buffer,
|
|
|
|
|
but for REG_ICASE. */
|
|
|
|
|
|
2006-01-15 17:59:52 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
build_wcs_upper_buffer (re_string_t *pstr)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
mbstate_t prev_st;
|
[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
|
|
|
|
int src_idx, byte_idx, end_idx, remain_len;
|
|
|
|
|
size_t mbclen;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
#ifdef _LIBC
|
2005-07-05 22:01:42 +00:00
|
|
|
|
char buf[MB_LEN_MAX];
|
|
|
|
|
assert (MB_LEN_MAX >= pstr->mb_cur_max);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
#else
|
2005-03-06 07:27:56 +00:00
|
|
|
|
char buf[64];
|
2003-11-29 06:40:52 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
byte_idx = pstr->valid_len;
|
|
|
|
|
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
/* The following optimization assumes that ASCII characters can be
|
|
|
|
|
mapped to wide characters with a simple cast. */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
|
|
|
|
|
{
|
|
|
|
|
while (byte_idx < end_idx)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2003-11-16 07:14:28 +00:00
|
|
|
|
wchar_t wc;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
|
|
|
|
|
if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
|
|
|
|
|
&& mbsinit (&pstr->cur_state))
|
|
|
|
|
{
|
|
|
|
|
/* In case of a singlebyte character. */
|
|
|
|
|
pstr->mbs[byte_idx]
|
|
|
|
|
= toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
|
|
|
|
|
/* The next step uses the assumption that wchar_t is encoded
|
2004-11-08 22:49:44 +00:00
|
|
|
|
ASCII-safe: all ASCII values can be converted like this. */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
|
|
|
|
|
++byte_idx;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 07:14:28 +00:00
|
|
|
|
remain_len = end_idx - byte_idx;
|
|
|
|
|
prev_st = pstr->cur_state;
|
2009-01-08 00:23:09 +00:00
|
|
|
|
mbclen = __mbrtowc (&wc,
|
|
|
|
|
((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
|
|
|
|
|
+ byte_idx), remain_len, &pstr->cur_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
|
|
|
|
if (BE (mbclen + 2 > 2, 1))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
wchar_t wcu = wc;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
if (iswlower (wc))
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
[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 mbcdlen;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
|
|
|
|
|
wcu = towupper (wc);
|
|
|
|
|
mbcdlen = wcrtomb (buf, wcu, &prev_st);
|
|
|
|
|
if (BE (mbclen == mbcdlen, 1))
|
|
|
|
|
memcpy (pstr->mbs + byte_idx, buf, mbclen);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
src_idx = byte_idx;
|
|
|
|
|
goto offsets_needed;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-16 07:14:28 +00:00
|
|
|
|
else
|
|
|
|
|
memcpy (pstr->mbs + byte_idx,
|
|
|
|
|
pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->wcs[byte_idx++] = wcu;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
/* Write paddings. */
|
|
|
|
|
for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
|
|
|
|
|
pstr->wcs[byte_idx++] = WEOF;
|
|
|
|
|
}
|
|
|
|
|
else if (mbclen == (size_t) -1 || mbclen == 0)
|
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
/* It is an invalid character or '\0'. Just use the byte. */
|
2003-11-16 07:14:28 +00:00
|
|
|
|
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
|
2003-11-19 09:09:27 +00:00
|
|
|
|
pstr->mbs[byte_idx] = ch;
|
|
|
|
|
/* And also cast it to wide char. */
|
|
|
|
|
pstr->wcs[byte_idx++] = (wchar_t) ch;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
if (BE (mbclen == (size_t) -1, 0))
|
|
|
|
|
pstr->cur_state = prev_st;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2003-11-16 07:14:28 +00:00
|
|
|
|
{
|
|
|
|
|
/* The buffer doesn't have enough space, finish to build. */
|
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->valid_len = byte_idx;
|
|
|
|
|
pstr->valid_raw_len = byte_idx;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
2003-11-16 07:14:28 +00:00
|
|
|
|
else
|
2003-11-29 06:40:52 +00:00
|
|
|
|
for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;)
|
2003-11-16 07:14:28 +00:00
|
|
|
|
{
|
|
|
|
|
wchar_t wc;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
const char *p;
|
2004-11-08 22:49:44 +00:00
|
|
|
|
offsets_needed:
|
2003-11-16 07:14:28 +00:00
|
|
|
|
remain_len = end_idx - byte_idx;
|
|
|
|
|
prev_st = pstr->cur_state;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (BE (pstr->trans != NULL, 0))
|
2003-11-16 07:14:28 +00:00
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
int i, ch;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
|
2003-11-16 07:14:28 +00:00
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i];
|
|
|
|
|
buf[i] = pstr->trans[ch];
|
2003-11-16 07:14:28 +00:00
|
|
|
|
}
|
2003-11-29 06:40:52 +00:00
|
|
|
|
p = (const char *) buf;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
}
|
2003-11-29 06:40:52 +00:00
|
|
|
|
else
|
|
|
|
|
p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
|
2009-01-08 00:23:09 +00:00
|
|
|
|
mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_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
|
|
|
|
if (BE (mbclen + 2 > 2, 1))
|
2003-11-16 07:14:28 +00:00
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
wchar_t wcu = wc;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
if (iswlower (wc))
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
[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 mbcdlen;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
|
|
|
|
|
wcu = towupper (wc);
|
2004-02-26 01:32:44 +00:00
|
|
|
|
mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (BE (mbclen == mbcdlen, 1))
|
|
|
|
|
memcpy (pstr->mbs + byte_idx, buf, mbclen);
|
[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
|
|
|
|
else if (mbcdlen != (size_t) -1)
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
[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 i;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
|
|
|
|
|
if (byte_idx + mbcdlen > pstr->bufs_len)
|
|
|
|
|
{
|
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pstr->offsets == NULL)
|
|
|
|
|
{
|
|
|
|
|
pstr->offsets = re_malloc (int, pstr->bufs_len);
|
|
|
|
|
|
|
|
|
|
if (pstr->offsets == NULL)
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
|
|
|
|
if (!pstr->offsets_needed)
|
|
|
|
|
{
|
[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
|
|
|
|
for (i = 0; i < (size_t) byte_idx; ++i)
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->offsets[i] = i;
|
|
|
|
|
pstr->offsets_needed = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy (pstr->mbs + byte_idx, buf, mbcdlen);
|
|
|
|
|
pstr->wcs[byte_idx] = wcu;
|
|
|
|
|
pstr->offsets[byte_idx] = src_idx;
|
|
|
|
|
for (i = 1; i < mbcdlen; ++i)
|
|
|
|
|
{
|
|
|
|
|
pstr->offsets[byte_idx + i]
|
|
|
|
|
= src_idx + (i < mbclen ? i : mbclen - 1);
|
|
|
|
|
pstr->wcs[byte_idx + i] = WEOF;
|
|
|
|
|
}
|
|
|
|
|
pstr->len += mbcdlen - mbclen;
|
|
|
|
|
if (pstr->raw_stop > src_idx)
|
|
|
|
|
pstr->stop += mbcdlen - mbclen;
|
|
|
|
|
end_idx = (pstr->bufs_len > pstr->len)
|
|
|
|
|
? pstr->len : pstr->bufs_len;
|
|
|
|
|
byte_idx += mbcdlen;
|
|
|
|
|
src_idx += mbclen;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
[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
|
|
|
|
else
|
|
|
|
|
memcpy (pstr->mbs + byte_idx, p, mbclen);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
}
|
2003-11-16 07:14:28 +00:00
|
|
|
|
else
|
2003-11-29 06:40:52 +00:00
|
|
|
|
memcpy (pstr->mbs + byte_idx, p, mbclen);
|
|
|
|
|
|
|
|
|
|
if (BE (pstr->offsets_needed != 0, 0))
|
|
|
|
|
{
|
[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 i;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
for (i = 0; i < mbclen; ++i)
|
|
|
|
|
pstr->offsets[byte_idx + i] = src_idx + i;
|
|
|
|
|
}
|
|
|
|
|
src_idx += mbclen;
|
|
|
|
|
|
|
|
|
|
pstr->wcs[byte_idx++] = wcu;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
/* Write paddings. */
|
|
|
|
|
for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
|
|
|
|
|
pstr->wcs[byte_idx++] = WEOF;
|
|
|
|
|
}
|
2003-11-19 09:09:27 +00:00
|
|
|
|
else if (mbclen == (size_t) -1 || mbclen == 0)
|
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
/* It is an invalid character or '\0'. Just use the byte. */
|
|
|
|
|
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
|
|
|
|
|
|
|
|
|
|
if (BE (pstr->trans != NULL, 0))
|
|
|
|
|
ch = pstr->trans [ch];
|
2003-11-19 09:09:27 +00:00
|
|
|
|
pstr->mbs[byte_idx] = ch;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
|
|
|
|
|
if (BE (pstr->offsets_needed != 0, 0))
|
|
|
|
|
pstr->offsets[byte_idx] = src_idx;
|
|
|
|
|
++src_idx;
|
|
|
|
|
|
2003-11-19 09:09:27 +00:00
|
|
|
|
/* And also cast it to wide char. */
|
|
|
|
|
pstr->wcs[byte_idx++] = (wchar_t) ch;
|
|
|
|
|
if (BE (mbclen == (size_t) -1, 0))
|
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
}
|
2003-11-16 07:14:28 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* The buffer doesn't have enough space, finish to build. */
|
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->valid_len = byte_idx;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->valid_raw_len = src_idx;
|
|
|
|
|
return REG_NOERROR;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skip characters until the index becomes greater than NEW_RAW_IDX.
|
|
|
|
|
Return the index. */
|
|
|
|
|
|
|
|
|
|
static int
|
2005-10-13 20:08:58 +00:00
|
|
|
|
internal_function
|
|
|
|
|
re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
mbstate_t prev_st;
|
[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
|
|
|
|
int rawbuf_idx;
|
|
|
|
|
size_t mbclen;
|
2006-06-04 04:59:36 +00:00
|
|
|
|
wchar_t wc = WEOF;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
/* Skip the characters which are not necessary to check. */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
rawbuf_idx < new_raw_idx;)
|
|
|
|
|
{
|
2002-11-13 04:00:16 +00:00
|
|
|
|
int remain_len;
|
|
|
|
|
remain_len = pstr->len - rawbuf_idx;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
prev_st = pstr->cur_state;
|
2009-01-08 00:23:09 +00:00
|
|
|
|
mbclen = __mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx,
|
|
|
|
|
remain_len, &pstr->cur_state);
|
2002-04-24 21:54:53 +00:00
|
|
|
|
if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2006-06-04 04:59:36 +00:00
|
|
|
|
/* We treat these cases as a single byte character. */
|
|
|
|
|
if (mbclen == 0 || remain_len == 0)
|
|
|
|
|
wc = L'\0';
|
|
|
|
|
else
|
|
|
|
|
wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
mbclen = 1;
|
|
|
|
|
pstr->cur_state = prev_st;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Then proceed the next character. */
|
|
|
|
|
rawbuf_idx += mbclen;
|
|
|
|
|
}
|
2002-11-13 04:00:16 +00:00
|
|
|
|
*last_wc = (wint_t) wc;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
return rawbuf_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
2002-11-06 19:57:50 +00:00
|
|
|
|
/* Build the buffer PSTR->MBS, and apply the translation if we need.
|
2002-04-24 21:54:53 +00:00
|
|
|
|
This function is used in case of REG_ICASE. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
build_upper_buffer (re_string_t *pstr)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
int char_idx, end_idx;
|
|
|
|
|
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (BE (pstr->trans != NULL, 0))
|
|
|
|
|
ch = pstr->trans[ch];
|
2002-04-24 21:54:53 +00:00
|
|
|
|
if (islower (ch))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
pstr->mbs[char_idx] = toupper (ch);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
pstr->mbs[char_idx] = ch;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->valid_len = char_idx;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->valid_raw_len = char_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Apply TRANS to the buffer in PSTR. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
static void
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_translate_buffer (re_string_t *pstr)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
int buf_idx, end_idx;
|
|
|
|
|
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
|
|
|
|
|
|
|
|
|
|
for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx];
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->mbs[buf_idx] = pstr->trans[ch];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
pstr->valid_len = buf_idx;
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->valid_raw_len = buf_idx;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function re-construct the buffers.
|
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
|
|
|
|
Concretely, convert to wide character in case of pstr->mb_cur_max > 1,
|
2002-04-24 21:54:53 +00:00
|
|
|
|
convert to upper case in case of REG_ICASE, apply translation. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
int offset = idx - pstr->raw_mbs_idx;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (BE (offset < 0, 0))
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
|
|
|
|
/* Reset buffer. */
|
2002-04-26 20:52:02 +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 (pstr->mb_cur_max > 1)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->len = pstr->raw_len;
|
|
|
|
|
pstr->stop = pstr->raw_stop;
|
|
|
|
|
pstr->valid_len = 0;
|
|
|
|
|
pstr->raw_mbs_idx = 0;
|
|
|
|
|
pstr->valid_raw_len = 0;
|
|
|
|
|
pstr->offsets_needed = 0;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
|
2002-11-06 19:57:50 +00:00
|
|
|
|
: CONTEXT_NEWLINE | CONTEXT_BEGBUF);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (!pstr->mbs_allocated)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
pstr->mbs = (unsigned char *) pstr->raw_mbs;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
offset = idx;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (BE (offset != 0, 1))
|
2002-04-24 21:54:53 +00:00
|
|
|
|
{
|
2006-09-07 13:50:31 +00:00
|
|
|
|
/* Should the already checked characters be kept? */
|
|
|
|
|
if (BE (offset < pstr->valid_raw_len, 1))
|
2004-12-22 20:10:10 +00:00
|
|
|
|
{
|
|
|
|
|
/* Yes, move them to the front of the buffer. */
|
2007-07-12 18:26:36 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2006-09-07 13:50:31 +00:00
|
|
|
|
if (BE (pstr->offsets_needed, 0))
|
|
|
|
|
{
|
|
|
|
|
int low = 0, high = pstr->valid_len, mid;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
mid = (high + low) / 2;
|
|
|
|
|
if (pstr->offsets[mid] > offset)
|
|
|
|
|
high = mid;
|
|
|
|
|
else if (pstr->offsets[mid] < offset)
|
|
|
|
|
low = mid + 1;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
while (low < high);
|
|
|
|
|
if (pstr->offsets[mid] < offset)
|
|
|
|
|
++mid;
|
|
|
|
|
pstr->tip_context = re_string_context_at (pstr, mid - 1,
|
|
|
|
|
eflags);
|
|
|
|
|
/* This can be quite complicated, so handle specially
|
|
|
|
|
only the common and easy case where the character with
|
|
|
|
|
different length representation of lower and upper
|
|
|
|
|
case is present at or after offset. */
|
|
|
|
|
if (pstr->valid_len > offset
|
|
|
|
|
&& mid == offset && pstr->offsets[mid] == offset)
|
|
|
|
|
{
|
|
|
|
|
memmove (pstr->wcs, pstr->wcs + offset,
|
|
|
|
|
(pstr->valid_len - offset) * sizeof (wint_t));
|
|
|
|
|
memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset);
|
|
|
|
|
pstr->valid_len -= offset;
|
|
|
|
|
pstr->valid_raw_len -= offset;
|
|
|
|
|
for (low = 0; low < pstr->valid_len; low++)
|
|
|
|
|
pstr->offsets[low] = pstr->offsets[low + offset] - offset;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Otherwise, just find out how long the partial multibyte
|
|
|
|
|
character at offset is and fill it with WEOF/255. */
|
|
|
|
|
pstr->len = pstr->raw_len - idx + offset;
|
|
|
|
|
pstr->stop = pstr->raw_stop - idx + offset;
|
|
|
|
|
pstr->offsets_needed = 0;
|
|
|
|
|
while (mid > 0 && pstr->offsets[mid - 1] == offset)
|
|
|
|
|
--mid;
|
|
|
|
|
while (mid < pstr->valid_len)
|
|
|
|
|
if (pstr->wcs[mid] != WEOF)
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
++mid;
|
|
|
|
|
if (mid == pstr->valid_len)
|
|
|
|
|
pstr->valid_len = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pstr->valid_len = pstr->offsets[mid] - offset;
|
|
|
|
|
if (pstr->valid_len)
|
|
|
|
|
{
|
|
|
|
|
for (low = 0; low < pstr->valid_len; ++low)
|
|
|
|
|
pstr->wcs[low] = WEOF;
|
|
|
|
|
memset (pstr->mbs, 255, pstr->valid_len);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pstr->valid_raw_len = pstr->valid_len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
pstr->tip_context = re_string_context_at (pstr, offset - 1,
|
|
|
|
|
eflags);
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (pstr->mb_cur_max > 1)
|
|
|
|
|
memmove (pstr->wcs, pstr->wcs + offset,
|
|
|
|
|
(pstr->valid_len - offset) * sizeof (wint_t));
|
2002-04-24 21:54:53 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2006-09-07 13:50:31 +00:00
|
|
|
|
if (BE (pstr->mbs_allocated, 0))
|
|
|
|
|
memmove (pstr->mbs, pstr->mbs + offset,
|
|
|
|
|
pstr->valid_len - offset);
|
|
|
|
|
pstr->valid_len -= offset;
|
|
|
|
|
pstr->valid_raw_len -= offset;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
#if DEBUG
|
2006-09-07 13:50:31 +00:00
|
|
|
|
assert (pstr->valid_len > 0);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif
|
2006-09-07 13:50:31 +00:00
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
/* No, skip all characters until IDX. */
|
2006-09-07 13:50:31 +00:00
|
|
|
|
int prev_valid_len = pstr->valid_len;
|
|
|
|
|
|
2003-11-29 06:40:52 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (BE (pstr->offsets_needed, 0))
|
|
|
|
|
{
|
|
|
|
|
pstr->len = pstr->raw_len - idx + offset;
|
|
|
|
|
pstr->stop = pstr->raw_stop - idx + offset;
|
|
|
|
|
pstr->offsets_needed = 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2002-11-06 19:57:50 +00:00
|
|
|
|
pstr->valid_len = 0;
|
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 (pstr->mb_cur_max > 1)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
int wcs_idx;
|
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
|
|
|
|
wint_t wc = WEOF;
|
|
|
|
|
|
|
|
|
|
if (pstr->is_utf8)
|
|
|
|
|
{
|
2003-11-29 06:40:52 +00:00
|
|
|
|
const unsigned char *raw, *p, *q, *end;
|
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
|
|
|
|
|
|
|
|
|
/* Special case UTF-8. Multi-byte chars start with any
|
|
|
|
|
byte other than 0x80 - 0xbf. */
|
|
|
|
|
raw = pstr->raw_mbs + pstr->raw_mbs_idx;
|
2003-11-26 03:24:15 +00:00
|
|
|
|
end = raw + (offset - pstr->mb_cur_max);
|
2006-09-07 13:50:31 +00:00
|
|
|
|
if (end < pstr->raw_mbs)
|
|
|
|
|
end = pstr->raw_mbs;
|
* 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
|
|
|
|
p = raw + offset - 1;
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
/* We know the wchar_t encoding is UCS4, so for the simple
|
|
|
|
|
case, ASCII characters, skip the conversion step. */
|
|
|
|
|
if (isascii (*p) && BE (pstr->trans == NULL, 1))
|
|
|
|
|
{
|
|
|
|
|
memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
|
2006-09-07 13:50:31 +00:00
|
|
|
|
/* pstr->valid_len = 0; */
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
wc = (wchar_t) *p;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
for (; p >= end; --p)
|
|
|
|
|
if ((*p & 0xc0) != 0x80)
|
|
|
|
|
{
|
|
|
|
|
mbstate_t cur_state;
|
|
|
|
|
wchar_t wc2;
|
|
|
|
|
int mlen = raw + pstr->len - p;
|
|
|
|
|
unsigned char buf[6];
|
|
|
|
|
size_t mbclen;
|
|
|
|
|
|
|
|
|
|
q = p;
|
|
|
|
|
if (BE (pstr->trans != NULL, 0))
|
|
|
|
|
{
|
|
|
|
|
int i = mlen < 6 ? mlen : 6;
|
|
|
|
|
while (--i >= 0)
|
|
|
|
|
buf[i] = pstr->trans[p[i]];
|
|
|
|
|
q = buf;
|
|
|
|
|
}
|
|
|
|
|
/* XXX Don't use mbrtowc, we know which conversion
|
|
|
|
|
to use (UTF-8 -> UCS4). */
|
|
|
|
|
memset (&cur_state, 0, sizeof (cur_state));
|
2009-01-08 00:23:09 +00:00
|
|
|
|
mbclen = __mbrtowc (&wc2, (const char *) p, mlen,
|
|
|
|
|
&cur_state);
|
* 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 (raw + offset - p <= mbclen
|
|
|
|
|
&& mbclen < (size_t) -2)
|
|
|
|
|
{
|
|
|
|
|
memset (&pstr->cur_state, '\0',
|
|
|
|
|
sizeof (mbstate_t));
|
|
|
|
|
pstr->valid_len = mbclen - (raw + offset - p);
|
|
|
|
|
wc = wc2;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
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
|
|
|
|
}
|
2004-11-08 22:49:44 +00:00
|
|
|
|
|
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 (wc == WEOF)
|
2003-11-26 03:24:15 +00:00
|
|
|
|
pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
|
2006-06-04 04:59:36 +00:00
|
|
|
|
if (wc == WEOF)
|
|
|
|
|
pstr->tip_context
|
2006-09-07 13:50:31 +00:00
|
|
|
|
= re_string_context_at (pstr, prev_valid_len - 1, eflags);
|
2006-06-04 04:59:36 +00:00
|
|
|
|
else
|
|
|
|
|
pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
|
|
|
|
|
&& IS_WIDE_WORD_CHAR (wc))
|
|
|
|
|
? CONTEXT_WORD
|
|
|
|
|
: ((IS_WIDE_NEWLINE (wc)
|
|
|
|
|
&& pstr->newline_anchor)
|
|
|
|
|
? CONTEXT_NEWLINE : 0));
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (BE (pstr->valid_len, 0))
|
|
|
|
|
{
|
|
|
|
|
for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
|
|
|
|
|
pstr->wcs[wcs_idx] = WEOF;
|
|
|
|
|
if (pstr->mbs_allocated)
|
|
|
|
|
memset (pstr->mbs, 255, pstr->valid_len);
|
|
|
|
|
}
|
|
|
|
|
pstr->valid_raw_len = pstr->valid_len;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2002-11-13 04:00:16 +00:00
|
|
|
|
else
|
2002-04-24 21:54:53 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-11-13 04:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
|
2006-06-04 04:59:36 +00:00
|
|
|
|
pstr->valid_raw_len = 0;
|
2002-11-13 04:00:16 +00:00
|
|
|
|
if (pstr->trans)
|
|
|
|
|
c = pstr->trans[c];
|
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
|
|
|
|
pstr->tip_context = (bitset_contain (pstr->word_char, c)
|
|
|
|
|
? CONTEXT_WORD
|
|
|
|
|
: ((IS_NEWLINE (c) && pstr->newline_anchor)
|
2002-11-13 04:00:16 +00:00
|
|
|
|
? CONTEXT_NEWLINE : 0));
|
|
|
|
|
}
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (!BE (pstr->mbs_allocated, 0))
|
2003-11-29 06:40:52 +00:00
|
|
|
|
pstr->mbs += offset;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
pstr->raw_mbs_idx = idx;
|
|
|
|
|
pstr->len -= offset;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
pstr->stop -= offset;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
|
|
|
|
/* Then build the buffers. */
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
2003-11-12 17:47:46 +00:00
|
|
|
|
if (pstr->mb_cur_max > 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
if (pstr->icase)
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
2006-01-15 17:59:52 +00:00
|
|
|
|
reg_errcode_t ret = build_wcs_upper_buffer (pstr);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (BE (ret != REG_NOERROR, 0))
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2002-04-24 21:54:53 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
build_wcs_buffer (pstr);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2002-04-24 21:54:53 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
* 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 (BE (pstr->mbs_allocated, 0))
|
|
|
|
|
{
|
|
|
|
|
if (pstr->icase)
|
|
|
|
|
build_upper_buffer (pstr);
|
|
|
|
|
else if (pstr->trans != NULL)
|
|
|
|
|
re_string_translate_buffer (pstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pstr->valid_len = pstr->len;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2004-11-10 15:48:06 +00:00
|
|
|
|
pstr->cur_idx = 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-29 06:40:52 +00:00
|
|
|
|
static unsigned char
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function __attribute ((pure))
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_peek_byte_case (const re_string_t *pstr, int idx)
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
|
|
|
|
int ch, off;
|
|
|
|
|
|
|
|
|
|
/* Handle the common (easiest) cases first. */
|
2004-01-06 22:12:27 +00:00
|
|
|
|
if (BE (!pstr->mbs_allocated, 1))
|
2003-11-29 06:40:52 +00:00
|
|
|
|
return re_string_peek_byte (pstr, idx);
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (pstr->mb_cur_max > 1
|
|
|
|
|
&& ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
|
|
|
|
|
return re_string_peek_byte (pstr, idx);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
off = pstr->cur_idx + idx;
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (pstr->offsets_needed)
|
|
|
|
|
off = pstr->offsets[off];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
|
|
|
|
|
this function returns CAPITAL LETTER I instead of first byte of
|
|
|
|
|
DOTLESS SMALL LETTER I. The latter would confuse the parser,
|
|
|
|
|
since peek_byte_case doesn't advance cur_idx in any way. */
|
|
|
|
|
if (pstr->offsets_needed && !isascii (ch))
|
|
|
|
|
return re_string_peek_byte (pstr, idx);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned char
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function __attribute ((pure))
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_fetch_byte_case (re_string_t *pstr)
|
2003-11-29 06:40:52 +00:00
|
|
|
|
{
|
2004-01-06 22:12:27 +00:00
|
|
|
|
if (BE (!pstr->mbs_allocated, 1))
|
2003-11-29 06:40:52 +00:00
|
|
|
|
return re_string_fetch_byte (pstr);
|
|
|
|
|
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
if (pstr->offsets_needed)
|
|
|
|
|
{
|
2004-01-06 22:12:27 +00:00
|
|
|
|
int off, ch;
|
2003-12-16 06:16:27 +00:00
|
|
|
|
|
2003-11-29 06:40:52 +00:00
|
|
|
|
/* For tr_TR.UTF-8 [[:islower:]] there is
|
|
|
|
|
[[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip
|
|
|
|
|
in that case the whole multi-byte character and return
|
|
|
|
|
the original letter. On the other side, with
|
|
|
|
|
[[: DOTLESS SMALL LETTER I return [[:I, as doing
|
|
|
|
|
anything else would complicate things too much. */
|
|
|
|
|
|
|
|
|
|
if (!re_string_first_byte (pstr, pstr->cur_idx))
|
|
|
|
|
return re_string_fetch_byte (pstr);
|
|
|
|
|
|
|
|
|
|
off = pstr->offsets[pstr->cur_idx];
|
|
|
|
|
ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
|
|
|
|
|
|
|
|
|
|
if (! isascii (ch))
|
|
|
|
|
return re_string_fetch_byte (pstr);
|
|
|
|
|
|
|
|
|
|
re_string_skip_bytes (pstr,
|
|
|
|
|
re_string_char_size_at (pstr, pstr->cur_idx));
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-01-06 22:12:27 +00:00
|
|
|
|
return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
|
2003-11-29 06:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static void
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_destruct (re_string_t *pstr)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
re_free (pstr->wcs);
|
2003-11-29 06:40:52 +00:00
|
|
|
|
re_free (pstr->offsets);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2003-11-29 06:40:52 +00:00
|
|
|
|
if (pstr->mbs_allocated)
|
2002-04-24 21:54:53 +00:00
|
|
|
|
re_free (pstr->mbs);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the context at IDX in INPUT. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static unsigned int
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_string_context_at (const re_string_t *input, int idx, int eflags)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int c;
|
2004-11-10 15:48:06 +00:00
|
|
|
|
if (BE (idx < 0, 0))
|
|
|
|
|
/* In this case, we use the value stored in input->tip_context,
|
|
|
|
|
since we can't know the character in input->mbs[-1] here. */
|
|
|
|
|
return input->tip_context;
|
|
|
|
|
if (BE (idx == input->len, 0))
|
|
|
|
|
return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
|
|
|
|
|
: CONTEXT_NEWLINE | CONTEXT_ENDBUF);
|
2002-12-13 23:45:19 +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 (input->mb_cur_max > 1)
|
2002-11-13 04:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
wint_t wc;
|
|
|
|
|
int wc_idx = idx;
|
|
|
|
|
while(input->wcs[wc_idx] == WEOF)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
/* It must not happen. */
|
|
|
|
|
assert (wc_idx >= 0);
|
|
|
|
|
#endif
|
|
|
|
|
--wc_idx;
|
|
|
|
|
if (wc_idx < 0)
|
|
|
|
|
return input->tip_context;
|
|
|
|
|
}
|
|
|
|
|
wc = input->wcs[wc_idx];
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
|
2002-11-13 04:00:16 +00:00
|
|
|
|
return CONTEXT_WORD;
|
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
|
|
|
|
return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
|
|
|
|
|
? CONTEXT_NEWLINE : 0);
|
2002-11-13 04:00:16 +00:00
|
|
|
|
}
|
2002-12-13 23:45:19 +00:00
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
c = re_string_byte_at (input, idx);
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
if (bitset_contain (input->word_char, c))
|
2002-12-13 23:45:19 +00:00
|
|
|
|
return CONTEXT_WORD;
|
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
|
|
|
|
return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
|
2002-12-13 23:45:19 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Functions for set operation. */
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_alloc (re_node_set *set, int size)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
set->alloc = size;
|
|
|
|
|
set->nelem = 0;
|
|
|
|
|
set->elems = re_malloc (int, size);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (set->elems == NULL, 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_init_1 (re_node_set *set, int elem)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
set->alloc = 1;
|
|
|
|
|
set->nelem = 1;
|
|
|
|
|
set->elems = re_malloc (int, 1);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (set->elems == NULL, 0))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
set->alloc = set->nelem = 0;
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
set->elems[0] = elem;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_init_2 (re_node_set *set, int elem1, int elem2)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
set->alloc = 2;
|
|
|
|
|
set->elems = re_malloc (int, 2);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (set->elems == NULL, 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
if (elem1 == elem2)
|
|
|
|
|
{
|
|
|
|
|
set->nelem = 1;
|
|
|
|
|
set->elems[0] = elem1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
set->nelem = 2;
|
|
|
|
|
if (elem1 < elem2)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
set->elems[0] = elem1;
|
|
|
|
|
set->elems[1] = elem2;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
set->elems[0] = elem2;
|
|
|
|
|
set->elems[1] = elem1;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
dest->nelem = src->nelem;
|
|
|
|
|
if (src->nelem > 0)
|
|
|
|
|
{
|
|
|
|
|
dest->alloc = dest->nelem;
|
|
|
|
|
dest->elems = re_malloc (int, dest->alloc);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (dest->elems == NULL, 0))
|
2002-11-27 23:00:16 +00:00
|
|
|
|
{
|
|
|
|
|
dest->alloc = dest->nelem = 0;
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
memcpy (dest->elems, src->elems, src->nelem * sizeof (int));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
re_node_set_init_empty (dest);
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to
|
|
|
|
|
DEST. Return value indicate the error code or REG_NOERROR if succeeded.
|
|
|
|
|
Note: We assume dest->elems is NULL, when dest->alloc is 0. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
|
|
|
|
|
const re_node_set *src2)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
int i1, i2, is, id, delta, sbase;
|
|
|
|
|
if (src1->nelem == 0 || src2->nelem == 0)
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
|
|
|
|
|
/* We need dest->nelem + 2 * elems_in_intersection; this is a
|
|
|
|
|
conservative estimate. */
|
|
|
|
|
if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
int new_alloc = src1->nelem + src2->nelem + dest->alloc;
|
|
|
|
|
int *new_elems = re_realloc (dest->elems, int, new_alloc);
|
|
|
|
|
if (BE (new_elems == NULL, 0))
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
dest->elems = new_elems;
|
|
|
|
|
dest->alloc = new_alloc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
/* Find the items in the intersection of SRC1 and SRC2, and copy
|
|
|
|
|
into the top of DEST those that are not already in DEST itself. */
|
|
|
|
|
sbase = dest->nelem + src1->nelem + src2->nelem;
|
|
|
|
|
i1 = src1->nelem - 1;
|
|
|
|
|
i2 = src2->nelem - 1;
|
|
|
|
|
id = dest->nelem - 1;
|
|
|
|
|
for (;;)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
if (src1->elems[i1] == src2->elems[i2])
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
/* Try to find the item in DEST. Maybe we could binary search? */
|
|
|
|
|
while (id >= 0 && dest->elems[id] > src1->elems[i1])
|
|
|
|
|
--id;
|
|
|
|
|
|
|
|
|
|
if (id < 0 || dest->elems[id] != src1->elems[i1])
|
|
|
|
|
dest->elems[--sbase] = src1->elems[i1];
|
|
|
|
|
|
|
|
|
|
if (--i1 < 0 || --i2 < 0)
|
|
|
|
|
break;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
|
|
|
|
|
/* Lower the highest of the two items. */
|
|
|
|
|
else if (src1->elems[i1] < src2->elems[i2])
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
if (--i2 < 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (--i1 < 0)
|
|
|
|
|
break;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
|
|
|
|
|
id = dest->nelem - 1;
|
|
|
|
|
is = dest->nelem + src1->nelem + src2->nelem - 1;
|
|
|
|
|
delta = is - sbase + 1;
|
|
|
|
|
|
|
|
|
|
/* Now copy. When DELTA becomes zero, the remaining
|
|
|
|
|
DEST elements are already in place; this is more or
|
|
|
|
|
less the same loop that is in re_node_set_merge. */
|
|
|
|
|
dest->nelem += delta;
|
|
|
|
|
if (delta > 0 && id >= 0)
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (dest->elems[is] > dest->elems[id])
|
|
|
|
|
{
|
|
|
|
|
/* Copy from the top. */
|
|
|
|
|
dest->elems[id + delta--] = dest->elems[is--];
|
|
|
|
|
if (delta == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Slide from the bottom. */
|
|
|
|
|
dest->elems[id + delta] = dest->elems[id];
|
|
|
|
|
if (--id < 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy remaining SRC elements. */
|
|
|
|
|
memcpy (dest->elems, dest->elems + sbase, delta * sizeof (int));
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Calculate the union set of the sets SRC1 and SRC2. And store it to
|
|
|
|
|
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
|
|
|
|
|
const re_node_set *src2)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int i1, i2, id;
|
|
|
|
|
if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
|
|
|
|
|
{
|
|
|
|
|
dest->alloc = src1->nelem + src2->nelem;
|
|
|
|
|
dest->elems = re_malloc (int, dest->alloc);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (dest->elems == NULL, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return REG_ESPACE;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (src1 != NULL && src1->nelem > 0)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return re_node_set_init_copy (dest, src1);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (src2 != NULL && src2->nelem > 0)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return re_node_set_init_copy (dest, src2);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
re_node_set_init_empty (dest);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
|
|
|
|
|
{
|
|
|
|
|
if (src1->elems[i1] > src2->elems[i2])
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
dest->elems[id++] = src2->elems[i2++];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (src1->elems[i1] == src2->elems[i2])
|
2002-11-06 19:57:50 +00:00
|
|
|
|
++i2;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dest->elems[id++] = src1->elems[i1++];
|
|
|
|
|
}
|
|
|
|
|
if (i1 < src1->nelem)
|
|
|
|
|
{
|
|
|
|
|
memcpy (dest->elems + id, src1->elems + i1,
|
2002-11-06 19:57:50 +00:00
|
|
|
|
(src1->nelem - i1) * sizeof (int));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
id += src1->nelem - i1;
|
|
|
|
|
}
|
|
|
|
|
else if (i2 < src2->nelem)
|
|
|
|
|
{
|
|
|
|
|
memcpy (dest->elems + id, src2->elems + i2,
|
2002-11-06 19:57:50 +00:00
|
|
|
|
(src2->nelem - i2) * sizeof (int));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
id += src2->nelem - i2;
|
|
|
|
|
}
|
|
|
|
|
dest->nelem = id;
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Calculate the union set of the sets DEST and SRC. And store it to
|
|
|
|
|
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static reg_errcode_t
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_merge (re_node_set *dest, const re_node_set *src)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
int is, id, sbase, delta;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (src == NULL || src->nelem == 0)
|
|
|
|
|
return REG_NOERROR;
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
if (dest->alloc < 2 * src->nelem + dest->nelem)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2003-11-23 19:21:23 +00:00
|
|
|
|
int new_alloc = 2 * (src->nelem + dest->alloc);
|
|
|
|
|
int *new_buffer = re_realloc (dest->elems, int, new_alloc);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
if (BE (new_buffer == NULL, 0))
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
dest->elems = new_buffer;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
dest->alloc = new_alloc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
if (BE (dest->nelem == 0, 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
dest->nelem = src->nelem;
|
|
|
|
|
memcpy (dest->elems, src->elems, src->nelem * sizeof (int));
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
/* Copy into the top of DEST the items of SRC that are not
|
|
|
|
|
found in DEST. Maybe we could binary search in DEST? */
|
|
|
|
|
for (sbase = dest->nelem + 2 * src->nelem,
|
|
|
|
|
is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
|
|
|
|
|
{
|
|
|
|
|
if (dest->elems[id] == src->elems[is])
|
|
|
|
|
is--, id--;
|
|
|
|
|
else if (dest->elems[id] < src->elems[is])
|
|
|
|
|
dest->elems[--sbase] = src->elems[is--];
|
|
|
|
|
else /* if (dest->elems[id] > src->elems[is]) */
|
|
|
|
|
--id;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
if (is >= 0)
|
|
|
|
|
{
|
|
|
|
|
/* If DEST is exhausted, the remaining items of SRC must be unique. */
|
|
|
|
|
sbase -= is + 1;
|
|
|
|
|
memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (int));
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
id = dest->nelem - 1;
|
|
|
|
|
is = dest->nelem + 2 * src->nelem - 1;
|
|
|
|
|
delta = is - sbase + 1;
|
|
|
|
|
if (delta == 0)
|
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
|
|
|
|
|
/* Now copy. When DELTA becomes zero, the remaining
|
|
|
|
|
DEST elements are already in place. */
|
|
|
|
|
dest->nelem += delta;
|
|
|
|
|
for (;;)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
if (dest->elems[is] > dest->elems[id])
|
|
|
|
|
{
|
|
|
|
|
/* Copy from the top. */
|
|
|
|
|
dest->elems[id + delta--] = dest->elems[is--];
|
|
|
|
|
if (delta == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Slide from the bottom. */
|
|
|
|
|
dest->elems[id + delta] = dest->elems[id];
|
|
|
|
|
if (--id < 0)
|
|
|
|
|
{
|
|
|
|
|
/* Copy remaining SRC elements. */
|
|
|
|
|
memcpy (dest->elems, dest->elems + sbase,
|
|
|
|
|
delta * sizeof (int));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return REG_NOERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Insert the new element ELEM to the re_node_set* SET.
|
2004-01-02 11:08:23 +00:00
|
|
|
|
SET should not already have ELEM.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return -1 if an error is occured, return 1 otherwise. */
|
|
|
|
|
|
|
|
|
|
static int
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_insert (re_node_set *set, int elem)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
Update.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.c (re_node_set_insert): Remove unused variables.
* posix/regex_internal.h (re_dfa_t): Add syntax field.
* posix/regcomp.c (parse): Initialize dfa->syntax.
* posix/regexec.c (acquire_init_state_context,
prune_impossible_nodes, check_matching, check_halt_state_context,
proceed_next_node, sift_states_iter_mb, sift_states_backward,
update_cur_sifted_state, sift_states_bkref, transit_state,
transit_state_sb, transit_state_mb, transit_state_bkref,
get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache,
build_trtable): Remove preg argument, add dfa argument instead
and remove dfa = preg->buffer initialization in the body.
Adjust all callers.
(check_node_accept_bytes, group_nodes_into_DFAstates,
check_node_accept): Likewise. Use dfa->syntax instead of
preg->syntax.
(check_arrival_add_next_nodes): Remove preg argument.
* posix/regex_internal.h (re_match_context_t): Make input
re_string_t instead of a pointer to it.
* posix/regex_internal.c (re_string_construct_common): Don't clear
pstr here...
(re_string_construct): ... but only here.
* posix/regexec.c (match_ctx_init): Remove input argument. Don't
initialize fields to zero.
(re_search_internal): Move input into mctx.input.
(acquire_init_state_context, check_matching,
check_halt_state_context, proceed_next_node,
clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
transit_state, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, check_arrival,
check_arrival_add_next_nodes, check_node_accept, extend_buffers):
Change mctx->input into &mctx->input and mctx->input->field into
mctx->input.field.
2004-01-02 Jakub Jelinek <jakub@redhat.com>
Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.h (re_const_bitset_ptr_t): New type.
(re_string_t): Add newline_anchor, word_char and word_ops_used fields.
(re_dfa_t): Change word_char type to bitset. Add word_ops_used field.
(re_string_context_at, re_string_reconstruct): Remove last argument.
* posix/regex_internal.c (re_string_allocate): Initialize
pstr->word_char and pstr->word_ops_used.
(re_string_context_at): Remove newline_anchor argument.
Use input->newline_anchor instead, swap && conditions.
Only use IS_WIDE_WORD_CHAR if input->word_ops_used != 0.
Use input->word_char bitmap instead of IS_WORD_CHAR.
(re_string_reconstruct): Likewise.
Adjust re_string_context_at caller.
* posix/regexec.c (acquire_init_state_context,
check_halt_state_context, transit_state, transit_state_sb,
transit_state_mb, transit_state_bkref, check_arrival,
check_node_accept): Adjust re_string_context_at and
re_string_reconstruct callers.
(re_search_internal): Likewise. Set input.newline_anchor.
(build_trtable): Use dfa->word_char bitmap instead of IS_WORD_CHAR.
* posix/regcomp.c (init_word_char): Change return type to void.
Set dfa->word_ops_used.
(free_dfa_content): Don't free dfa->word_char.
(parse_expression): Remove error handling for init_word_char.
2004-01-02 21:20:51 +00:00
|
|
|
|
int idx;
|
2004-01-02 11:08:23 +00:00
|
|
|
|
/* In case the set is empty. */
|
|
|
|
|
if (set->alloc == 0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return -1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-02 11:08:23 +00:00
|
|
|
|
if (BE (set->nelem, 0) == 0)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-01-02 11:08:23 +00:00
|
|
|
|
/* We already guaranteed above that set->alloc != 0. */
|
|
|
|
|
set->elems[0] = elem;
|
|
|
|
|
++set->nelem;
|
|
|
|
|
return 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Realloc if we need. */
|
2004-01-02 11:08:23 +00:00
|
|
|
|
if (set->alloc == set->nelem)
|
2002-02-26 19:06:03 +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
|
|
|
|
int *new_elems;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
set->alloc = set->alloc * 2;
|
* 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
|
|
|
|
new_elems = re_realloc (set->elems, int, set->alloc);
|
|
|
|
|
if (BE (new_elems == NULL, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return -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
|
|
|
|
set->elems = new_elems;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2004-01-02 11:08:23 +00:00
|
|
|
|
|
|
|
|
|
/* Move the elements which follows the new element. Test the
|
|
|
|
|
first element separately to skip a check in the inner loop. */
|
|
|
|
|
if (elem < set->elems[0])
|
|
|
|
|
{
|
|
|
|
|
idx = 0;
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
for (idx = set->nelem; idx > 0; idx--)
|
|
|
|
|
set->elems[idx] = set->elems[idx - 1];
|
2004-01-02 11:08:23 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-01-02 11:08:23 +00:00
|
|
|
|
for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
|
|
|
|
|
set->elems[idx] = set->elems[idx - 1];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2004-01-02 11:08:23 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Insert the new element. */
|
|
|
|
|
set->elems[idx] = elem;
|
|
|
|
|
++set->nelem;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-25 22:32:18 +00:00
|
|
|
|
/* Insert the new element ELEM to the re_node_set* SET.
|
|
|
|
|
SET should not already have any element greater than or equal to ELEM.
|
|
|
|
|
Return -1 if an error is occured, return 1 otherwise. */
|
|
|
|
|
|
|
|
|
|
static int
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_insert_last (re_node_set *set, int elem)
|
2004-11-25 22:32:18 +00:00
|
|
|
|
{
|
|
|
|
|
/* Realloc if we need. */
|
|
|
|
|
if (set->alloc == set->nelem)
|
|
|
|
|
{
|
* 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
|
|
|
|
int *new_elems;
|
2004-11-25 22:32:18 +00:00
|
|
|
|
set->alloc = (set->alloc + 1) * 2;
|
* 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
|
|
|
|
new_elems = re_realloc (set->elems, int, set->alloc);
|
|
|
|
|
if (BE (new_elems == NULL, 0))
|
2004-11-25 22:32:18 +00:00
|
|
|
|
return -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
|
|
|
|
set->elems = new_elems;
|
2004-11-25 22:32:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Insert the new element. */
|
|
|
|
|
set->elems[set->nelem++] = elem;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Compare two node sets SET1 and SET2.
|
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
|
|
|
|
return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static int
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function __attribute ((pure))
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
|
|
|
|
|
return 0;
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
for (i = set1->nelem ; --i >= 0 ; )
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (set1->elems[i] != set2->elems[i])
|
|
|
|
|
return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
static int
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function __attribute ((pure))
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_contains (const re_node_set *set, int elem)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-12-10 04:37:58 +00:00
|
|
|
|
unsigned int idx, right, mid;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (set->nelem <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* Binary search the element. */
|
|
|
|
|
idx = 0;
|
|
|
|
|
right = set->nelem - 1;
|
|
|
|
|
while (idx < right)
|
|
|
|
|
{
|
|
|
|
|
mid = (idx + right) / 2;
|
|
|
|
|
if (set->elems[mid] < elem)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
idx = mid + 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else
|
2002-11-06 19:57:50 +00:00
|
|
|
|
right = mid;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-09-28 05:28:44 +00:00
|
|
|
|
return set->elems[idx] == elem ? idx + 1 : 0;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_node_set_remove_at (re_node_set *set, int idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (idx < 0 || idx >= set->nelem)
|
|
|
|
|
return;
|
|
|
|
|
--set->nelem;
|
Update.
2004-01-02 Paolo Bonzini <bonzini@gnu.org>
* posix/regex_internal.c (re_node_set_add_intersect,
re_node_set_merge): Rewritten.
(re_node_set_insert, re_node_set_remove_at):
Avoid memmove, we know what direction we should copy and that we
are copying 32-bit words.
(re_node_set_compare): Iterate backwards.
* posix/regex_internal.h (re_match_context_t): Add dfa member.
* posix/regexec.c (match_ctx_free_subtops, search_cur_bkref_entry,
match_ctx_add_sublast, sift_ctx_init, acquire_init_state_context,
prune_impossible_nodes, check_halt_state_context, proceed_next_node,
sift_states_backward, update_cur_sifted_state, check_dst_limits,
check_dst_limits_calc_pos, sift_states_bkref, transit_state,
check_subexp_matching_top, transit_state_sb, transit_state_mb,
transit_state_bkref, get_subexp, get_subexp_sub, check_arrival,
check_arrival_add_next_nodes, expand_bkref_cache, check_node_accept):
Remove dfa parameter. Get dfa from mctxt. Adjust callers.
(re_search_internal): Initialize mctxt.dfa.
2004-01-03 06:56:35 +00:00
|
|
|
|
for (; idx < set->nelem; idx++)
|
|
|
|
|
set->elems[idx] = set->elems[idx + 1];
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Add the token TOKEN to dfa->nodes, and return the index of the token.
|
|
|
|
|
Or return -1, if an error will be occured. */
|
|
|
|
|
|
|
|
|
|
static int
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
|
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 type = token.type;
|
2003-11-22 09:35:46 +00:00
|
|
|
|
if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
|
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
|
|
|
|
size_t new_nodes_alloc = dfa->nodes_alloc * 2;
|
[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 *new_nexts, *new_indices;
|
2005-01-27 19:08:10 +00:00
|
|
|
|
re_node_set *new_edests, *new_eclosures;
|
* 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
|
|
|
|
re_token_t *new_nodes;
|
|
|
|
|
|
|
|
|
|
/* Avoid overflows. */
|
|
|
|
|
if (BE (new_nodes_alloc < dfa->nodes_alloc, 0))
|
|
|
|
|
return -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
|
|
|
|
|
* 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
|
|
|
|
new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
|
* 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 (BE (new_nodes == NULL, 0))
|
2007-07-12 18:26:36 +00:00
|
|
|
|
return -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 = new_nodes;
|
[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
|
|
|
|
new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc);
|
|
|
|
|
new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc);
|
|
|
|
|
new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
|
|
|
|
|
new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
|
|
|
|
|
if (BE (new_nexts == NULL || new_indices == NULL
|
2005-01-27 19:08:10 +00:00
|
|
|
|
|| new_edests == NULL || new_eclosures == NULL, 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
|
|
|
|
return -1;
|
|
|
|
|
dfa->nexts = new_nexts;
|
|
|
|
|
dfa->org_indices = new_indices;
|
|
|
|
|
dfa->edests = new_edests;
|
|
|
|
|
dfa->eclosures = new_eclosures;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
dfa->nodes_alloc = new_nodes_alloc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
dfa->nodes[dfa->nodes_len] = token;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
dfa->nodes[dfa->nodes_len].constraint = 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
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
dfa->nodes[dfa->nodes_len].accept_mb =
|
|
|
|
|
(type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET;
|
|
|
|
|
#endif
|
|
|
|
|
dfa->nexts[dfa->nodes_len] = -1;
|
|
|
|
|
re_node_set_init_empty (dfa->edests + dfa->nodes_len);
|
|
|
|
|
re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return dfa->nodes_len++;
|
|
|
|
|
}
|
|
|
|
|
|
* 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
|
|
|
|
static inline unsigned int
|
2005-10-13 20:08:58 +00:00
|
|
|
|
internal_function
|
|
|
|
|
calc_state_hash (const re_node_set *nodes, unsigned int context)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int hash = nodes->nelem + context;
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0 ; i < nodes->nelem ; i++)
|
|
|
|
|
hash += nodes->elems[i];
|
|
|
|
|
return hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Search for the state whose node_set is equivalent to NODES.
|
|
|
|
|
Return the pointer to the state, if we found it in the DFA.
|
2002-02-28 07:43:13 +00:00
|
|
|
|
Otherwise create the new one and return it. In case of an error
|
|
|
|
|
return NULL and set the error code in ERR.
|
|
|
|
|
Note: - We assume NULL as the invalid state, then it is possible that
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return value is NULL and ERR is REG_NOERROR.
|
|
|
|
|
- We never return non-NULL value in case of any errors, it is for
|
|
|
|
|
optimization. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
|
2005-10-13 20:08:58 +00:00
|
|
|
|
static re_dfastate_t *
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
|
|
|
|
|
const re_node_set *nodes)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int hash;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
re_dfastate_t *new_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
struct re_state_table_entry *spot;
|
|
|
|
|
int i;
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (nodes->nelem == 0, 0))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_NOERROR;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
hash = calc_state_hash (nodes, 0);
|
|
|
|
|
spot = dfa->state_table + (hash & dfa->state_hash_mask);
|
|
|
|
|
|
2002-03-12 02:04:08 +00:00
|
|
|
|
for (i = 0 ; i < spot->num ; i++)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-03-12 02:04:08 +00:00
|
|
|
|
re_dfastate_t *state = spot->array[i];
|
|
|
|
|
if (hash != state->hash)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
continue;
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (re_node_set_compare (&state->nodes, nodes))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There are no appropriate state in the dfa, create the new one. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
new_state = create_ci_newstate (dfa, nodes, hash);
|
* 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 (BE (new_state == NULL, 0))
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
|
|
|
|
|
return new_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Search for the state whose node_set is equivalent to NODES and
|
|
|
|
|
whose context is equivalent to CONTEXT.
|
|
|
|
|
Return the pointer to the state, if we found it in the DFA.
|
2002-02-28 07:43:13 +00:00
|
|
|
|
Otherwise create the new one and return it. In case of an error
|
|
|
|
|
return NULL and set the error code in ERR.
|
|
|
|
|
Note: - We assume NULL as the invalid state, then it is possible that
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return value is NULL and ERR is REG_NOERROR.
|
|
|
|
|
- We never return non-NULL value in case of any errors, it is for
|
|
|
|
|
optimization. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
static re_dfastate_t *
|
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
|
|
|
|
|
const re_node_set *nodes, unsigned int context)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned int hash;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
re_dfastate_t *new_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
struct re_state_table_entry *spot;
|
|
|
|
|
int i;
|
|
|
|
|
if (nodes->nelem == 0)
|
2002-02-28 07:43:13 +00:00
|
|
|
|
{
|
|
|
|
|
*err = REG_NOERROR;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
hash = calc_state_hash (nodes, context);
|
|
|
|
|
spot = dfa->state_table + (hash & dfa->state_hash_mask);
|
|
|
|
|
|
2002-03-12 02:04:08 +00:00
|
|
|
|
for (i = 0 ; i < spot->num ; i++)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2002-03-12 02:04:08 +00:00
|
|
|
|
re_dfastate_t *state = spot->array[i];
|
2003-12-15 00:56:30 +00:00
|
|
|
|
if (state->hash == hash
|
|
|
|
|
&& state->context == context
|
|
|
|
|
&& re_node_set_compare (state->entrance_nodes, nodes))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
return state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
/* There are no appropriate state in `dfa', create the new one. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
new_state = create_cd_newstate (dfa, nodes, context, hash);
|
* 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 (BE (new_state == NULL, 0))
|
|
|
|
|
*err = REG_ESPACE;
|
|
|
|
|
|
|
|
|
|
return new_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-10 04:37:58 +00:00
|
|
|
|
/* Finish initialization of the new state NEWSTATE, and using its hash value
|
|
|
|
|
HASH put in the appropriate bucket of DFA's state table. Return value
|
|
|
|
|
indicates the error code if failed. */
|
2002-02-28 07:43:13 +00:00
|
|
|
|
|
2004-12-10 04:37:58 +00:00
|
|
|
|
static reg_errcode_t
|
2005-10-13 20:08:58 +00:00
|
|
|
|
register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
|
|
|
|
|
unsigned int hash)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-12-10 04:37:58 +00:00
|
|
|
|
struct re_state_table_entry *spot;
|
2002-11-06 19:57:50 +00:00
|
|
|
|
reg_errcode_t err;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
newstate->hash = hash;
|
|
|
|
|
err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
if (BE (err != REG_NOERROR, 0))
|
2004-12-10 04:37:58 +00:00
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
for (i = 0; i < newstate->nodes.nelem; i++)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
2004-12-10 04:37:58 +00:00
|
|
|
|
int elem = newstate->nodes.elems[i];
|
|
|
|
|
if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
|
|
|
|
|
re_node_set_insert_last (&newstate->non_eps_nodes, elem);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
spot = dfa->state_table + (hash & dfa->state_hash_mask);
|
2003-11-23 19:21:23 +00:00
|
|
|
|
if (BE (spot->alloc <= spot->num, 0))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2003-11-23 19:21:23 +00:00
|
|
|
|
int new_alloc = 2 * spot->num + 2;
|
|
|
|
|
re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
|
|
|
|
|
new_alloc);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
if (BE (new_array == NULL, 0))
|
|
|
|
|
return REG_ESPACE;
|
|
|
|
|
spot->array = new_array;
|
2003-11-23 19:21:23 +00:00
|
|
|
|
spot->alloc = new_alloc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-03-12 02:04:08 +00:00
|
|
|
|
spot->array[spot->num++] = newstate;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return REG_NOERROR;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
[BZ #1248]
2005-08-26 Paul Eggert <eggert@cs.ucla.edu>
[BZ #1248]
* posix/regex_internal.h (bitset_not, bitset_merge, bitset_not_merge,
bitset_mask, re_string_allocate, re_string_construct,
re_string_reconstruct, re_string_destruct, re_string_elem_size_at,
re_string_char_size_at, re_string_wchar_at, re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_alloc, re_node_set_init_1,
re_node_set_init_2, re_node_set_init_copy, re_node_set_add_intersect,
re_node_set_init_union, re_node_set_merge, re_node_set_insert,
re_node_set_insert_last, re_node_set_compare, re_node_set_contains,
re_node_set_remove_at, re_dfa_add_node, re_acquire_state,
re_acquire_state_context): Remove unnecessary forward decls.
(re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at):
Put __attribute at function definition, now that the function decl
has been removed.
* posix/regex_internal.c (re_string_peek_byte_case,
re_string_fetch_byte_case, re_node_set_compare, re_node_set_contains):
Likewise.
2005-10-13 21:10:24 +00:00
|
|
|
|
static void
|
|
|
|
|
free_state (re_dfastate_t *state)
|
|
|
|
|
{
|
|
|
|
|
re_node_set_free (&state->non_eps_nodes);
|
|
|
|
|
re_node_set_free (&state->inveclosure);
|
|
|
|
|
if (state->entrance_nodes != &state->nodes)
|
|
|
|
|
{
|
|
|
|
|
re_node_set_free (state->entrance_nodes);
|
|
|
|
|
re_free (state->entrance_nodes);
|
|
|
|
|
}
|
|
|
|
|
re_node_set_free (&state->nodes);
|
|
|
|
|
re_free (state->word_trtable);
|
|
|
|
|
re_free (state->trtable);
|
|
|
|
|
re_free (state);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Create the new state which is independ of contexts.
|
|
|
|
|
Return the new state if succeeded, otherwise return NULL. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static re_dfastate_t *
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
|
|
|
|
|
unsigned int hash)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_dfastate_t *newstate;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
|
|
|
|
|
newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (newstate == NULL, 0))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return NULL;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
err = re_node_set_init_copy (&newstate->nodes, nodes);
|
|
|
|
|
if (BE (err != REG_NOERROR, 0))
|
|
|
|
|
{
|
|
|
|
|
re_free (newstate);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-12-10 04:37:58 +00:00
|
|
|
|
newstate->entrance_nodes = &newstate->nodes;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
for (i = 0 ; i < nodes->nelem ; i++)
|
|
|
|
|
{
|
|
|
|
|
re_token_t *node = dfa->nodes + nodes->elems[i];
|
|
|
|
|
re_token_type_t type = node->type;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (type == CHARACTER && !node->constraint)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
continue;
|
[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
|
|
|
|
|
newstate->accept_mb |= node->accept_mb;
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* If the state has the halt node, the state is a halt state. */
|
[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 (type == END_OF_RE)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
newstate->halt = 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (type == OP_BACK_REF)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
newstate->has_backref = 1;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
else if (type == ANCHOR || node->constraint)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
newstate->has_constraint = 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
err = register_state (dfa, newstate, hash);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
if (BE (err != REG_NOERROR, 0))
|
|
|
|
|
{
|
|
|
|
|
free_state (newstate);
|
|
|
|
|
newstate = NULL;
|
|
|
|
|
}
|
|
|
|
|
return newstate;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 07:43:13 +00:00
|
|
|
|
/* Create the new state which is depend on the context CONTEXT.
|
|
|
|
|
Return the new state if succeeded, otherwise return NULL. */
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static re_dfastate_t *
|
2005-10-15 15:23:33 +00:00
|
|
|
|
internal_function
|
2005-10-13 20:08:58 +00:00
|
|
|
|
create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
|
|
|
|
|
unsigned int context, unsigned int hash)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int i, nctx_nodes = 0;
|
2002-02-28 07:43:13 +00:00
|
|
|
|
reg_errcode_t err;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_dfastate_t *newstate;
|
|
|
|
|
|
2004-12-10 04:37:58 +00:00
|
|
|
|
newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (newstate == NULL, 0))
|
2002-02-28 07:43:13 +00:00
|
|
|
|
return NULL;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
err = re_node_set_init_copy (&newstate->nodes, nodes);
|
|
|
|
|
if (BE (err != REG_NOERROR, 0))
|
|
|
|
|
{
|
|
|
|
|
re_free (newstate);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
newstate->context = context;
|
|
|
|
|
newstate->entrance_nodes = &newstate->nodes;
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < nodes->nelem ; i++)
|
|
|
|
|
{
|
|
|
|
|
re_token_t *node = dfa->nodes + nodes->elems[i];
|
|
|
|
|
re_token_type_t type = node->type;
|
2008-05-15 04:42:20 +00:00
|
|
|
|
unsigned int constraint = node->constraint;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2002-10-12 08:34:26 +00:00
|
|
|
|
if (type == CHARACTER && !constraint)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
continue;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
newstate->accept_mb |= node->accept_mb;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
|
|
|
|
|
/* If the state has the halt node, the state is a halt state. */
|
|
|
|
|
if (type == END_OF_RE)
|
|
|
|
|
newstate->halt = 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
else if (type == OP_BACK_REF)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
newstate->has_backref = 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
if (constraint)
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (newstate->entrance_nodes == &newstate->nodes)
|
|
|
|
|
{
|
|
|
|
|
newstate->entrance_nodes = re_malloc (re_node_set, 1);
|
2002-03-12 02:04:08 +00:00
|
|
|
|
if (BE (newstate->entrance_nodes == NULL, 0))
|
2002-11-06 19:57:50 +00:00
|
|
|
|
{
|
|
|
|
|
free_state (newstate);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
re_node_set_init_copy (newstate->entrance_nodes, nodes);
|
|
|
|
|
nctx_nodes = 0;
|
|
|
|
|
newstate->has_constraint = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
|
|
|
|
|
{
|
|
|
|
|
re_node_set_remove_at (&newstate->nodes, i - nctx_nodes);
|
|
|
|
|
++nctx_nodes;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
2002-02-28 07:43:13 +00:00
|
|
|
|
err = register_state (dfa, newstate, hash);
|
2002-11-06 19:57:50 +00:00
|
|
|
|
if (BE (err != REG_NOERROR, 0))
|
|
|
|
|
{
|
|
|
|
|
free_state (newstate);
|
|
|
|
|
newstate = NULL;
|
|
|
|
|
}
|
|
|
|
|
return newstate;
|
|
|
|
|
}
|