2002-02-26 19:06:03 +00:00
|
|
|
|
/* Extended regular expression matching and search library.
|
2018-01-01 00:32:25 +00:00
|
|
|
|
Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
2002-02-26 19:06:03 +00:00
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
|
License along with the GNU C Library; if not, see
|
2017-12-20 11:47:44 +00:00
|
|
|
|
<https://www.gnu.org/licenses/>. */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#include <langinfo.h>
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
#include <wctype.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2018-10-15 03:20:08 +00:00
|
|
|
|
#include <intprops.h>
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
|
|
|
|
#ifdef _LIBC
|
2015-09-08 21:11:03 +00:00
|
|
|
|
# include <libc-lock.h>
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# define lock_define(name) __libc_lock_define (, name)
|
|
|
|
|
# define lock_init(lock) (__libc_lock_init (lock), 0)
|
|
|
|
|
# define lock_fini(lock) ((void) 0)
|
|
|
|
|
# define lock_lock(lock) __libc_lock_lock (lock)
|
|
|
|
|
# define lock_unlock(lock) __libc_lock_unlock (lock)
|
|
|
|
|
#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
|
|
|
|
|
# include "glthread/lock.h"
|
|
|
|
|
/* Use gl_lock_define if empty macro arguments are known to work.
|
|
|
|
|
Otherwise, fall back on less-portable substitutes. */
|
|
|
|
|
# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
|
|
|
|
|
|| (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
|
|
|
|
|
# define lock_define(name) gl_lock_define (, name)
|
|
|
|
|
# elif USE_POSIX_THREADS
|
|
|
|
|
# define lock_define(name) pthread_mutex_t name;
|
|
|
|
|
# elif USE_PTH_THREADS
|
|
|
|
|
# define lock_define(name) pth_mutex_t name;
|
|
|
|
|
# elif USE_SOLARIS_THREADS
|
|
|
|
|
# define lock_define(name) mutex_t name;
|
|
|
|
|
# elif USE_WINDOWS_THREADS
|
|
|
|
|
# define lock_define(name) gl_lock_t name;
|
|
|
|
|
# else
|
|
|
|
|
# define lock_define(name)
|
|
|
|
|
# endif
|
|
|
|
|
# define lock_init(lock) glthread_lock_init (&(lock))
|
|
|
|
|
# define lock_fini(lock) glthread_lock_destroy (&(lock))
|
|
|
|
|
# define lock_lock(lock) glthread_lock_lock (&(lock))
|
|
|
|
|
# define lock_unlock(lock) glthread_lock_unlock (&(lock))
|
|
|
|
|
#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO
|
|
|
|
|
# include <pthread.h>
|
|
|
|
|
# define lock_define(name) pthread_mutex_t name;
|
|
|
|
|
# define lock_init(lock) pthread_mutex_init (&(lock), 0)
|
|
|
|
|
# define lock_fini(lock) pthread_mutex_destroy (&(lock))
|
|
|
|
|
# define lock_lock(lock) pthread_mutex_lock (&(lock))
|
|
|
|
|
# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
|
2005-05-06 23:31:06 +00:00
|
|
|
|
#else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# define lock_define(name)
|
|
|
|
|
# define lock_init(lock) 0
|
|
|
|
|
# define lock_fini(lock) ((void) 0)
|
|
|
|
|
/* The 'dfa' avoids an "unused variable 'dfa'" warning from GCC. */
|
|
|
|
|
# define lock_lock(lock) ((void) dfa)
|
|
|
|
|
# define lock_unlock(lock) ((void) 0)
|
2005-05-06 23:31:06 +00:00
|
|
|
|
#endif
|
2003-02-21 01:52:32 +00:00
|
|
|
|
|
|
|
|
|
/* In case that the system doesn't have isblank(). */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# 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/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) \
|
2012-05-23 20:38:10 +00:00
|
|
|
|
__dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# endif
|
|
|
|
|
#else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# undef gettext
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# define gettext(msgid) (msgid)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef gettext_noop
|
|
|
|
|
/* This define is so xgettext can find the internationalizable
|
|
|
|
|
strings. */
|
|
|
|
|
# define gettext_noop(String) String
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-08-01 09:00:43 +00:00
|
|
|
|
#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE) || _LIBC
|
2003-02-23 09:58:08 +00:00
|
|
|
|
# define RE_ENABLE_I18N
|
2003-02-21 01:52:32 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Number of ASCII characters. */
|
|
|
|
|
#define ASCII_CHARS 0x80
|
|
|
|
|
|
|
|
|
|
/* Number of single byte characters. */
|
|
|
|
|
#define SBC_MAX (UCHAR_MAX + 1)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
|
|
|
|
#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
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# undef __wctype
|
2018-08-23 00:46:32 +00:00
|
|
|
|
# undef __iswalnum
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# undef __iswctype
|
2018-08-23 00:46:32 +00:00
|
|
|
|
# undef __towlower
|
|
|
|
|
# undef __towupper
|
2002-02-26 19:06:03 +00:00
|
|
|
|
# define __wctype wctype
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# define __iswalnum iswalnum
|
2002-02-26 19:06:03 +00:00
|
|
|
|
# define __iswctype iswctype
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# define __towlower towlower
|
|
|
|
|
# define __towupper towupper
|
2002-02-26 19:06:03 +00:00
|
|
|
|
# define __btowc btowc
|
2009-01-08 00:23:09 +00:00
|
|
|
|
# define __mbrtowc mbrtowc
|
2003-02-21 01:52:32 +00:00
|
|
|
|
# define __wcrtomb wcrtomb
|
2004-11-03 20:27:19 +00:00
|
|
|
|
# define __regfree regfree
|
2002-04-26 20:52:02 +00:00
|
|
|
|
#endif /* not _LIBC */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#ifndef SSIZE_MAX
|
|
|
|
|
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* The type of indexes into strings. This is signed, not size_t,
|
|
|
|
|
since the API requires indexes to fit in regoff_t anyway, and using
|
|
|
|
|
signed integers makes the code a bit smaller and presumably faster.
|
|
|
|
|
The traditional GNU regex implementation uses int for indexes.
|
|
|
|
|
The POSIX-compatible implementation uses a possibly-wider type.
|
|
|
|
|
The name 'Idx' is three letters to minimize the hassle of
|
|
|
|
|
reindenting a lot of regex code that formerly used 'int'. */
|
|
|
|
|
typedef regoff_t Idx;
|
|
|
|
|
#ifdef _REGEX_LARGE_OFFSETS
|
|
|
|
|
# define IDX_MAX SSIZE_MAX
|
|
|
|
|
#else
|
|
|
|
|
# define IDX_MAX INT_MAX
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* A hash value, suitable for computing hash tables. */
|
|
|
|
|
typedef __re_size_t re_hashval_t;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
/* An integer used to represent a set of bits. It must be unsigned,
|
|
|
|
|
and must be at least as wide as unsigned int. */
|
|
|
|
|
typedef unsigned long int bitset_word_t;
|
|
|
|
|
/* All bits set in a bitset_word_t. */
|
|
|
|
|
#define BITSET_WORD_MAX ULONG_MAX
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
|
|
|
|
/* Number of bits in a bitset_word_t. For portability to hosts with
|
|
|
|
|
padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)';
|
|
|
|
|
instead, deduce it directly from BITSET_WORD_MAX. Avoid
|
|
|
|
|
greater-than-32-bit integers and unconditional shifts by more than
|
|
|
|
|
31 bits, as they're not portable. */
|
|
|
|
|
#if BITSET_WORD_MAX == 0xffffffffUL
|
|
|
|
|
# define BITSET_WORD_BITS 32
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 4 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 36
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 16 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 48
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 28 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 60
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 64
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 72
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 128
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1
|
|
|
|
|
# define BITSET_WORD_BITS 256
|
|
|
|
|
#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1
|
|
|
|
|
# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */
|
|
|
|
|
# if BITSET_WORD_BITS <= SBC_MAX
|
|
|
|
|
# error "Invalid SBC_MAX"
|
|
|
|
|
# endif
|
|
|
|
|
#else
|
|
|
|
|
# error "Add case for new bitset_word_t size"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Number of bitset_word_t values in a bitset_t. */
|
|
|
|
|
#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
|
|
|
|
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
typedef bitset_word_t bitset_t[BITSET_WORDS];
|
|
|
|
|
typedef bitset_word_t *re_bitset_ptr_t;
|
|
|
|
|
typedef const bitset_word_t *re_const_bitset_ptr_t;
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx alloc;
|
|
|
|
|
Idx nelem;
|
|
|
|
|
Idx *elems;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
} 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. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nmbchars;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
|
|
|
|
/* # of collating symbols. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx ncoll_syms;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
|
|
|
|
/* # of equivalence classes. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nequiv_classes;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
|
|
|
|
/* # of range expressions. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nranges;
|
2002-07-10 23:09:16 +00:00
|
|
|
|
|
|
|
|
|
/* # of character classes. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nchar_classes;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
} 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 */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx; /* for BACK_REF */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
re_context_type ctx_type; /* for ANCHOR */
|
|
|
|
|
} opr;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#if __GNUC__ >= 2 && !defined __STRICT_ANSI__
|
2002-07-10 23:09:16 +00:00
|
|
|
|
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;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *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]. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx raw_mbs_idx;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* The length of the valid characters in the buffers. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx 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. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx valid_raw_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 length of the buffers MBS and WCS. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx bufs_len;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* The index in MBS, which is updated by re_string_fetch_byte. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx 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. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx raw_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
|
|
|
|
/* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx 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. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx raw_stop;
|
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
|
|
|
|
/* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx stop;
|
2002-07-27 08:20:17 +00:00
|
|
|
|
|
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. */
|
2005-09-23 06:11:29 +00:00
|
|
|
|
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;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* true 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
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#ifndef _LIBC
|
|
|
|
|
# define IS_IN(libc) false
|
2007-08-26 01:35:19 +00:00
|
|
|
|
#endif
|
2017-12-20 11:47:44 +00:00
|
|
|
|
|
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))
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#if defined _LIBC || HAVE_ALLOCA
|
|
|
|
|
# include <alloca.h>
|
|
|
|
|
#endif
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
|
|
|
|
|
#ifndef _LIBC
|
|
|
|
|
# if HAVE_ALLOCA
|
|
|
|
|
/* The OS usually guarantees only one guard page at the bottom of the stack,
|
|
|
|
|
and a page size can be as small as 4096 bytes. So we cannot safely
|
|
|
|
|
allocate anything larger than 4096 bytes. Also care for the possibility
|
|
|
|
|
of a few compiler-allocated temporary stack slots. */
|
|
|
|
|
# define __libc_use_alloca(n) ((n) < 4032)
|
|
|
|
|
# else
|
|
|
|
|
/* alloca is implemented with malloc, so just use malloc. */
|
|
|
|
|
# define __libc_use_alloca(n) 0
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# undef alloca
|
|
|
|
|
# define alloca(n) malloc (n)
|
* posix/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* posix/regcomp.c (init_dfa): Don't initialize unused members.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (set_regs): Don't alloca with an unbounded size.
alloca modernization/simplification for regex.
* posix/regex.c: Remove portability cruft for alloca. This no longer
needs to be at the start of the file, and can be moved into
regex_internal.h and simplified.
* posix/regex_internal.h: Include <alloca.h>.
(__libc_use_alloca) [!defined _LIBC]: New macro.
* posix/regexec.c (build_trtable): Remove "#ifdef _LIBC",
since the code now works outside glibc.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/regex.h: Remove use of _RE_ARGS.
2005-08-25 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (find_recover_state): Change "err" to "*err".
2005-08-24 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (regerror): Pointer args are 'restrict',
as per POSIX.
* posix/regex.h (regerror): Likewise.
* manual/pattern.texi (POSIX Regexp Compilation): Likewise.
Similarly for regcomp and regexec. Also, first 2 args of regexec
and 2nd arg of regerror are const.
* posix/regex.c: Do not include <sys/types.h>, as POSIX no longer
requires this. (The code never needed it.)
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regexec.c (sift_states_bkref): re_node_set_insert returns
int, not reg_errcode_t.
* posix/regex_internal.c (calc_state_hash): Put 'inline' before type,
since some broken compilers warn about it otherwise.
* posix/regcomp.c (create_initial_state): Remove duplicate decl.
2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume
C89 or better. All uses removed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex.c: Prevent using C++ compilers.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (duplicate_node): Return new index, not an error
code, and let the caller return REG_ESPACE if out of space. This
removes an uninitialied-variable warning with GCC 4.0.1, and also
avoids taking the address of a local variable. All callers
changed.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* include/time.h (__strptime_internal): Rename parameter to avoid
bogus compiler warning.
2005-08-19 Jim Meyering <jim@meyering.net>
* posix/regexec.c (proceed_next_node): Redo local variables to
avoid GCC shadowing warnings.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Minor code rearrangement.
(re_acquire_state_context): Likewise.
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (re_string_realloc_buffers):
(re_node_set_insert, re_node_set_insert_last, re_dfa_add_node):
Rename local variables to avoid GCC shadowing warnings.
2005-07-08 Eric Blake <ebb9@byu.net>
Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not
wchar_t. Remove now-unnecessary cast.
(build_range_exp): Likewise.
2005-09-06 21:15:13 +00:00
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#ifdef _LIBC
|
|
|
|
|
# define MALLOC_0_IS_NONNULL 1
|
|
|
|
|
#elif !defined MALLOC_0_IS_NONNULL
|
|
|
|
|
# define MALLOC_0_IS_NONNULL 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
|
# define MAX(a,b) ((a) < (b) ? (b) : (a))
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef MIN
|
|
|
|
|
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#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
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* 'node_idx' is the index in dfa->nodes, if 'type' == 0.
|
|
|
|
|
Otherwise 'type' indicate the type of this node. */
|
|
|
|
|
Idx node_idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
};
|
|
|
|
|
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)
|
2015-06-05 20:04:47 +00:00
|
|
|
|
#define IS_WIDE_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_')
|
2002-11-13 04:00:16 +00:00
|
|
|
|
#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
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_hashval_t hash;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
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;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* If this state can accept "multi byte".
|
2002-02-26 19:06:03 +00:00
|
|
|
|
Note that we refer to multibyte characters, and multi character
|
2017-12-20 11:47:44 +00:00
|
|
|
|
collating elements as "multi byte". */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx num;
|
|
|
|
|
Idx 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
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx next_idx;
|
|
|
|
|
Idx alloc;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_dfastate_t **array;
|
|
|
|
|
} state_array_t;
|
|
|
|
|
|
|
|
|
|
/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node;
|
|
|
|
|
Idx str_idx; /* The position NODE match at. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx str_idx;
|
|
|
|
|
Idx node;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
state_array_t *path;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx alasts; /* Allocation size of LASTS. */
|
|
|
|
|
Idx nlasts; /* The number of LASTS. */
|
2002-11-27 23:00:16 +00:00
|
|
|
|
re_sub_match_last_t **lasts;
|
|
|
|
|
} re_sub_match_top_t;
|
|
|
|
|
|
2002-04-24 21:54:53 +00:00
|
|
|
|
struct re_backref_cache_entry
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx node;
|
|
|
|
|
Idx str_idx;
|
|
|
|
|
Idx subexp_from;
|
|
|
|
|
Idx 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)
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const re_dfa_t *const dfa;
|
2004-01-03 13:07:29 +00:00
|
|
|
|
#else
|
2005-09-07 16:15:23 +00:00
|
|
|
|
const 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. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx match_last;
|
|
|
|
|
Idx last_node;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* The state log used by the matcher. */
|
|
|
|
|
re_dfastate_t **state_log;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx state_log_top;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
/* Back reference cache. */
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nbkref_ents;
|
|
|
|
|
Idx abkref_ents;
|
2002-04-24 21:54:53 +00:00
|
|
|
|
struct re_backref_cache_entry *bkref_ents;
|
2002-09-28 05:28:44 +00:00
|
|
|
|
int max_mb_elem_len;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx nsub_tops;
|
|
|
|
|
Idx asub_tops;
|
2002-11-27 23:00:16 +00:00
|
|
|
|
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;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx last_node;
|
|
|
|
|
Idx 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
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx idx;
|
|
|
|
|
Idx node;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
regmatch_t *regs;
|
|
|
|
|
re_node_set eps_via_nodes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct re_fail_stack_t
|
|
|
|
|
{
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx num;
|
|
|
|
|
Idx alloc;
|
2002-09-30 22:01:05 +00:00
|
|
|
|
struct re_fail_stack_ent_t *stack;
|
|
|
|
|
};
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
struct re_dfa_t
|
|
|
|
|
{
|
|
|
|
|
re_token_t *nodes;
|
* posix/regex_internal.c (re_string_reconstruct): Avoid calling
mbrtowc for very simple UTF-8 case.
2005-09-01 Paul Eggert <eggert@cs.ucla.edu>
* posix/regex_internal.c (build_wcs_upper_buffer): Fix portability
bugs in int versus size_t comparisons.
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regex_internal.c (re_acquire_state): Make DFA pointer arg
a pointer-to-const.
(re_acquire_state_context): Likewise.
* posix/regex_internal.h: Adjust prototypes.
2005-08-31 Jim Meyering <jim@meyering.net>
* posix/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate,
register_state): Likewise.
* posix/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* posix/regexec.c (re_search_internal): Simplify update of
rm_so and rm_eo by replacing "if (A == B) A += C - B;"
with the equivalent of "if (A == B) A = C;".
2005-09-06 Ulrich Drepper <drepper@redhat.com>
* posix/regcomp.c (re_compile_internal): Change third parameter type
to size_t.
(init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't
overflow.
* posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc
and nodes_len to size_t.
* posix/regex_internal.c (re_dfa_add_node): Use size_t as type for
new_nodes_alloc. Check for overflow.
2005-08-31 Paul Eggert <eggert@cs.ucla.edu>
* posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char):
(optimize_subexps, lower_subexp):
Don't assume 1<<31 has defined behavior on hosts with 32-bit int,
since the signed shift might overflow. Use 1u<<31 instead.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain):
Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise.
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (optimize_subexps, lower_subexp):
Use CHAR_BIT rather than 8, for clarity.
* posix/regexec.c (check_dst_limits_calc_pos_1):
(check_subexp_matching_top): Likewise.
* posix/regcomp.c (init_dfa): Make table_size unsigned, so that we
don't have to worry about portability issues when shifting it left.
Remove no-longer-needed test for table_size > 0.
* posix/regcomp.c (parse_sub_exp): Do not shift more bits than there
are in a word, as the resulting behavior is undefined.
* posix/regexec.c (check_dst_limits_calc_pos_1): Likewise;
in one case, a <= should have been an <, and in another case the
whole test was missing.
* posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to
the standard name CHAR_BIT.
2005-09-07 01:15:33 +00:00
|
|
|
|
size_t nodes_alloc;
|
|
|
|
|
size_t nodes_len;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *nexts;
|
|
|
|
|
Idx *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
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* number of subexpressions 're_nsub' is in regex_t. */
|
|
|
|
|
re_hashval_t state_hash_mask;
|
|
|
|
|
Idx init_node;
|
|
|
|
|
Idx 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. */
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_word_t used_bkref_map;
|
|
|
|
|
bitset_word_t 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;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_t 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;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
Idx *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
|
2017-12-20 11:47:44 +00:00
|
|
|
|
lock_define (lock)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Functions for bitset_t operation. */
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
bitset_set (bitset_t set, Idx i)
|
|
|
|
|
{
|
|
|
|
|
set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
bitset_clear (bitset_t set, Idx i)
|
|
|
|
|
{
|
|
|
|
|
set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
|
bitset_contain (const bitset_t set, Idx i)
|
|
|
|
|
{
|
|
|
|
|
return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
bitset_empty (bitset_t set)
|
|
|
|
|
{
|
|
|
|
|
memset (set, '\0', sizeof (bitset_t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
bitset_set_all (bitset_t set)
|
|
|
|
|
{
|
|
|
|
|
memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
|
|
|
|
|
if (SBC_MAX % BITSET_WORD_BITS != 0)
|
|
|
|
|
set[BITSET_WORDS - 1] =
|
|
|
|
|
((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
bitset_copy (bitset_t dest, const bitset_t src)
|
|
|
|
|
{
|
|
|
|
|
memcpy (dest, src, sizeof (bitset_t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_not (bitset_t set)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int bitset_i;
|
2017-12-20 11:47:44 +00:00
|
|
|
|
for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
set[bitset_i] = ~set[bitset_i];
|
2017-12-20 11:47:44 +00:00
|
|
|
|
if (SBC_MAX % BITSET_WORD_BITS != 0)
|
|
|
|
|
set[BITSET_WORDS - 1] =
|
|
|
|
|
((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1)
|
|
|
|
|
& ~set[BITSET_WORDS - 1]);
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static inline void
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_merge (bitset_t dest, const bitset_t src)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
|
|
|
|
int bitset_i;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
dest[bitset_i] |= src[bitset_i];
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
static inline void
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
bitset_mask (bitset_t dest, const bitset_t src)
|
2003-11-24 19:30:51 +00:00
|
|
|
|
{
|
|
|
|
|
int bitset_i;
|
[BZ #1302]
2005-09-06 Paul Eggert <eggert@cs.ucla.edu>
Ulrich Drepper <drepper@redhat.com>
[BZ #1302]
Change bitset word type from unsigned int to unsigned long int,
as this has better performance on typical 64-bit hosts. Change
bitset type name to bitset_t.
* posix/regcomp.c (build_equiv_class, build_charclass):
(build_range_exp, build_collating_symbol):
Prefer bitset_t to re_bitset_ptr_t in prototypes, when the actual
argument is a bitset. This is merely a style issue, but it makes
it clearer that an entire array is expected.
(re_compile_fastmap_iter, init_dfa, init_word_char, optimize_subexps,
lower_subexp): Adjust for new bitset_t definition.
(lower_subexp, parse_bracket_exp, built_charclass_op): Likewise.
* posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain,
bitset_not, bitset_merge, bitset_set_all, bitset_mask): Likewise.
* posix/regexec.c (check_dst_limits_calc_pos_1,
check_subexp_matching_top, build_trtable, group_nodes_into_DFAstates):
Likewise.
* posix/regcomp.c (utf8_sb_map): Don't assume initializer
== 0xffffffff.
* posix/regex_internal.h (BITSET_WORD_BITS): Renamed from UINT_BITS.
All uses changed.
(BITSET_WORDS): Renamed from BITSET_UINTS. All uses changed.
(bitset_word_t): New type, replacing 'unsigned int' for bitset uses.
All uses changed.
(BITSET_WORD_MAX): New macro.
(bitset_set, bitset_clear, bitset_contain, bitset_empty,
(bitset_set_all, bitset_copy): Adjust for bitset_t change.
(bitset_empty, bitset_copy):
Prefer sizeof (bitset_t) to multiplying it out ourselves.
(bitset_not_merge): Remove; unused.
(bitset_contain): Return bool, not unsigned int with one bit on.
All callers changed.
* posix/regexec.c (build_trtable): Don't assume bitset_t has no
stricter alignment than re_node_set; do this by defining a new
internal type struct dests_alloc and using it to allocate memory.
2005-09-28 17:33:18 +00:00
|
|
|
|
for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
|
2003-11-24 19:30:51 +00:00
|
|
|
|
dest[bitset_i] &= src[bitset_i];
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-15 20:59:51 +00:00
|
|
|
|
#ifdef RE_ENABLE_I18N
|
2017-12-20 11:47:44 +00:00
|
|
|
|
/* Functions for re_string. */
|
2013-02-07 22:44:18 +00:00
|
|
|
|
static int
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute__ ((pure, unused))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_string_char_size_at (const re_string_t *pstr, Idx 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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-07 22:44:18 +00:00
|
|
|
|
static wint_t
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute__ ((pure, unused))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_string_wchar_at (const re_string_t *pstr, Idx 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];
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# ifdef _LIBC
|
|
|
|
|
# include <locale/weight.h>
|
|
|
|
|
# endif
|
2014-09-11 23:02:17 +00:00
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
static int
|
2017-08-31 16:25:55 +00:00
|
|
|
|
__attribute__ ((pure, unused))
|
2017-12-20 11:47:44 +00:00
|
|
|
|
re_string_elem_size_at (const re_string_t *pstr, Idx idx)
|
2002-02-26 19:06:03 +00:00
|
|
|
|
{
|
2017-12-20 11:47:44 +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;
|
|
|
|
|
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;
|
2014-09-11 23:02:17 +00:00
|
|
|
|
findidx (table, indirect, extra, &p, pstr->len - idx);
|
2002-09-05 10:28:51 +00:00
|
|
|
|
return p - pstr->mbs - idx;
|
2002-02-26 19:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2017-12-20 11:47:44 +00:00
|
|
|
|
# endif /* _LIBC */
|
2002-02-26 19:06:03 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* RE_ENABLE_I18N */
|
|
|
|
|
|
2017-12-20 11:47:44 +00:00
|
|
|
|
#ifndef FALLTHROUGH
|
|
|
|
|
# if __GNUC__ < 7
|
|
|
|
|
# define FALLTHROUGH ((void) 0)
|
|
|
|
|
# else
|
|
|
|
|
# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-02-26 19:06:03 +00:00
|
|
|
|
#endif /* _REGEX_INTERNAL_H */
|