summaryrefslogtreecommitdiff
path: root/lib/regcomp.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix violation of <stdbool.h> replacement in regex.Eric Blake2008-05-151-2/+2
| | | | | | | * lib/regcomp.c (re_compile_internal): Avoid implicit cast to bool. Reported by Heinrich Mislik <Heinrich.Mislik@univie.ac.at>. Signed-off-by: Eric Blake <ebb9@byu.net>
* optimize double anchors such as ^$Paolo Bonzini2008-05-151-25/+23
| | | | | | | | | | | | | | 2008-05-15 Paolo Bonzini <bonzini@gnu.org> * lib/regcomp.c (optimize_utf8): Add a note on why we test opr.ctx_type. (calc_first): Initialize constraint field. (duplicate_node_closure): Use it instead of special casing ANCHORS. Fix grammar. (duplicate_node): Merge constraint field for all node types. (calc_eclosure_iter): Look at constraint field for all node types. * lib/regex_internal.c (create_cd_newstate): Don't look at opr.ctx_type.
* Fix a 4-year-old used-uninitialized bug in regcomp.c.Jim Meyering2007-12-011-1/+1
| | | | | | * lib/regcomp.c (optimize_utf8): Fix a typo, s/idx/ctx_type/, that would inhibit utf8-optimization of a regexp containing line- or buffer-anchors, e.g., `^', `$'.
* Fix regex code so it doesn't rely on strcasecmp.Paul Eggert2007-02-151-19/+1
| | | | | | | | | | * lib/regex_internal.h: Include <langinfo.h> only if _LIBC is defined. Otherwise, include gnulib's langinfo.h. * lib/regcomp.c (init_dfa): Don't use strcasecmp, as it can have undesirable behavior in non-C locales. Instead, rely on locale_charset. * m4/regex.m4 (gl_PREREQ_REGEX): Don't require AM_LANGINFO_CODESET. * modules/regex (FILES): Remove m4/codeset.m4. (Depends-on): Add localcharset. Remove strcase.
* 2007-02-05 Paolo Bonzini <bonzini@gnu.org>Paolo Bonzini2007-02-051-6/+2
| | | | | | | | | | Merge upstream fix for glibc bugzilla #3957: 2007-02-05 Jakub Jelinek <jakub@redhat.com> * lib/regcomp.c (parse_bracket_exp): Set '\n' bit rather than '\0' bit for RE_HAT_LISTS_NOT_NEWLINE. (build_charclass_op): Remove bogus comment.
* Avoid mempcpy in the regex code, as the string.h mempcpy stuffPaul Eggert2007-02-021-8/+4
| | | | | | | | is causing more trouble than it's curing. * lib/regex_internal.h (__mempcpy): Remove. * lib/regcomp.c (regerror): Rewrite to avoid the need for mempcpy (and make the code a tad smaller to boot). * m4/regex.m4 (gl_PREREQ_REGEX): Don't check for mempcpy.
* * lib/regex.h (_Restrict_): Renamed from __restrict, to avoidPaul Eggert2007-01-291-6/+6
| | | | | | | | | | | | a circularity problem with HP-UX ia64 reported by Bob Proulx in <http://lists.gnu.org/archive/html/bug-gnulib/2007-01/msg00394.html>. All uses changed. (_Restrict_arr_): Renamed from __restrict_arr, for similar reasons. All uses changed. * lib/regcomp.c, lib/regexec.c: Change all uses from __restrict to _Restrict_. * lib/regexec.c (regexec): Declare pmatch with _Restrict_arr_, so that the parameter matches the prototype.
* * lib/regcomp.c (parse_branch): Rename local, exp->expr, to avoidJim Meyering2006-11-281-7/+7
| | | | warning from "gcc -Wshadow" about shadowing the builtin.
* * regcomp.c (init_dfa): Don't use wchar_t or wctype_t if RE_ENABLE_I18NPaul Eggert2006-04-131-4/+6
| | | | | is not defined. Problem reported by Mark D. Baushke via Derek R. Price. * regex.h (RE_DUP_MAX): Update comment to match current implementation.
* Fix space-tab problem. From Jim Meyering.Paul Eggert2006-04-111-2/+2
|
* Merge regex changes from libc, removing some of ourPaul Eggert2006-04-101-275/+352
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX-conformance changes that were rejected and redoing them in a less-intrusive way. * lib/regcomp.c (re_compile_internal, init_dfa): Length arg is now size_t, not Idx. All uses changed. (peek_token): Forward decl now says internal_function. (__re_error_msgid, __re_error_msgid_idx): Now static rather than extern with attribute_hidden. (re_compile_pattern) [!defined _LIBC]: Use K&R-style defn. For some reason libc prefers K&R style defns for external functions. (regerror) [!defined _LIBC]: Likewise. (re_set_syntax, re_compile_fastmap, regcomp, regfree, re_comp): (seek_collating_symbol_entry, lookup_collation_sequence_value): (build_range_exp, build_collating_symbol): Use K&R-style defn. (re_compile_fastmap): Use '\0' to memset, not 0. (utf8_sb_map): Make the calculations more obvious. (init_dfa, parse_bracket_exp, build_charclass_op): Call calloc and cast result, as glibc does. (init_word_char, fetch_token, peek_token, peek_token_bracket): (build_range_exp, build_collating_symbol): Now internal functions. * lib/regex.c [!defined _LIBC]: Allow compiling with C++ compilers. * lib/regex.h (__USE_GNU_REGEX): New macro. Don't depend on _REGEX_SOURCE any more; depend on _GNU_SOURCE instead. Don't depend on VMS; depend on __VMS instead, for POSIX namespace cleanness. (regoff_t): Define to ssize_t, not long int. Remove the REG_ macros named below. Instead, make the old names (e.g., RE_BACKSLASH_ESCAPE_IN_LISTS) visible only if __USE_GNU_REGEX. (REG_BACKSLASH_ESCAPE_IN_LISTS): (REG_BK_PLUS_QM, REG_CHAR_CLASSES, REG_CONTEXT_INDEP_ANCHORS): (REG_CONTEXT_INDEP_OPS, REG_CONTEXT_INVALID_OPS): (REG_DOT_NEWLINE, REG_DOT_NOT_NULL, REG_HAT_LISTS_NOT_NEWLINE): (REG_INTERVALS, REG_LIMITED_OPS, REG_NEWLINE_ALT): (REG_NO_BK_BRACES, REG_NO_BK_PARENS, REG_NO_BK_REFS): (REG_NO_BK_VBAR, REG_NO_EMPTY_RANGES): (REG_UNMATCHED_RIGHT_PAREN_ORD, REG_NO_POSIX_BACKTRACKING): (REG_NO_GNU_OPS, REG_DEBUG, REG_INVALID_INTERVAL_ORD): (REG_IGNORE_CASE, REG_CARET_ANCHORS_HERE): (REG_CONTEXT_INVALID_DUP, REG_NO_SUB, REG_SYNTAX_EMACS): (REG_SYNTAX_AWK, REG_SYNTAX_GNU_AWK, REG_SYNTAX_POSIX_AWK): (REG_SYNTAX_GREP, REG_SYNTAX_EGREP, REG_SYNTAX_POSIX_EGREP): (REG_SYNTAX_ED, REG_SYNTAX_SED, _REG_SYNTAX_POSIX_COMMON): (REG_SYNTAX_POSIX_BASIC, REG_SYNTAX_POSIX_MINIMAL_BASIC): (REG_SYNTAX_POSIX_EXTENDED, REG_SYNTAX_POSIX_MINIMAL_EXTENDED): (REG_DUP_MAX, REG_UNALLOCATED, REG_REALLOCATE, REG_FIXED): (REG_NREGS): Remove. All uses replaced by the old RE_* names. (RE_BACKSLASH_ESCAPE_IN_LISTS): (RE_BK_PLUS_QM, RE_CHAR_CLASSES, RE_CONTEXT_INDEP_ANCHORS): (RE_CONTEXT_INDEP_OPS, RE_CONTEXT_INVALID_OPS): (RE_DOT_NEWLINE, RE_DOT_NOT_NULL, RE_HAT_LISTS_NOT_NEWLINE): (RE_INTERVALS, RE_LIMITED_OPS, RE_NEWLINE_ALT): (RE_NO_BK_BRACES, RE_NO_BK_PARENS, RE_NO_BK_REFS): (RE_NO_BK_VBAR, RE_NO_EMPTY_RANGES): (RE_UNMATCHED_RIGHT_PAREN_ORD, RE_NO_POSIX_BACKTRACKING): (RE_NO_GNU_OPS, RE_DEBUG, RE_INVALID_INTERVAL_ORD): (RE_IGNORE_CASE, RE_CARET_ANCHORS_HERE): (RE_CONTEXT_INVALID_DUP, RE_NO_SUB): Don't bother having these macros be independent of each others' values, since they no longer exist in the POSIX name space. Rename the following member names back to their old names, unless !__USE_GNU_REGEX. All uses changed back. (buffer): Renamed from re_buffer. (allocated): Renamed from re_allocated. (used): Renamed from re_used. (syntax): Renamed from re_syntax. (fastmap): Renamed from re_fastmap. (translate): Renamed from re_translate. (can_be_null): Renamed from re_can_be_null. (regs_allocated): Renamed from re_regs_allocated. (fastmap_accurate): Renamed from re_fastmap_accurate. (no_sub): Renamed from re_no_sub. (not_bol): Renamed from re_not_bol. (not_eol): Renamed from re_not_eol. (newline_anchor): Renamed from re_newline_anchor. (num_regs): Renamed from rm_num_regs. (start): Renamed from rm_start. (end): Renamed from rm_end. (free_state): Move up a bit. * lib/regex_internal.h (inline) [__GNUC__ < 3 && defined _LIBC]: #define to be empty. (ASCII_CHARS): New macro, replacing all uses of 0x80 and/or SBC_MAX / 2 when that is what is intended. (SBC_MAX): Define to UCHAR_MAX + 1, not 256. (__re_error_msgid, __re_error_msgid_idx): Remove decls; not needed. (MAX): New macro. (re_xmalloc, re_calloc, re_xrealloc, re_x2realloc): Remove. All uses changed back to re_malloc, etc. It's now the caller's responsibility to check for overflow; all callers changed. (re_alloc_oversized, re_x2alloc_oversized, re_xnmalloc, re_xnrealloc): (re_x2nrealloc): Remove. (free_state): Remove decl. * lib/regexc.c (regexec, re_match, re_search, re_match_2, re_search_2): (re_set_registers, re_exec): Use K&R-style defn. 2006-01-31 Roland McGrath <roland@redhat.com> * lib/regcomp.c (calc_eclosure_iter): Remove dead variables. Reported by Mike Frysinger <vapier@gentoo.org>. 2006-01-15 Andreas Jaeger <aj@suse.de> [BZ #1950] * lib/regex_internal.c (re_string_reconstruct): Adjust for build_wcs_upper_buffer change. (build_wcs_upper_buffer): Change return type. 2005-12-10 Ulrich Drepper <drepper@redhat.com> * lib/regex_internal.h: Include <stdint.h> if available. 2005-12-06 Paolo Bonzini <bonzini@gnu.org> * lib/regex_internal.h (SIZE_MAX): Provide a default definition. 2005-10-14 Ulrich Drepper <drepper@redhat.com> * lib/regcomp.c: Adjust for changed secondary hash function. 2005-09-30 Ulrich Drepper <drepper@redhat.com> * lib/regex.h: Pretty printing. Clean up namespace a bit. 2005-09-30 Jakub Jelinek <jakub@redhat.com> * lib/regexec.c (update_cur_sifted_state, check_arrival, check_arrival_add_next_nodes): Avoid using uninitialized variable. 2005-09-06 Paul Eggert <eggert@cs.ucla.edu> Ulrich Drepper <drepper@redhat.com> [BZ #1302] * lib/regex_internal.h (bitset_t): Renamed from bitset. All uses changed. (bitset_word_t): Renamed from bitset_word. All uses changed. 2005-09-22 Ulrich Drepper <drepper@redhat.com> [BZ #281] * lib/regex.h: Define RE_TRANSLATE_TYPE as unsigned char *. * lib/regcomp.c: Remove unnecessary uses of unsigned RE_TRANSLATE_TYPE. * lib/regex_internal.h: Likewise. * lib/regex_internal.c: Likewise. * lib/regexec.c: Likewise. Based on a patch by Stepan Kasal <kasal@ucw.cz>. 2005-09-07 Ulrich Drepper <drepper@redhat.com> * lib/regexec.c (find_recover_state): Remove unnecessary initialization. (transit_state_bkref): Make DFA a const pointer. (get_subexp): Likewise. (check_arrival): Likewise. (update_cur_sifted_state): Likewise. (re_search_internal): Likewise. (prune_impossible_nodes): Likewise. (acquire_init_state_context): Likewise. (proceed_next_node): Likewise. (set_regs): Likewise. (free_fail_stack_return): Likewise. (check_arrival_expand_ecl): Mark DFA parameter as const. (check_arrival_expand_ecl_sub): Likewise. (check_subexp_limits): Likewise. (sub_epsilon_src_nodes): Likewise. (add_epsilon_src_nodes): Likewise. (merge_state_array): Likewise. (update_regs): Likewise. (build_trtable): Likewise. (sift_states_backward): Mark MCTX parameter as const. (build_sifted_states): Likewise. (update_cur_sifted_state): Likewise. (sift_states_mkref): Likewise. (check_arrival_expand_ecl): Mark eclosure as const. (check_dst_limits_calc_pos_1): Likewise. * lib/regex_internal.h (re_match_context_t): Make dfa a const pointer. 2005-09-06 Ulrich Drepper <drepper@redhat.com> * lib/regexec.c (merge_state_with_log): Define dfa as const pointer. (transit_state_sb): Likewise. (transit_state_mb): Likewise. (sift_states_iter_mb): Likewise. (check_arrival_add_next_nodes): Likewise. (check_node_accept_bytes): Change first parameter to pointer-to-const. [_LIBC] (re_search_2_stub): Use mempcpy. * lib/regex_internal.c (re_string_reconstruct): Avoid calling mbrtowc for very simple UTF-8 case. * lib/regex_internal.c (re_acquire_state): Make DFA pointer arg a pointer-to-const. (re_acquire_state_context): Likewise. * lib/regex_internal.h: Adjust prototypes. * lib/regex.c: Prevent using C++ compilers. * lib/regex_internal.c (re_acquire_state): Minor code rearrangement. (re_acquire_state_context): Likewise.
* * regcomp.c, regexec.c, regex_internal.c: Back out previousDerek R. Price2005-09-161-13/+0
| | | | | changes, consolidating in... * regex_internal.h: ...this file.
* * regex_internal.h: Blank `pure' for GNUC < 3.Derek R. Price2005-09-151-0/+13
| | | | | | | * regex_internal.c: Ditto, using this... (__GNUC_PREREQ): ...new macro. * regcomp.c, regexec.c: Blank `always_inline' for GNUC < 3.1 using... (__GNUC_PREREQ): ...this new macro.
* Change bitset word type from unsigned int to unsigned long int,Paul Eggert2005-09-061-44/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as this has better performance on typical 64-bit hosts. Port bitset code to hosts with unusual word sizes. * lib/regcomp.c (build_equiv_class, build_charclass): (build_range_exp, build_collating_symbol): Prefer bitset to re_bitset_ptr_t in prototypes, when the actual argument is a bitset. This is merely a style issue, but it makes it clearer that an entire array is expected. (re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps): * lib/regcomp.c (lower_subexp, parse_bracket_exp): (built_charclass_op): Port to the case where bitset_word is not the same as unsigned int. * lib/regex_internal.h (bitset_set, bitset_clear, bitset_contain): (bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise. * lib/regexec.c (check_dst_limits_calc_pos_1): (check_subexp_matching_top): (build_trtable, group_nodes_into_DFAstates): Likewise. * lib/regcomp.c (re_compile_fastmap_iter, utf8_sb_map): (optimize_utf8): Don't assume that SBC_MAX is a multiple of BITSET_WORD_BITS. * lib/regex_internal.h (bitset_set_all, bitset_not): Likewise. * lib/regexec.c (group_nodes_into_DFAstates): Likewise. * lib/regcomp.c (utf8_sb_map): Don't assume UINT_MAX == 0xffffffff. * lib/regcomp.c (optimize_subexps, lower_subexp): Work even if bitset_word has holes in its bitwise representation. * lib/regex_internal.h (BITSET_WORD_BITS): Likewise. * lib/regexec.c (check_dst_limits_calc_pos_1): (heck_subexp_matching_top): Likewise. * lib/regex_internal.c (re_string_reconstruct): Don't assume UCHAR_MAX == 255. * lib/regex_internal.h (bitset_set_all): Likewise. * lib/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS. All uses changed. (BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed. (bitset_word): New type, replacing 'unsigned int' for bitset uses. All uses changed. (BITSET_WORD_MAX): New macro. (bitset_set, bitset_clear, bitset_contain, bitset_empty): (bitset_set_all, bitset_copy): Now inline functions, not macros. (bitset_empty, bitset_copy): Prefer sizeof (bitset) to multiplying it out ourselves. (bitset_not_merge): Remove; unused. (bitset_contain): Return bool, not unsigned int with one bit on. All callers changed. * lib/regexec.c (build_trtable): Don't assume bitset has no stricter alignment than re_node_set; do this by defining a new internal type struct dests_alloc and using it to allocate memory. * config/srclist.txt: Add glibc bug 1302.
* Check for arithmetic overflow when calculating sizes, to preventPaul Eggert2005-09-021-29/+23
| | | | | | | | | | | | | | | | | | | | | some buffer-overflow issues. These patches are conservative, in the sense that when I couldn't determine whether an overflow was possible, I inserted a run-time check. * regex_internal.h (re_xmalloc, re_xrealloc, re_x2realloc): New macros. (SIZE_MAX) [!defined SIZE_MAX]: New macro. (re_alloc_oversized, re_x2alloc_oversized, re_xnmalloc): (re_xnrealloc, re_x2nrealloc): New inline functions. * lib/regcomp.c (init_dfa, analyze, build_range_exp, parse_bracket_exp): (build_equiv_class, build_charclass): Check for arithmetic overflow in size expression calculations. * lib/regex_internal.c (re_string_realloc_buffers): (build_wcs_upper_buffer, re_node_set_add_intersect): (re_node_set_init_union, re_node_set_insert, re_node_set_insert_last): (re_dfa_add_node, register_state): Likewise. * lib/regexec.c (re_search_stub, re_copy_regs, re_search_internal): (prune_impossible_nodes, push_fail_stack, set_regs, check_arrival): (build_trtable, extend_buffers, match_ctx_init, match_ctx_add_entry): (match_ctx_add_subtop, match_ctx_add_sublast): Likewise.
* Use bool where appropriate.Paul Eggert2005-09-011-48/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/regcomp.c (re_set_fastmap): ICASE arg is bool, not int. All callers changed. (calc_eclosure_iter): Likewise, for ROOT arg. (parse_bracket_element): Likewise, for ACCEPT_HYPHEN arg. (build_charclass_op): Likewise, for NON_MATCH arg. * lib/regex_internal.c (re_string_allocate, re_string_construct): (re_string_construct_common): Likewise, for ICASE arg. * lib/regexec.c (re_search_2_stub, re_search_stub): Likewise, for RET_LEN arg. (check_matching): Likewise, for FL_LONGEST_MATCH arg. (set_regs): Likewise, for FL_BACKTRACK arg. * lib/regcomp.c (re_compile_fastmap_iter, optimize_utf8): (duplicate_node_closure, calc_inveclosure, calc_eclosure): (calc_eclosure_iter, parse_bracket_exp): Use bool for internal variables that are booleans. * lib/regexec.c (re_search_internal, check_matching): (proceed_next_node): (set_regs, build_sifted_states, sift_states_bkref): (check_arrival_add_next_nodes, check_arrival_expand_ecl_sub): (expand_bkref_cache, build_trtable, group_nodes_into_DFAstates): (find_collation_sequence_value): Likewise. * lib/regex_internal.c (re_node_set_insert, re_node_set_insert_last): (re_node_set_compare): Return bool, not int. All callers changed. * lib/regexec.c (check_halt_node_context, check_dst_limits): (build_trtable, check_node_accept): Likewise. * lib/regex_internal.h: Include stdbool.h. Fix bugs uncovered when converting to bool. * lib/regcomp.c (calc_eclosure_iter): Check for storage allocation failure instead of charging ahead blindly. * lib/regex_internal.c (register_state): Likewise. * lib/regexec.c (re_search_2_stub): Use simpler method than boolean for freeing internal storage. (group_nodes_into_DFA_states): Use unsigned int, not int, for bitset pieces used as boolean, to avoid undefined behavior on hosts that do int overflow checking. * config/srclist.txt: Add glibc bug 1285.
* * lib/regcomp.c (search_duplicated_node): Make first pointer argPaul Eggert2005-08-311-2/+2
| | | | | | | | | | a pointer-to-const. * lib/regex_internal.c (create_ci_newstate, create_cd_newstate): (register_state): Likewise. * lib/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. * config/srclist.txt: Add glibc bug 1282.
* On 64-bit hosts (where size_t is 64 bits and int is 32 bits), thePaul Eggert2005-08-311-114/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | old glibc regex code mishandles strings longer than 2**31 bytes. This patch fixes this when the regex code is used in gnulib (i.e., outside glibc). * lib/regex.h (_REGEX_LARGE_OFFSETS): New feature-test macro, governing whether the rest of this patch is active. By default, the macro is disabled and the patch has no effect. (regoff_t) [defined _REGEX_LARGE_OFFSETS]: Define to off_t, not int. (__re_idx_t, __re_size_t, __re_long_size_t): New types. (struct re_pattern_buffer, re_search, re_search_2, re_match): (re_match_2, re_set_registers): Use the new types. * lib/regex_internal.h (Idx, re_hashval_t): New types. (REG_MISSING, REG_ERROR, REG_VALID_INDEX, REG_VALID_NONZERO_INDEX): New macros. (re_node_set, re_charset_t, re_token_t, re_string_realloc_buffers): (re_string_context_at, bin_tree_t, re_dfastate_t): (struct re_state_table_entry, state_array_t, re_sub_match_last_t): (re_sub_match_top_t, re_match_context_t, re_sift_context_t): (struct re_fail_stack_ent_t, struct re_fail_stack_t, struct re_dfa_t): (re_string_char_size_at, re_string_wchar_at): (re_string_elem_size_at): Use the new types and macros to port to 64-bit hosts. Use unsigned types for internal values, so that the code mostly works even for arrays larger than SSIZE_MAX. * lib/regcomp.c (re_compile_internal, init_dfa, duplicate_node): (search_duplicated_node, calc_eclosure_iter, fetch_number): (parse_reg_exp, parse_branch, parse_expression, parse_sub_exp): (build_equiv_class, build_charclass, re_compile_fastmap_iter): (free_dfa_content, create_initial_state, optimize_utf8, analyze): (optimize_subexps, calc_first, link_nfa_nodes, duplicate_node_closure): (calc_inveclosure, parse_dup_op, build_range_exp): (build_collating_symbol, parse_bracket_exp, build_charclass_op): (fetch_number, create_token_tree, mark_opt_subexp): Likewise. * lib/regex_internal.c (re_string_construct_common, create_ci_newstate): (create_cd_newstate, re_string_allocate, re_string_construct): (re_string_realloc_buffers, build_wcs_upper_buffer): (re_string_skip_chars, build_upper_buffer, re_string_translate_buffer): (re_string_reconstruct, re_string_peek_byte_case): (re_string_fetch_byte_case, 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_insert_last, re_node_set_compare, re_node_set_contains): (re_node_set_remove_at, re_dfa_add_node, calc_state_hash): (re_acquire_state, re_acquire_state_context, register_state): Likewise. * lib/regex.c (match_ctx_init, match_ctx_add_entry, search_cur_bkref_entry): (match_ctx_add_subtop, match_ctx_add_sublast, sift_ctx_init): (re_search_internal, re_search_2_stub, re_search_stub) (re_copy_regs, check_matching, check_halt_state_context, update_regs): (push_fail_stack, sift_states_iter_mb, build_sifted_states): (update_cur_sifted_state, check_dst_limits): (check_dst_limits_calc_pos_1, check_dst_limits_calc_pos): (check_subexp_limits, sift_states_bkref, merge_state_array): (check_subexp_matching_top, get_subexp, get_subexp_sub): (find_subexp_node, check_arrival, check_arrival_add_next_nodes): (check_arrival_expand_ecl, check_arrival_expand_ecl_sub): (expand_bkref_cache, check_node_accept_bytes): (group_nodes_into_DFAstates, check_node_accept, regexec, re_match): (re_search, re_match_2, re_search_2, prune_impossible_nodes): (acquire_init_state_context, check_halt_node_context): (proceed_next_node, pop_fail_stack, set_regs, free_fail_stack_return): (sift_states_backward, clean_state_log_if_needed): (sub_epsilon_src_nodes, add_epsilone_src_nodes, merge_state_with_log): (find_recover_state, transit_state_sb, transit_state_mb): (transit_state_bkref, build_trtable, match_ctx_clean): Likewise. * lib/regcomp.c (parse_dup_op): Add an extra test if Idx is unsigned, to work around an assumption that REG_MISSING is negative. * m4/regex.m4 (gl_REGEX): Require AC_SYS_LARGEFILE, Define _REGEX_LARGE_OFFSETS). Test for regoff_t/off_t bug in 64-bit and large-file glibc and in 32-bit large-file Solaris. * config/srclist.txt: Add glibc bug 1281.
* * lib/regcomp.c (re_comp) [defined _REGEX_RE_COMP || defined _LIBC]:Paul Eggert2005-08-311-17/+8
| | | | | | | | | | | (seek_collating_symbol_entry) [defined _LIBC]: (lookup_collation_sequence_value) [defined _LIBC]: (build_range_exp, build_collating_symbol) [defined _LIBC]: Use prototypes rather than old-style function definitions. * lib/regexec.c (re_exec) [defined _REGEX_RE_COMP || defined _LIBC]: (transit_state_sb) [0]: (find_collation_sequence_value) [defined _LIBC]: Likewise. * config/srclist.txt: Add glibc bug 1280.
* * lib/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):Paul Eggert2005-08-311-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | (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. * lib/regex_internal.h (bitset_set, bitset_clear, bitset_contain): Likewise. * lib/regexec.c (check_dst_limits_calc_pos_1): (check_subexp_matching_top): Likewise. * lib/regcomp.c (optimize_subexps, lower_subexp): Use CHAR_BIT rather than 8, for clarity. * lib/regexec.c (check_dst_limits_calc_pos_1): (check_subexp_matching_top): Likewise. * lib/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. * lib/regcomp.c (parse_sub_exp): Do not shift more bits than there are in a word, as the resulting behavior is undefined. * lib/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. * lib/regex_internal.h (BYTE_BITS): Remove. All uses changed to the standard name CHAR_BIT. * lib/regexec.c (match_ctx_add_entry): Don't assume that ~0 == -1; this is not true on one's complement and signed-magnitude hosts.
* * lib/regex_internal.h (re_sub_match_top_t): Remove unused memberPaul Eggert2005-08-311-2/+0
| | | | | | | next_last_offset. (struct re_dfa_t): Remove unused member states_alloc. * lib/regcomp.c (init_dfa): Don't initialize unused members. * config/srclist.txt: Add glibc bug 1273.
* Make regex safe for g++. This fixes one real bug (an "err"Paul Eggert2005-08-251-7/+8
| | | | | | | | | | | | | | | | that should have been "*err"). * config/srclist.txt: Add glibc bug 1241. * lib/regex_internal.h (re_calloc): New macro, consistent with re_malloc etc. All callers of calloc changed to use re_calloc. * lib/regex_internal.c (build_wcs_upper_buffer): Return reg_errcode_t, not int. All callers changed. * lib/regcomp.c (re_compile_fastmap_iter): Don't use alloca (mb_cur_max); just use an array of size MB_LEN_MAX. * lib/regexec.c (push_fail_stack): Use re_realloc, not realloc. (find_recover_state): Change "err" to "*err"; this fixes what appears to be a real bug. (check_arrival_expand_ecl_sub): Be consistent about reg_errcode_t versus int.
* * config/srclist.txt: Add glibc bug 1240.Paul Eggert2005-08-251-1/+2
| | | | | * lib/regcomp.c (regerror): 2nd arg is 'restrict', as per POSIX. * lib/regex.h (regerror): Likewise.
* * config/srclist.txt: Add glibc bug 1237.Paul Eggert2005-08-241-134/+134
| | | | | | | | | | | * lib/regcomp.c, lib/regex_internal.c, lib/regex_internal.h: * lib/regexec.c: All uses of recently-renamed identifiers changed to use the new, POSIX-compliant names. The code will build and run just fine without these changes, but it's better to eat our own dog food and use the standard-conforming names. * m4/regex.m4 (gl_REGEX): Use POSIX-compliant spellings when testing for GNU regex features.
* * config/srclist.txt: Add glibc bug 1224.Paul Eggert2005-08-211-26/+0
| | | | | | | | * lib/regcomp.c: (init_word_char, create_initial_state, duplicate_node_closure): (fetch_token, peek_token_bracket, build_range_exp): (build_collating_symbol): Remove forward decls; no longer needed now that we use prototypes.
* * config/srclist.txt: Add glibc bug 1223.Paul Eggert2005-08-201-1/+0
| | | | * lib/regcomp.c (create_initial_state): Remove duplicate decl.
* * config/srclist.txt: Add glibc bugs 1220, 1221, 1222.Paul Eggert2005-08-201-221/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/regcomp.c: (re_compile_pattern, re_set_syntax, re_compile_fastmap): (re_compile_fastmap_iter, regcomp, regerror, regfree): (re_compile_internal, init_dfa, init_word_char, free_workarea_compile): (create_initial_state, optimize_utf8, analyze, postorder, preorder): (optimize_subexps, lower_subexps, lower_subexp, calc_first, calc_next): (link_nfa_nodes, duplicate_node_closure, search_duplicated_node): (duplicate_node, calc_inveclosure, calc_eclosure, calc_eclosure_iter): (fetch_token, peek_token, peek_token_bracket, parse, parse_reg_exp): (parse_branch, parse_expression, parse_sub_exp, parse_dup_op): (build_range_exp, build_collating_symbol, parse_bracket_exp): (parse_bracket_element, parse_bracket_symbol, build_equiv_class): (build_charclass, build_charclass_op, fetch_number, create_tree): (create_token_tree, mark_opt_subexp, duplicate_tree): Use prototypes rather than old-style definitions. * lib/regex_internal.c: (re_string_allocate, re_string_construct, re_string_realloc_buffers): (re_string_construct_common, build_wcs_buffer, build_wcs_upper_buffer): (re_string_skip_chars, build_upper_buffer, re_string_translate_buffer): (re_string_reconstruct, re_string_peek_byte_case): (re_string_fetch_byte_case, re_string_destruct, 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_insert_last, re_node_set_compare, re_node_set_contains): (re_node_set_remove_at, re_dfa_add_node, calc_state_hash): (re_acquire_state, re_acquire_state_context, register_state): (create_ci_newstate, create_cd_newstate, free_state): Likewise. * lib/regexec.c (regexec, re_match, re_search, re_match_2, re_search_2): (re_search_2_stub, re_search_stub, re_copy_regs, re_set_registers): (re_search_internal, prune_impossible_nodes): (acquire_init_state_context, check_matching, static): (check_halt_node_context, check_halt_state_context, proceed_next_node): (push_fail_stack, pop_fail_stack, set_regs, free_fail_stack_return): (update_regs, sift_states_backward, build_sifted_states): (clean_state_log_if_needed, merge_state_array): (update_cur_sifted_state, add_epsilon_src_nodes): (sub_epsilon_src_nodes, check_dst_limits, check_dst_limits_calc_pos_1): (check_dst_limits_calc_pos, check_subexp_limits, sift_states_bkref): (sift_states_iter_mb, transit_state, merge_state_with_log, static): (find_recover_state, check_subexp_matching_top, transit_state_mb): (transit_state_bkref, get_subexp, get_subexp_sub, find_subexp_node): (check_arrival, check_arrival_add_next_nodes): (check_arrival_expand_ecl, check_arrival_expand_ecl_sub): (expand_bkref_cache, build_trtable, group_nodes_into_DFAstates): (check_node_accept_bytes, check_node_accept, extend_buffers): (match_ctx_init, match_ctx_clean, match_ctx_free, match_ctx_add_entry): (search_cur_bkref_entry, match_ctx_add_subtop, match_ctx_add_sublast): (sift_ctx_init): Likewise. * lib/regex_internal.h: (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_string_peek_byte_case): (re_string_fetch_byte_case): Declare even if RE_NO_INTERNAL_PROTOTYPES is defined, since we now use prototypes always. * lib/regex.h (_RE_ARGS): Remove. No longer needed, since we assume C89 or better. All uses removed.
* (duplicate_node): Return new index, not an error code,Paul Eggert2005-08-201-31/+30
| | | | | | | 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.
* * config/srclist.txt: Comment out regcomp.c, since we have a porting fixPaul Eggert2005-07-081-3/+4
| | | | | | now. * lib/regcomp.c (init_dfa, build_range_exp): Store __btowc value in wint_t, not wchar_t. Remove now-unnecessary cast.
* * modules/regex (Files): Add lib/regex_internal.c,Paul Eggert2005-07-071-0/+3925
lib/regex_internal.h, lib/regexec.c, lib/regcomp.c, m4/codeset.m4. (Depends-on): Add extensions. (Makefile.am): Remove lib_SOURCES; now done by m4 code. * config/srclist.txt: Add regcomp.c, regex.c, regex.h, regex_internal.c, regexec.c. Add regex_internal.h too, but as a comment, since the libc version is currently broken in gnulib mode. * lib/regex.c, lib/regex.h: Sync from libc. * lib/regcomp.c, lib/regexec_internal.c, lib/regex_internal.h, lib/regexec.c: New files, synced from libc, except that regex_internal.h currently has a small porting fix. * m4/regex.m4: Adjust to new libc regex implementation. (gl_INCLUDED_REGEX): Add AC_LIBSOURCES for all the .c and .h parts of (the new) regex. Quote the m4 stuff better. Check for RE_ICASE bug of old gnulib. Check for REG_STARTEND of recent libc. Rename local variables from jm_* to gl_*. Quote operand of "test -f". Say "recent enough" version of libc, not "version 2". (gl_PREREQ_REGEX): Remove AC_FUNC_ALLOCA, since alloca is a prerequisite module. Remove AC_HEADER_STDC; no longer needed. Check for locale.h, isblank, mbrtowc, wcrtomb, wcscoll. Remove check for btowc, isascii. Require AM_LANGINFO_CODESET.