2002-02-26 19:06:03 +00:00
|
|
|
|
/* Extended regular expression matching and search library.
|
2005-01-26 19:43:44 +00:00
|
|
|
|
Copyright (C) 2002, 2003, 2004, 2005 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. */
|
|
|
|
|
|
|
|
|
|
#ifndef _REGEX_INTERNAL_H
|
|
|
|
|
#define _REGEX_INTERNAL_H 1
|
|
|
|
|
|
2003-02-21 01:52:32 +00:00
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2004-11-08 22:49:44 +00:00
|
|
|
|
#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
|
|
|
|
|
# include <langinfo.h>
|
|
|
|
|
#endif
|
2003-02-21 01:52:32 +00:00
|
|
|
|
#if defined HAVE_LOCALE_H || defined _LIBC
|
|
|
|
|
# include <locale.h>
|
|
|
|
|
#endif
|
|
|
|
|
#if defined HAVE_WCHAR_H || defined _LIBC
|
|
|
|
|
# include <wchar.h>
|
|
|
|
|
#endif /* HAVE_WCHAR_H || _LIBC */
|
|
|
|
|
#if defined HAVE_WCTYPE_H || defined _LIBC
|
|
|
|
|
# include <wctype.h>
|
|
|
|
|
#endif /* HAVE_WCTYPE_H || _LIBC */
|
2005-05-06 23:31:06 +00:00
|
|
|
|
#if defined _LIBC
|
|
|
|
|
# include <bits/libc-lock.h>
|
|
|
|
|
#else
|
|
|
|
|
# define __libc_lock_define(CLASS,NAME)
|
|
|
|
|
# define __libc_lock_init(NAME) do { } while (0)
|
|
|
|
|
# define __libc_lock_lock(NAME) do { } while (0)
|
|
|
|
|
# define __libc_lock_unlock(NAME) do { } while (0)
|
|
|
|
|
#endif
|
2003-02-21 01:52:32 +00:00
|
|
|
|
|
|
|
|
|
/* In case that the system doesn't have isblank(). */
|
|
|
|
|
#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
|
|
|
|
|
# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
|
|
|
|
|
# define _RE_DEFINE_LOCALE_FUNCTIONS 1
|
|
|
|
|
# include <locale/localeinfo.h>
|
|
|
|
|
# include <locale/elem-hash.h>
|
|
|
|
|
# include <locale/coll-lookup.h>
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* This is for other GNU distributions with internationalized messages. */
|
2004-01-30 05:22:32 +00:00
|
|
|
|
#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# include <libintl.h>
|
|
|
|
|
# ifdef _LIBC
|
|
|
|
|
# undef gettext
|
|
|
|
|
# define gettext(msgid) \
|
[BZ #284, BZ #721]
* intl/dcigettext.c (_nl_find_msg): Add a cast.
* nis/nis_clone_dir.c (nis_clone_directory): Use char * for ADDR.
* nis/nis_clone_obj.c (nis_clone_object): Likewise.
* nis/nis_clone_res.c (nis_clone_result): Likewise.
* resolv/nss_dns/dns-network.c (getanswer_r): Use const unsigned char *
for END_OF_MESSAGE and CP.
* resolv/res_send.c (send_dg): Add else branch for case impossible
unless `poll' is buggy.
* crypt/crypt_util.c (__setkey_r): Add a cast.
* locale/programs/linereader.c (get_toplvl_escape): Use size_t for
NBYTES, and unsigned char * for BYTES.
* locale/programs/charmap.c (charmap_new_char): Use size_t and
unsighed char * for NBYTES, BYTES parameters.
* sysdeps/generic/dl-hash.h (_dl_elf_hash): Take const char * argument
and cast it.
* sysdeps/i386/i686/dl-hash.h (_dl_elf_hash): Likewise.
* sunrpc/create_xid.c (_create_xid): Don't use unsigned long for RES.
* sunrpc/svcauth_des.c (_svcauth_des): Fix cast type.
* sunrpc/auth_des.c (authdes_create): Don't use u_char for PKEY_DATA.
(authdes_marshal): Don't use unsigned int for LEN.
* sunrpc/xdr.c (xdr_hyper): Don't use unsigned long for T2.
(xdr_u_hyper): Likewise.
(xdr_u_short): Don't use u_long for L.
* sunrpc/xdr_intXX_t.c (xdr_int64_t): Don't use uint32_t for T2.
* inet/rexec.c (rexec_af): Use socklen_t.
* sunrpc/key_call.c (getkeyserv_handle): Likewise.
* sunrpc/rtime.c (rtime): Likewise.
* resolv/res_send.c (send_vc, send_dg): Likewise.
* nis/nis_callback.c (__nis_create_callback): Likewise.
* sysdeps/generic/libc-start.c: Use unsigned int for nthreads ptr.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Fix type of ADDR local.
* libio/libio.h (_IO_BE): Add parenthesis around EXPR.
* intl/dcigettext.c (INTVARDEF, INTUSE): Macros removed.
(_nl_default_dirname): Use libc_hidden_data_def instead of INTVARDEF.
(libc_freeres_fn, DCIGETTEXT): Don't use INTUSE.
* intl/bindtextdom.c (INTUSE): Macro removed.
(_nl_default_dirname): Use libc_hidden_proto.
(set_binding_values): Don't use INTUSE.
* include/libintl.h (_libc_intl_domainname_internal): Decl removed.
(_libc_intl_domainname): Use libc_hidden_proto.
* posix/regex_internal.h (gettext): Remove INTUSE on it.
* locale/SYS_libc.c (_libc_intl_domainname): Use libc_hidden_data_def
rather than INTDEF.
* include/libintl.h (_): Don't use *_internal name.
* ctype/ctype-extn.c (__ctype_tolower, __ctype_toupper): Use int32_t,
not uint32_t.
* locale/lc-ctype.c (_nl_postload_ctype): Likewise for assignments.
* iconv/gconv_open.c (__gconv_open): Remove useless cast.
[BZ #721]
* sysdeps/i386/dl-machine.h (ELF_MACHINE_NO_RELA): Define this outside
of [RESOLVE_MAP].
* sysdeps/sh/dl-machine.h (ELF_MACHINE_NO_REL): Likewise.
* sysdeps/powerpc/powerpc32/dl-machine.h
(elf_machine_rel, elf_machine_rel_relative): Removed.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rel, elf_machine_rel_relative): Removed.
2005-02-03 Alexandre Oliva <aoliva@redhat.com>
[BZ #721]
* elf/dynamic-link.h: Don't declare nested auto functions that are
not going to be defined.
2004-07-23 Jakub Jelinek <jakub@redhat.com>
[BZ #284]
* include/features.h (_POSIX_SOURCE, _POSIX_C_SOURCE): Define
if _XOPEN_SOURCE >= 500 even if __STRICT_ANSI__ is defined.
2005-02-16 Roland McGrath <roland@redhat.com>
2005-02-17 01:19:55 +00:00
|
|
|
|
INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# endif
|
|
|
|
|
#else
|
|
|
|
|
# define gettext(msgid) (msgid)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef gettext_noop
|
|
|
|
|
/* This define is so xgettext can find the internationalizable
|
|
|
|
|
strings. */
|
|
|
|
|
# define gettext_noop(String) String
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-02-23 09:58:08 +00:00
|
|
|
|
#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
|
|
|
|
|
# define RE_ENABLE_I18N
|
2003-02-21 01:52:32 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if __GNUC__ >= 3
|
|
|
|
|
# define BE(expr, val) __builtin_expect (expr, val)
|
|
|
|
|
#else
|
|
|
|
|
# define BE(expr, val) (expr)
|
|
|
|
|
# define inline
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
/* Number of bits in a byte. */
|
|
|
|
|
#define BYTE_BITS 8
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Number of single byte character. */
|
|
|
|
|
#define SBC_MAX 256
|
|
|
|
|
|
|
|
|
|
#define COLL_ELEM_LEN_MAX 8
|
|
|
|
|
|
|
|
|
|
/* The character which represents newline. */
|
|
|
|
|
#define NEWLINE_CHAR '\n'
|
2002-11-13 04:00:16 +00:00
|
|
|
|
#define WIDE_NEWLINE_CHAR L'\n'
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Rename to standard API for using out of glibc. */
|
|
|
|
|
#ifndef _LIBC
|
|
|
|
|
# define __wctype wctype
|
|
|
|
|
# define __iswctype iswctype
|
|
|
|
|
# define __btowc btowc
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# define __mempcpy mempcpy
|
|
|
|
|
# define __wcrtomb wcrtomb
|
2004-11-03 20:27:19 +00:00
|
|
|
|
# define __regfree regfree
|
2002-04-26 20:52:02 +00:00
|
|
|
|
# define attribute_hidden
|
|
|
|
|
#endif /* not _LIBC */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2003-09-23 05:33:43 +00:00
|
|
|
|
#ifdef __GNUC__
|
2003-12-16 19:52:22 +00:00
|
|
|
|
# define __attribute(arg) __attribute__ (arg)
|
2003-09-23 05:33:43 +00:00
|
|
|
|
#else
|
2003-12-16 19:52:22 +00:00
|
|
|
|
# define __attribute(arg)
|
2003-09-23 05:33:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-03-13 08:59:47 +00:00
|
|
|
|
extern const char __re_error_msgid[] attribute_hidden;
|
|
|
|
|
extern const size_t __re_error_msgid_idx[] attribute_hidden;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
/* Number of bits in an unsinged int. */
|
|
|
|
|
#define UINT_BITS (sizeof (unsigned int) * BYTE_BITS)
|
|
|
|
|
/* Number of unsigned int in an bit_set. */
|
|
|
|
|
#define BITSET_UINTS ((SBC_MAX + UINT_BITS - 1) / UINT_BITS)
|
|
|
|
|
typedef unsigned int bitset[BITSET_UINTS];
|
|
|
|
|
typedef unsigned int *re_bitset_ptr_t;
|
|
|
|
|
typedef const unsigned int *re_const_bitset_ptr_t;
|
|
|
|
|
|
|
|
|
|
#define bitset_set(set,i) (set[i / UINT_BITS] |= 1 << i % UINT_BITS)
|
|
|
|
|
#define bitset_clear(set,i) (set[i / UINT_BITS] &= ~(1 << i % UINT_BITS))
|
|
|
|
|
#define bitset_contain(set,i) (set[i / UINT_BITS] & (1 << i % UINT_BITS))
|
|
|
|
|
#define bitset_empty(set) memset (set, 0, sizeof (unsigned int) * BITSET_UINTS)
|
|
|
|
|
#define bitset_set_all(set) \
|
|
|
|
|
memset (set, 255, sizeof (unsigned int) * BITSET_UINTS)
|
|
|
|
|
#define bitset_copy(dest,src) \
|
|
|
|
|
memcpy (dest, src, sizeof (unsigned int) * BITSET_UINTS)
|
|
|
|
|
static inline void bitset_not (bitset set);
|
|
|
|
|
static inline void bitset_merge (bitset dest, const bitset src);
|
|
|
|
|
static inline void bitset_not_merge (bitset dest, const bitset src);
|
|
|
|
|
static inline void bitset_mask (bitset dest, const bitset src);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#define PREV_WORD_CONSTRAINT 0x0001
|
|
|
|
|
#define PREV_NOTWORD_CONSTRAINT 0x0002
|
|
|
|
|
#define NEXT_WORD_CONSTRAINT 0x0004
|
|
|
|
|
#define NEXT_NOTWORD_CONSTRAINT 0x0008
|
|
|
|
|
#define PREV_NEWLINE_CONSTRAINT 0x0010
|
|
|
|
|
#define NEXT_NEWLINE_CONSTRAINT 0x0020
|
|
|
|
|
#define PREV_BEGBUF_CONSTRAINT 0x0040
|
|
|
|
|
#define NEXT_ENDBUF_CONSTRAINT 0x0080
|
2005-01-26 19:43:44 +00:00
|
|
|
|
#define WORD_DELIM_CONSTRAINT 0x0100
|
|
|
|
|
#define NOT_WORD_DELIM_CONSTRAINT 0x0200
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
|
|
|
|
|
WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
|
|
|
|
|
WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
|
2005-01-26 19:43:44 +00:00
|
|
|
|
INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
|
2002-02-26 19:06:03 +00:00
|
|
|
|
LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
|
|
|
|
|
LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
|
|
|
|
|
BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
|
|
|
|
|
BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
|
2005-01-26 19:43:44 +00:00
|
|
|
|
WORD_DELIM = WORD_DELIM_CONSTRAINT,
|
|
|
|
|
NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
|
2002-02-26 19:06:03 +00:00
|
|
|
|
} re_context_type;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int alloc;
|
|
|
|
|
int nelem;
|
|
|
|
|
int *elems;
|
|
|
|
|
} re_node_set;
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
NON_TYPE = 0,
|
|
|
|
|
|
2003-11-18 23:40:59 +00:00
|
|
|
|
/* Node type, These are used by token, node, tree. */
|
|
|
|
|
CHARACTER = 1,
|
|
|
|
|
END_OF_RE = 2,
|
|
|
|
|
SIMPLE_BRACKET = 3,
|
|
|
|
|
OP_BACK_REF = 4,
|
|
|
|
|
OP_PERIOD = 5,
|
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
COMPLEX_BRACKET = 6,
|
|
|
|
|
OP_UTF8_PERIOD = 7,
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
2003-11-23 09:46:38 +00:00
|
|
|
|
/* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
|
|
|
|
|
when the debugger shows values of this enum type. */
|
|
|
|
|
#define EPSILON_BIT 8
|
2003-11-18 23:40:59 +00:00
|
|
|
|
OP_OPEN_SUBEXP = EPSILON_BIT | 0,
|
|
|
|
|
OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
|
|
|
|
|
OP_ALT = EPSILON_BIT | 2,
|
|
|
|
|
OP_DUP_ASTERISK = EPSILON_BIT | 3,
|
[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
|
|
|
|
ANCHOR = EPSILON_BIT | 4,
|
2003-11-18 23:40:59 +00:00
|
|
|
|
|
|
|
|
|
/* Tree type, these are used only by tree. */
|
|
|
|
|
CONCAT = 16,
|
[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
|
|
|
|
SUBEXP = 17,
|
2003-11-18 23:40:59 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Token type, these are used only by token. */
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
OP_DUP_PLUS = 18,
|
|
|
|
|
OP_DUP_QUESTION,
|
|
|
|
|
OP_OPEN_BRACKET,
|
2002-02-26 19:06:03 +00:00
|
|
|
|
OP_CLOSE_BRACKET,
|
|
|
|
|
OP_CHARSET_RANGE,
|
|
|
|
|
OP_OPEN_DUP_NUM,
|
|
|
|
|
OP_CLOSE_DUP_NUM,
|
|
|
|
|
OP_NON_MATCH_LIST,
|
|
|
|
|
OP_OPEN_COLL_ELEM,
|
|
|
|
|
OP_CLOSE_COLL_ELEM,
|
|
|
|
|
OP_OPEN_EQUIV_CLASS,
|
|
|
|
|
OP_CLOSE_EQUIV_CLASS,
|
|
|
|
|
OP_OPEN_CHAR_CLASS,
|
|
|
|
|
OP_CLOSE_CHAR_CLASS,
|
|
|
|
|
OP_WORD,
|
|
|
|
|
OP_NOTWORD,
|
2003-09-23 05:43:03 +00:00
|
|
|
|
OP_SPACE,
|
|
|
|
|
OP_NOTSPACE,
|
2003-11-18 23:40:59 +00:00
|
|
|
|
BACK_SLASH
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
} re_token_type_t;
|
|
|
|
|
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
/* Multibyte characters. */
|
|
|
|
|
wchar_t *mbchars;
|
|
|
|
|
|
|
|
|
|
/* Collating symbols. */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef _LIBC
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int32_t *coll_syms;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Equivalence classes. */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef _LIBC
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int32_t *equiv_classes;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Range expressions. */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# ifdef _LIBC
|
2002-02-26 19:06:03 +00:00
|
|
|
|
uint32_t *range_starts;
|
|
|
|
|
uint32_t *range_ends;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# else /* not _LIBC */
|
2002-04-26 20:52:02 +00:00
|
|
|
|
wchar_t *range_starts;
|
|
|
|
|
wchar_t *range_ends;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
# endif /* not _LIBC */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* Character classes. */
|
|
|
|
|
wctype_t *char_classes;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
|
|
|
|
/* If this character set is the non-matching list. */
|
|
|
|
|
unsigned int non_match : 1;
|
|
|
|
|
|
|
|
|
|
/* # of multibyte characters. */
|
|
|
|
|
int nmbchars;
|
|
|
|
|
|
|
|
|
|
/* # of collating symbols. */
|
|
|
|
|
int ncoll_syms;
|
|
|
|
|
|
|
|
|
|
/* # of equivalence classes. */
|
|
|
|
|
int nequiv_classes;
|
|
|
|
|
|
|
|
|
|
/* # of range expressions. */
|
|
|
|
|
int nranges;
|
|
|
|
|
|
|
|
|
|
/* # of character classes. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int nchar_classes;
|
|
|
|
|
} re_charset_t;
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
unsigned char c; /* for CHARACTER */
|
|
|
|
|
re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_charset_t *mbcset; /* for COMPLEX_BRACKET */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int idx; /* for BACK_REF */
|
|
|
|
|
re_context_type ctx_type; /* for ANCHOR */
|
|
|
|
|
} opr;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
#if __GNUC__ >= 2
|
|
|
|
|
re_token_type_t type : 8;
|
|
|
|
|
#else
|
|
|
|
|
re_token_type_t type;
|
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int constraint : 10; /* context constraint */
|
|
|
|
|
unsigned int duplicated : 1;
|
2003-12-27 23:40:06 +00:00
|
|
|
|
unsigned int opt_subexp : 1;
|
2002-02-26 19:06:03 +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
|
|
|
|
unsigned int accept_mb : 1;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
/* These 2 bits can be moved into the union if needed (e.g. if running out
|
|
|
|
|
of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int mb_partial : 1;
|
|
|
|
|
#endif
|
2003-11-24 19:30:51 +00:00
|
|
|
|
unsigned int word_char : 1;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
} re_token_t;
|
|
|
|
|
|
2003-11-18 23:40:59 +00:00
|
|
|
|
#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
struct re_string_t
|
|
|
|
|
{
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Indicate the raw buffer which is the original string passed as an
|
|
|
|
|
argument of regexec(), re_search(), etc.. */
|
2002-09-10 18:40:35 +00:00
|
|
|
|
const unsigned char *raw_mbs;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Store the multibyte string. In case of "case insensitive mode" like
|
2002-04-24 21:54:53 +00:00
|
|
|
|
REG_ICASE, upper cases of the string are stored, otherwise MBS points
|
|
|
|
|
the same address that RAW_MBS points. */
|
2002-09-10 18:40:35 +00:00
|
|
|
|
unsigned char *mbs;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
|
|
|
|
/* Store the wide character string which is corresponding to MBS. */
|
2002-05-24 08:49:00 +00:00
|
|
|
|
wint_t *wcs;
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
int *offsets;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
mbstate_t cur_state;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif
|
2002-07-10 23:09:16 +00:00
|
|
|
|
/* Index in RAW_MBS. Each character mbs[i] corresponds to
|
|
|
|
|
raw_mbs[raw_mbs_idx + i]. */
|
|
|
|
|
int raw_mbs_idx;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* The length of the valid characters in the buffers. */
|
|
|
|
|
int valid_len;
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
/* The corresponding number of bytes in raw_mbs array. */
|
|
|
|
|
int valid_raw_len;
|
|
|
|
|
/* The length of the buffers MBS and WCS. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
int bufs_len;
|
|
|
|
|
/* The index in MBS, which is updated by re_string_fetch_byte. */
|
|
|
|
|
int cur_idx;
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
/* length of RAW_MBS array. */
|
|
|
|
|
int raw_len;
|
|
|
|
|
/* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
|
2002-04-24 21:54:53 +00:00
|
|
|
|
int len;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
/* End of the buffer may be shorter than its length in the cases such
|
|
|
|
|
as re_match_2, re_search_2. Then, we use STOP for end of the buffer
|
|
|
|
|
instead of LEN. */
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
int raw_stop;
|
|
|
|
|
/* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
|
2002-07-27 08:20:17 +00:00
|
|
|
|
int stop;
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* The context of mbs[0]. We store the context independently, since
|
|
|
|
|
the context of mbs[0] may be different from raw_mbs[0], which is
|
|
|
|
|
the beginning of the input string. */
|
|
|
|
|
unsigned int tip_context;
|
|
|
|
|
/* The translation passed as a part of an argument of re_compile_pattern. */
|
2004-12-22 20:10:10 +00:00
|
|
|
|
unsigned RE_TRANSLATE_TYPE trans;
|
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
|
|
|
|
/* Copy of re_dfa_t's word_char. */
|
|
|
|
|
re_const_bitset_ptr_t word_char;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* 1 if REG_ICASE. */
|
Update.
2003-11-28 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/fpu/libm-test-ulps: Add some more minor changes
to compensate other setup.
2003-11-27 Andreas Jaeger <aj@suse.de>
* sysdeps/x86_64/fpu/libm-test-ulps: Add ulps for new atan2 test.
* math/libm-test.inc (atan2_test): Add test that run infinitly.
Reported by "Willus" <etc231etc231@willus.com>.
2003-11-27 Michael Matz <matz@suse.de>
* sysdeps/ieee754/dbl-64/mpsqrt.c (fastiroot): Fix 64-bit problem
with wrong types.
2003-11-28 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (acquire_init_state_context): Make inline.
Add always_inline attribute.
(check_matching): Add BE macro. Move if (cur_state->has_backref)
into if (dfa->nbackref).
(sift_states_backward): Fix comment.
(transit_state): Add BE macro. Move if (next_state->has_backref)
into if (dfa->nbackref && next_state). Don't check for next_state
!= NULL twice.
* posix/regcomp.c (peek_token): Use opr.ctx_type instead of opr.idx
for ANCHOR.
(parse_expression): Only call init_word_char if word context will be
needed.
* posix/bug-regex11.c (tests): Add new tests.
* posix/tst-regex.c: Include getopt.h.
(timing): New variable.
(main): Set timing to 1 if --timing argument is present.
Add 2 new tests.
(run_test, run_test_backwards): Handle timing.
2003-11-27 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (re_string_t): Remove mbs_case field.
Add offsets, valid_raw_len, raw_len, raw_stop, mbs_allocated and
offsets_needed fields. Change icase, is_utf8 and map_notascii
type from int bitfield to unsigned char.
(MBS_ALLOCATED, MBS_CASE_ALLOCATED): Remove.
(build_wcs_upper_buffer): Change prototype to return int.
(re_string_peek_byte_case, re_string_fetch_byte_case): Remove
defines, add prototypes.
* posix/regex_internal.c (re_string_allocate): Don't initialize
stop here. Don't initialize mbs_case. Set valid_raw_len.
Use mbs_allocated instead of MBS_* macros.
(re_string_construct): Don't initialize stop and valid_len here.
Don't initialize mbs_case. Use mbs_allocated instead of MBS_*
macros. Reallocate buffers if build_wcs_upper_buffer converted
too few bytes. Set valid_len to bufs_len only for single byte
no translation and set in that case valid_raw_len as well.
(re_string_realloc_buffers): Reallocate offsets if not NULL.
Use mbs_allocated instead of MBS_ALLOCATED. Don't reallocate
mbs_case.
(re_string_construct_common): Initialize raw_len, mbs_allocated,
stop and raw_stop.
(build_wcs_buffer): Apply pstr->trans before mbrtowc instead of
after it. Set valid_raw_len. Don't set mbs_case.
(build_wcs_upper_buffer): Return REG_NOERROR or REG_ESPACE.
Only use the fast path if !pstr->offsets_needed. Apply pstr->trans
before mbrtowc instead of after it. If upper case character
uses different number of bytes than lower case, goto to the
slow path. Don't call towupper unnecessarily twice. Set
valid_raw_len as well. Handle in the slow path the case if
lower and upper case use different number of characters.
Don't set mbs_case.
(re_string_skip_chars): Use valid_raw_len instead of valid_len.
(build_upper_buffer): Don't set mbs_case. Add BE macro. Set
valid_raw_len.
(re_string_translate_buffer): Set mbs instead of mbs_case. Set
valid_raw_len.
(re_string_reconstruct): Use raw_len/raw_stop to initialize
len/stop. Clear valid_raw_len and offsets_needed when clearing
valid_len. Use mbs_allocated instead of MBS_* macros.
Check original offset against valid_raw_len instead of valid_len.
Remove mbs_case handling. Adjust valid_raw_len together with
valid_len. If is_utf8 and looking for tip context, apply
pstr->trans first. If buffers start with partial multi-byte
character, initialize mbs array as well if mbs_allocated.
Check return value of build_wcs_upper_buffer.
(re_string_peek_byte_case): New function.
(re_string_fetch_byte_case): New function.
(re_string_destruct): Use mbs_allocated instead of MBS_ALLOCATED.
Don't free mbs_case. Free offsets.
* posix/regcomp.c (init_dfa): Only check if charset name is UTF-8
if mb_cur_max == 6.
* posix/regexec.c (re_search_internal): Initialize input.raw_stop
as well. Use valid_raw_len instead of valid_len when looking
through fastmap. Adjust registers through input.offsets.
(extend_buffers): Allow build_wcs_upper_buffer to fail.
* posix/bug-regex18.c (tests): Enable #ifdefed out tests. Add new
tests.
2003-11-29 06:13:09 +00:00
|
|
|
|
unsigned char icase;
|
|
|
|
|
unsigned char is_utf8;
|
|
|
|
|
unsigned char map_notascii;
|
|
|
|
|
unsigned char mbs_allocated;
|
|
|
|
|
unsigned char offsets_needed;
|
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
|
|
|
|
unsigned char newline_anchor;
|
|
|
|
|
unsigned char word_ops_used;
|
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
|
|
|
|
int mb_cur_max;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
};
|
|
|
|
|
typedef struct re_string_t re_string_t;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2003-11-16 07:14:28 +00:00
|
|
|
|
struct re_dfa_t;
|
|
|
|
|
typedef struct re_dfa_t re_dfa_t;
|
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
|
|
|
|
|
|
|
|
|
#ifndef _LIBC
|
|
|
|
|
# ifdef __i386__
|
|
|
|
|
# define internal_function __attribute ((regparm (3), stdcall))
|
|
|
|
|
# else
|
|
|
|
|
# define internal_function
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#ifndef RE_NO_INTERNAL_PROTOTYPES
|
|
|
|
|
static reg_errcode_t 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)
|
|
|
|
|
internal_function;
|
|
|
|
|
static reg_errcode_t re_string_construct (re_string_t *pstr, const char *str,
|
|
|
|
|
int len, RE_TRANSLATE_TYPE trans,
|
|
|
|
|
int icase, const re_dfa_t *dfa)
|
|
|
|
|
internal_function;
|
|
|
|
|
static reg_errcode_t re_string_reconstruct (re_string_t *pstr, int idx,
|
|
|
|
|
int eflags) internal_function;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
|
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 new_buf_len)
|
|
|
|
|
internal_function;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
# ifdef RE_ENABLE_I18N
|
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
|
|
|
|
static void build_wcs_buffer (re_string_t *pstr) internal_function;
|
|
|
|
|
static int build_wcs_upper_buffer (re_string_t *pstr) internal_function;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
# endif /* RE_ENABLE_I18N */
|
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
|
|
|
|
static void build_upper_buffer (re_string_t *pstr) internal_function;
|
|
|
|
|
static void re_string_translate_buffer (re_string_t *pstr) internal_function;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
static void re_string_destruct (re_string_t *pstr) internal_function;
|
|
|
|
|
# ifdef RE_ENABLE_I18N
|
|
|
|
|
static int re_string_elem_size_at (const re_string_t *pstr, int idx)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
static inline int re_string_char_size_at (const re_string_t *pstr, int idx)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
static inline wint_t re_string_wchar_at (const re_string_t *pstr, int idx)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
# endif /* RE_ENABLE_I18N */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static unsigned int re_string_context_at (const re_string_t *input, int idx,
|
2004-12-10 04:37:58 +00:00
|
|
|
|
int eflags)
|
|
|
|
|
internal_function __attribute ((pure));
|
2004-12-22 20:10:10 +00:00
|
|
|
|
static unsigned char re_string_peek_byte_case (const re_string_t *pstr,
|
|
|
|
|
int idx)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
static unsigned char re_string_fetch_byte_case (re_string_t *pstr)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#define re_string_peek_byte(pstr, offset) \
|
|
|
|
|
((pstr)->mbs[(pstr)->cur_idx + offset])
|
|
|
|
|
#define re_string_fetch_byte(pstr) \
|
|
|
|
|
((pstr)->mbs[(pstr)->cur_idx++])
|
|
|
|
|
#define re_string_first_byte(pstr, idx) \
|
2003-11-19 08:43:18 +00:00
|
|
|
|
((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#define re_string_is_single_byte_char(pstr, idx) \
|
2004-01-14 01:45:37 +00:00
|
|
|
|
((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
|
2002-11-06 20:36:47 +00:00
|
|
|
|
|| (pstr)->wcs[(idx) + 1] != WEOF))
|
2002-07-27 08:20:17 +00:00
|
|
|
|
#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
|
|
|
|
|
#define re_string_get_buffer(pstr) ((pstr)->mbs)
|
|
|
|
|
#define re_string_length(pstr) ((pstr)->len)
|
2002-04-24 21:54:53 +00:00
|
|
|
|
#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
|
|
|
|
|
#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
|
|
|
|
|
|
|
|
|
|
#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
|
|
|
|
|
#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
|
|
|
|
|
#define re_free(p) free (p)
|
|
|
|
|
|
|
|
|
|
struct bin_tree_t
|
|
|
|
|
{
|
|
|
|
|
struct bin_tree_t *parent;
|
|
|
|
|
struct bin_tree_t *left;
|
|
|
|
|
struct bin_tree_t *right;
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
struct bin_tree_t *first;
|
|
|
|
|
struct bin_tree_t *next;
|
|
|
|
|
|
|
|
|
|
re_token_t token;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
/* `node_idx' is the index in dfa->nodes, if `type' == 0.
|
|
|
|
|
Otherwise `type' indicate the type of this node. */
|
|
|
|
|
int node_idx;
|
|
|
|
|
};
|
|
|
|
|
typedef struct bin_tree_t bin_tree_t;
|
|
|
|
|
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
#define BIN_TREE_STORAGE_SIZE \
|
|
|
|
|
((1024 - sizeof (void *)) / sizeof (bin_tree_t))
|
|
|
|
|
|
|
|
|
|
struct bin_tree_storage_t
|
|
|
|
|
{
|
|
|
|
|
struct bin_tree_storage_t *next;
|
|
|
|
|
bin_tree_t data[BIN_TREE_STORAGE_SIZE];
|
|
|
|
|
};
|
|
|
|
|
typedef struct bin_tree_storage_t bin_tree_storage_t;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#define CONTEXT_WORD 1
|
|
|
|
|
#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
|
|
|
|
|
#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
|
|
|
|
|
#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
|
|
|
|
|
|
|
|
|
|
#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
|
|
|
|
|
#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
|
|
|
|
|
#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
|
|
|
|
|
#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
|
|
|
|
|
#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
|
|
|
|
|
|
|
|
|
|
#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
|
|
|
|
|
#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
|
2002-11-13 04:00:16 +00:00
|
|
|
|
#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
|
|
|
|
|
#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
|
|
|
|
|
((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
|
|
|
|
|
|| ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
|
|
|
|
|
|| ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
|
|
|
|
|
|| ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
|
|
|
|
|
|
|
|
|
|
#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
|
|
|
|
|
((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
|
|
|
|
|
|| (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
|
|
|
|
|
|| (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
|
|
|
|
|
|| (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
|
|
|
|
|
|
|
|
|
|
struct re_dfastate_t
|
|
|
|
|
{
|
|
|
|
|
unsigned int hash;
|
|
|
|
|
re_node_set nodes;
|
2004-12-10 04:37:58 +00:00
|
|
|
|
re_node_set non_eps_nodes;
|
|
|
|
|
re_node_set inveclosure;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set *entrance_nodes;
|
2004-12-27 16:44:39 +00:00
|
|
|
|
struct re_dfastate_t **trtable, **word_trtable;
|
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
|
|
|
|
unsigned int context : 4;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int halt : 1;
|
|
|
|
|
/* If this state can accept `multi byte'.
|
|
|
|
|
Note that we refer to multibyte characters, and multi character
|
|
|
|
|
collating elements as `multi byte'. */
|
|
|
|
|
unsigned int accept_mb : 1;
|
|
|
|
|
/* If this state has backreference node(s). */
|
|
|
|
|
unsigned int has_backref : 1;
|
|
|
|
|
unsigned int has_constraint : 1;
|
|
|
|
|
};
|
|
|
|
|
typedef struct re_dfastate_t re_dfastate_t;
|
|
|
|
|
|
|
|
|
|
struct re_state_table_entry
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
int alloc;
|
2002-03-12 02:04:08 +00:00
|
|
|
|
re_dfastate_t **array;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int next_idx;
|
|
|
|
|
int alloc;
|
|
|
|
|
re_dfastate_t **array;
|
|
|
|
|
} state_array_t;
|
|
|
|
|
|
|
|
|
|
/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int node;
|
|
|
|
|
int str_idx; /* The position NODE match at. */
|
|
|
|
|
state_array_t path;
|
|
|
|
|
} re_sub_match_last_t;
|
|
|
|
|
|
|
|
|
|
/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
|
|
|
|
|
And information about the node, whose type is OP_CLOSE_SUBEXP,
|
|
|
|
|
corresponding to NODE is stored in LASTS. */
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int str_idx;
|
|
|
|
|
int node;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
int next_last_offset;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
state_array_t *path;
|
|
|
|
|
int alasts; /* Allocation size of LASTS. */
|
|
|
|
|
int nlasts; /* The number of LASTS. */
|
|
|
|
|
re_sub_match_last_t **lasts;
|
|
|
|
|
} re_sub_match_top_t;
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
struct re_backref_cache_entry
|
|
|
|
|
{
|
|
|
|
|
int node;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
int str_idx;
|
|
|
|
|
int subexp_from;
|
|
|
|
|
int subexp_to;
|
2004-11-12 09:45:05 +00:00
|
|
|
|
char more;
|
|
|
|
|
char unused;
|
|
|
|
|
unsigned short int eps_reachable_subexps_map;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
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
|
|
|
|
/* The string object corresponding to the input string. */
|
|
|
|
|
re_string_t input;
|
2004-01-03 13:07:29 +00:00
|
|
|
|
#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
|
2004-12-22 20:10:10 +00:00
|
|
|
|
re_dfa_t *const dfa;
|
2004-01-03 13:07:29 +00:00
|
|
|
|
#else
|
2004-12-22 20:10:10 +00:00
|
|
|
|
re_dfa_t *dfa;
|
2004-01-03 13:07:29 +00:00
|
|
|
|
#endif
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* EFLAGS of the argument of regexec. */
|
|
|
|
|
int eflags;
|
|
|
|
|
/* Where the matching ends. */
|
|
|
|
|
int match_last;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
int last_node;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* The state log used by the matcher. */
|
|
|
|
|
re_dfastate_t **state_log;
|
|
|
|
|
int state_log_top;
|
|
|
|
|
/* Back reference cache. */
|
|
|
|
|
int nbkref_ents;
|
|
|
|
|
int abkref_ents;
|
|
|
|
|
struct re_backref_cache_entry *bkref_ents;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
int max_mb_elem_len;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
int nsub_tops;
|
|
|
|
|
int asub_tops;
|
|
|
|
|
re_sub_match_top_t **sub_tops;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
} re_match_context_t;
|
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
re_dfastate_t **sifted_states;
|
|
|
|
|
re_dfastate_t **limited_states;
|
|
|
|
|
int last_node;
|
|
|
|
|
int last_str_idx;
|
2004-11-08 16:06:36 +00:00
|
|
|
|
re_node_set limits;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
} re_sift_context_t;
|
|
|
|
|
|
2002-09-30 22:01:05 +00:00
|
|
|
|
struct re_fail_stack_ent_t
|
|
|
|
|
{
|
|
|
|
|
int idx;
|
|
|
|
|
int node;
|
|
|
|
|
regmatch_t *regs;
|
|
|
|
|
re_node_set eps_via_nodes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct re_fail_stack_t
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
int alloc;
|
|
|
|
|
struct re_fail_stack_ent_t *stack;
|
|
|
|
|
};
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
struct re_dfa_t
|
|
|
|
|
{
|
|
|
|
|
re_token_t *nodes;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
int nodes_alloc;
|
|
|
|
|
int nodes_len;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int *nexts;
|
2002-12-17 10:58:04 +00:00
|
|
|
|
int *org_indices;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_node_set *edests;
|
|
|
|
|
re_node_set *eclosures;
|
|
|
|
|
re_node_set *inveclosures;
|
|
|
|
|
struct re_state_table_entry *state_table;
|
|
|
|
|
re_dfastate_t *init_state;
|
|
|
|
|
re_dfastate_t *init_state_word;
|
|
|
|
|
re_dfastate_t *init_state_nl;
|
|
|
|
|
re_dfastate_t *init_state_begbuf;
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
bin_tree_t *str_tree;
|
|
|
|
|
bin_tree_storage_t *str_tree_storage;
|
2003-11-24 19:30:51 +00:00
|
|
|
|
re_bitset_ptr_t sb_char;
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
int str_tree_storage_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
|
|
|
|
|
|
|
|
|
/* number of subexpressions `re_nsub' is in regex_t. */
|
|
|
|
|
unsigned int state_hash_mask;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
int states_alloc;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
int init_node;
|
|
|
|
|
int nbackref; /* The number of backreference in this dfa. */
|
2004-12-06 03:03:01 +00:00
|
|
|
|
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* Bitmap expressing which backreference is used. */
|
2004-12-22 20:10:10 +00:00
|
|
|
|
unsigned int used_bkref_map;
|
|
|
|
|
unsigned int completed_bkref_map;
|
2004-12-06 03:03:01 +00:00
|
|
|
|
|
2002-09-28 05:28:44 +00:00
|
|
|
|
unsigned int has_plural_match : 1;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
/* If this dfa has "multibyte node", which is a backreference or
|
|
|
|
|
a node which can accept multibyte character or multi character
|
|
|
|
|
collating element. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
unsigned int has_mb_node : 1;
|
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
2003-11-12 17:47:46 +00:00
|
|
|
|
unsigned int is_utf8 : 1;
|
2003-11-16 07:14:28 +00:00
|
|
|
|
unsigned int map_notascii : 1;
|
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
|
|
|
|
unsigned int word_ops_used : 1;
|
Update.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (NFTW_NEW_NAME, NFTW_OLD_NAME): Add prototypes.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/tst-regex.c (umemlen): New variable.
(test_expr): Add expectedicase argument. Test case insensitive
searches as well as backwards searches (case sensitive and
insensitive) too.
(run_test): Add icase argument. Use it to compute regcomp flags.
(run_test_backwards): New function.
(main): Cast read to size_t to avoid warning. Set umemlen.
Add expectedicase arguments to test_expr.
* posix/regex_internal.c (re_string_reconstruct): If is_utf8,
find previous character by walking back instead of converting
all chars from beginning.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/regex_internal.h (struct re_string_t): Add is_utf8
and mb_cur_max fields.
(struct re_dfa_t): Likewise. Reorder fields to make structure
smaller on 64-bit arches.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments.
(re_string_char_size_at, re_string_wchar_at): Use pstr->mb_cur_max
instead of MB_CUR_MAX.
* posix/regcomp.c (re_compile_fastmap_iter): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
(re_compile_internal): Pass new arguments to re_string_construct.
(init_dfa): Initialize mb_cur_max and is_utf8 fields.
(peek_token, peek_token_bracket): Use input->mb_cur_max instead
of MB_CUR_MAX.
(parse_expression, parse_bracket_exp, parse_charclass_op): Use
dfa->mb_cur_max instead of MB_CUR_MAX.
* posix/regex_internal.c (re_string_construct_common): Add
mb_cur_max and is_utf8 arguments. Initialize fields with them.
(re_string_allocate, re_string_construct): Add mb_cur_max and
is_utf8 arguments, pass them to re_string_construct_common.
Use mb_cur_max instead of MB_CUR_MAX.
(re_string_realloc_buffers): Use pstr->mb_cur_max instead of
MB_CUR_MAX.
(re_string_reconstruct): Likewise.
(re_string_context_at): Use input->mb_cur_max instead of
MB_CUR_MAX.
(create_ci_newstate, create_cd_newstate): Use dfa->mb_cur_max
instead of MB_CUR_MAX.
* posix/regexec.c (re_search_internal): Likewise.
Pass new arguments to re_string_allocate.
(check_matching, transit_state_sb): Use dfa->mb_cur_max instead of
MB_CUR_MAX.
(extend_buffers): Use pstr->mb_cur_max instead of MB_CUR_MAX.
2003-11-12 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (tests): Add bug-regex19.
(bug-regex19-ENV): Add LOCPATH.
* posix/bug-regex19.c: New test.
2003-11-12 17:47:46 +00:00
|
|
|
|
int mb_cur_max;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
bitset word_char;
|
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
|
|
|
|
reg_syntax_t syntax;
|
2004-11-18 23:57:34 +00:00
|
|
|
|
int *subexp_map;
|
Update.
2003-11-19 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (extend_buffers): Don't allocate
twice as big state_log as needed. Don't modify pstr->valid_len
for mb_cur_max == 1 !icase !trans.
* posix/regcomp.c (free_bin_tree): Removed.
(create_tree): Add dfa argument. Don't call re_malloc for
each tree, instead allocate from str_tree_storage.
(re_dfa_add_tree_node): New function.
(free_dfa_content): Handle freeing if dfa->nodes == NULL
or dfa->state_table == NULL.
(re_compile_internal): Call free_dfa_content if init_dfa
fails. Call free_workarea_compile, re_string_destruct
and free_dfa_content for most of the other failure paths.
(init_dfa): Initialize str_tree_storage_idx.
Don't clear any fields on allocation failure.
(free_workarea_compile): Free str_tree_storage chunks
instead of free_bin_tree (dfa->str_tree).
(parse): Call re_dfa_add_tree_node instead of re_dfa_add_node
followed by create_tree. Add dfa argument to remaining
create_tree calls. Remove new_idx variable. Remove calls
to free_bin_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_sub_exp,
parse_dup_op, parse_bracket_exp, build_charclass_op): Likewise.
(duplicate_tree): Remove calls to free_bin_tree, add dfa
argument to create_tree.
* posix/regex_internal.h (BIN_TREE_STORAGE_SIZE): Define.
(bin_tree_storage_t): New type.
(re_dfa_t): Add str_tree_storage and str_tree_storage_idx
fields.
* posix/Makefile (tests): Add bug-regex21.
(generated): Add bug-regex21-mem, bug-regex21.mtrace,
tst-rxspencer-mem and tst-rxspencer.mtrace.
(tests): Depend on $(objpfx)bug-regex21-mem
and $(objpfx)tst-rxspencer-mem.
(bug-regex21-ENV, tst-rxspencer-ENV): Set.
($(objpfx)bug-regex21-mem, $(objpfx)tst-rxspencer-mem): New.
* posix/tst-rxspencer.c (main): Add call to mtrace.
Free line at the end.
* posix/bug-regex21.c: New test.
* posix/regexec.c (get_subexp): After calling get_subexp_sub
2003-11-19 19:37:31 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
char* re_str;
|
|
|
|
|
#endif
|
2005-05-06 23:31:06 +00:00
|
|
|
|
__libc_lock_define (, lock)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#ifndef RE_NO_INTERNAL_PROTOTYPES
|
|
|
|
|
static reg_errcode_t re_node_set_alloc (re_node_set *set, int size) internal_function;
|
|
|
|
|
static reg_errcode_t re_node_set_init_1 (re_node_set *set, int elem) internal_function;
|
|
|
|
|
static reg_errcode_t re_node_set_init_2 (re_node_set *set, int elem1,
|
|
|
|
|
int elem2) internal_function;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
|
2004-12-22 20:10:10 +00:00
|
|
|
|
static reg_errcode_t re_node_set_init_copy (re_node_set *dest,
|
|
|
|
|
const re_node_set *src) internal_function;
|
|
|
|
|
static reg_errcode_t re_node_set_add_intersect (re_node_set *dest,
|
|
|
|
|
const re_node_set *src1,
|
|
|
|
|
const re_node_set *src2) internal_function;
|
|
|
|
|
static reg_errcode_t re_node_set_init_union (re_node_set *dest,
|
|
|
|
|
const re_node_set *src1,
|
|
|
|
|
const re_node_set *src2) internal_function;
|
|
|
|
|
static reg_errcode_t re_node_set_merge (re_node_set *dest,
|
|
|
|
|
const re_node_set *src) internal_function;
|
|
|
|
|
static int re_node_set_insert (re_node_set *set, int elem) internal_function;
|
|
|
|
|
static int re_node_set_insert_last (re_node_set *set,
|
|
|
|
|
int elem) internal_function;
|
|
|
|
|
static int re_node_set_compare (const re_node_set *set1,
|
|
|
|
|
const re_node_set *set2)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
static int re_node_set_contains (const re_node_set *set, int elem)
|
|
|
|
|
internal_function __attribute ((pure));
|
|
|
|
|
static void re_node_set_remove_at (re_node_set *set, int idx) internal_function;
|
2002-10-12 08:34:26 +00:00
|
|
|
|
#define re_node_set_remove(set,id) \
|
|
|
|
|
(re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#define re_node_set_empty(p) ((p)->nelem = 0)
|
|
|
|
|
#define re_node_set_free(set) re_free ((set)->elems)
|
[BZ #605, BZ #611]
Update.
2004-12-13 Paolo Bonzini <bonzini@gnu.org>
Separate parsing and creation of the NFA. Avoided recursion on
the (very unbalanced) parse tree.
[BZ #611]
* posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest,
re_dfa_add_tree_node, mark_opt_subexp_iter): Removed.
(optimize_subexps, duplicate_tree, calc_first, calc_next,
mark_opt_subexp): Rewritten.
(preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes,
create_token_tree, free_tree, free_token): New.
(analyze): Accept a regex_t *. Invoke the passes via the preorder and
postorder generic visitors. Do not initialize the fields in the
re_dfa_t that represent the transitions.
(free_dfa_content): Use free_token.
(re_compile_internal): Analyze before UTF-8 optimizations. Do not
include optimization of subexpressions.
(create_initial_state): Fetch the DFA node index from the first node's
bin_tree_t *.
(optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION.
Return on COMPLEX_BRACKET.
(duplicate_node_closure): Fix comment.
(duplicate_node): Do not initialize the fields in the
re_dfa_t that represent the transitions.
(calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP.
(create_tree): Remove final argument. All callers adjusted. Rewritten
to use create_token_tree.
(parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp,
build_charclass_op): Use create_tree or create_token_tree instead
of re_dfa_add_tree_node.
(parse_dup_op): Likewise. Also free the tree using free_tree for
"<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent
to "a|". Adjust invocation of mark_opt_subexp.
(parse_sub_exp): Create a single SUBEXP node.
* posix/regex_internal.c (re_dfa_add_node): Remove last parameter,
always perform as if it was 1. Do not initialize OPT_SUBEXP and
DUPLICATED, and initialize the DFA fields representing the transitions.
* posix/regex_internal.h (re_dfa_add_node): Adjust prototype.
(re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens
section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP.
(bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and
NEXT into pointers to trees. Remove ECLOSURE.
2004-12-28 Paolo Bonzini <bonzini@gnu.org >
[BZ #605]
* posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes
that were already created.
* posix/regex_internal.c (re_dfa_add_node): Set accept_mb field
in the token if needed.
(create_ci_newstate, create_cd_newstate): Set accept_mb field
from the tokens' field.
* posix/regex_internal.h (re_token_t): Add accept_mb field.
(ACCEPT_MB_NODE): Removed.
* posix/regexec.c (proceed_next_node, transit_states_mb,
build_sifted_states, check_arrival_add_next_nodes): Use
accept_mb instead of ACCEPT_MB_NODE.
2005-01-26 22:42:49 +00:00
|
|
|
|
static int re_dfa_add_node (re_dfa_t *dfa, re_token_t token) internal_function;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
static re_dfastate_t *re_acquire_state (reg_errcode_t *err, re_dfa_t *dfa,
|
|
|
|
|
const re_node_set *nodes) internal_function;
|
|
|
|
|
static re_dfastate_t *re_acquire_state_context (reg_errcode_t *err,
|
|
|
|
|
re_dfa_t *dfa,
|
|
|
|
|
const re_node_set *nodes,
|
|
|
|
|
unsigned int context) internal_function;
|
|
|
|
|
static void free_state (re_dfastate_t *state) internal_function;
|
|
|
|
|
#endif
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
SB_CHAR,
|
|
|
|
|
MB_CHAR,
|
|
|
|
|
EQUIV_CLASS,
|
|
|
|
|
COLL_SYM,
|
|
|
|
|
CHAR_CLASS
|
|
|
|
|
} bracket_elem_type;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
bracket_elem_type type;
|
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
unsigned char ch;
|
2002-09-10 18:40:35 +00:00
|
|
|
|
unsigned char *name;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
wchar_t wch;
|
|
|
|
|
} opr;
|
|
|
|
|
} bracket_elem_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Inline functions for bitset operation. */
|
|
|
|
|
static inline void
|
2004-12-22 20:10:10 +00:00
|
|
|
|
bitset_not (bitset set)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int bitset_i;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
for (bitset_i = 0; bitset_i < BITSET_UINTS; ++bitset_i)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
set[bitset_i] = ~set[bitset_i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
2004-12-22 20:10:10 +00:00
|
|
|
|
bitset_merge (bitset dest, const bitset src)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int bitset_i;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
for (bitset_i = 0; bitset_i < BITSET_UINTS; ++bitset_i)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dest[bitset_i] |= src[bitset_i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
2004-12-22 20:10:10 +00:00
|
|
|
|
bitset_not_merge (bitset dest, const bitset src)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < BITSET_UINTS; ++i)
|
|
|
|
|
dest[i] |= ~src[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
bitset_mask (bitset dest, const bitset src)
|
2003-11-24 19:30:51 +00:00
|
|
|
|
{
|
|
|
|
|
int bitset_i;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
for (bitset_i = 0; bitset_i < BITSET_UINTS; ++bitset_i)
|
2003-11-24 19:30:51 +00:00
|
|
|
|
dest[bitset_i] &= src[bitset_i];
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#if defined RE_ENABLE_I18N && !defined RE_NO_INTERNAL_PROTOTYPES
|
2002-02-26 19:06:03 +00:00
|
|
|
|
/* Inline functions for re_string. */
|
|
|
|
|
static inline int
|
2004-12-22 20:10:10 +00:00
|
|
|
|
internal_function
|
2004-02-26 01:32:44 +00:00
|
|
|
|
re_string_char_size_at (const re_string_t *pstr, int idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int byte_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
|
|
|
|
if (pstr->mb_cur_max == 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return 1;
|
2003-11-11 06:58:52 +00:00
|
|
|
|
for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
if (pstr->wcs[idx + byte_idx] != WEOF)
|
|
|
|
|
break;
|
|
|
|
|
return byte_idx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline wint_t
|
2004-12-22 20:10:10 +00:00
|
|
|
|
internal_function
|
2004-02-26 01:32:44 +00:00
|
|
|
|
re_string_wchar_at (const re_string_t *pstr, int idx)
|
2002-02-26 19:06:03 +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 (pstr->mb_cur_max == 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return (wint_t) pstr->mbs[idx];
|
|
|
|
|
return (wint_t) pstr->wcs[idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2004-12-22 20:10:10 +00:00
|
|
|
|
internal_function
|
2004-02-26 01:32:44 +00:00
|
|
|
|
re_string_elem_size_at (const re_string_t *pstr, int idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#ifdef _LIBC
|
2002-09-10 18:40:35 +00:00
|
|
|
|
const unsigned char *p, *extra;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
const int32_t *table, *indirect;
|
|
|
|
|
int32_t tmp;
|
2004-12-22 20:10:10 +00:00
|
|
|
|
# include <locale/weight.h>
|
2002-02-26 19:06:03 +00:00
|
|
|
|
uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
|
|
|
|
|
|
|
|
|
|
if (nrules != 0)
|
|
|
|
|
{
|
|
|
|
|
table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
|
2002-09-10 18:40:35 +00:00
|
|
|
|
extra = (const unsigned char *)
|
2002-11-06 20:36:47 +00:00
|
|
|
|
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
|
|
|
|
|
_NL_COLLATE_INDIRECTMB);
|
|
|
|
|
p = pstr->mbs + idx;
|
2002-09-10 18:40:35 +00:00
|
|
|
|
tmp = findidx (&p);
|
2002-09-05 10:28:51 +00:00
|
|
|
|
return p - pstr->mbs - idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2004-12-22 20:10:10 +00:00
|
|
|
|
#endif /* _LIBC */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
|
|
|
|
#endif /* _REGEX_INTERNAL_H */
|