mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-08 14:20:07 +00:00
Update.
* posix/regex_internal.h (re_token_type_t): Remove unused ALT, END_OF_RE_TOKEN_T and SUBEXP. Reorder values. Add OP_UTF8_PERIOD and EPSILON_BIT. (IS_EPSILON_NODE): Just test if EPSILON_BIT is set. (ACCEPT_MB_NODE): Return 1 for OP_UTF8_PERIOD as well. * posix/regex_internal.c (create_ci_newstate, create_cd_newstate): Handle OP_UTF8_PERIOD. (re_string_reconstruct): Set valid_len for single byte char searching with no translation and case sensitivity. * posix/regcomp.c (re_compile_fastmap_iter, calc_first): Handle OP_UTF8_PERIOD. (re_compile_internal): Don't call optimize_utf8 if preg->translate != NULL. (optimize_utf8): Remove BACK_SLASH case. Transform OP_PERIOD into OP_UTF8_PERIOD if the searching can be optimized. (parse_bracket_exp): Don't create SIMPLE_BRACKET if it doesn't have any bits set and COMPLEX_BRACKET is used. * posix/regexec.c (transit_state_mb): Fix comment typo. (group_nodes_into_DFAstates, check_node_accept): Handle OP_UTF8_PERIOD. (check_node_accept_bytes): Likewise. Reorder slightly so that re_string_char_size_at and re_string_elem_size_at are called only when needed. * posix/bug-regex20.c (BRE, ERE): Define. (tests): Use them to make lines shorter. Expect . to be optimized. Add lots of new tests. (main): Run (ATM just case sensitive) test with backwards searching as well. 2003-11-18 Jakub Jelinek <jakub@redhat.com>
This commit is contained in:
parent
5146ec9a2c
commit
ad7f28c29d
32
ChangeLog
32
ChangeLog
@ -1,3 +1,35 @@
|
||||
2003-11-18 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* posix/regex_internal.h (re_token_type_t): Remove unused ALT,
|
||||
END_OF_RE_TOKEN_T and SUBEXP. Reorder values. Add OP_UTF8_PERIOD
|
||||
and EPSILON_BIT.
|
||||
(IS_EPSILON_NODE): Just test if EPSILON_BIT is set.
|
||||
(ACCEPT_MB_NODE): Return 1 for OP_UTF8_PERIOD as well.
|
||||
* posix/regex_internal.c (create_ci_newstate, create_cd_newstate):
|
||||
Handle OP_UTF8_PERIOD.
|
||||
(re_string_reconstruct): Set valid_len for single byte char searching
|
||||
with no translation and case sensitivity.
|
||||
* posix/regcomp.c (re_compile_fastmap_iter, calc_first): Handle
|
||||
OP_UTF8_PERIOD.
|
||||
(re_compile_internal): Don't call optimize_utf8 if preg->translate
|
||||
!= NULL.
|
||||
(optimize_utf8): Remove BACK_SLASH case.
|
||||
Transform OP_PERIOD into OP_UTF8_PERIOD if the searching can be
|
||||
optimized.
|
||||
(parse_bracket_exp): Don't create SIMPLE_BRACKET if it doesn't have
|
||||
any bits set and COMPLEX_BRACKET is used.
|
||||
* posix/regexec.c (transit_state_mb): Fix comment typo.
|
||||
(group_nodes_into_DFAstates, check_node_accept): Handle
|
||||
OP_UTF8_PERIOD.
|
||||
(check_node_accept_bytes): Likewise. Reorder slightly so that
|
||||
re_string_char_size_at and re_string_elem_size_at are called
|
||||
only when needed.
|
||||
* posix/bug-regex20.c (BRE, ERE): Define.
|
||||
(tests): Use them to make lines shorter. Expect . to be
|
||||
optimized. Add lots of new tests.
|
||||
(main): Run (ATM just case sensitive) test with backwards searching
|
||||
as well.
|
||||
|
||||
2003-11-18 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* io/bug-ftw4.c: Include string.h.
|
||||
|
@ -29,6 +29,9 @@
|
||||
#define RE_NO_INTERNAL_PROTOTYPES 1
|
||||
#include "regex_internal.h"
|
||||
|
||||
#define BRE RE_SYNTAX_POSIX_BASIC
|
||||
#define ERE RE_SYNTAX_POSIX_EXTENDED
|
||||
|
||||
static struct
|
||||
{
|
||||
int syntax;
|
||||
@ -42,71 +45,145 @@ static struct
|
||||
\xc3\xb6 LATIN SMALL LETTER O WITH DIAERESIS
|
||||
\xe2\x80\x94 EM DASH */
|
||||
/* Should be optimized. */
|
||||
{RE_SYNTAX_POSIX_BASIC, "foo", "b\xc3\xa4rfoob\xc3\xa4z", 4, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "b\xc3\xa4z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "b\xc3\xa4*z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "b\xc3\xa4*z", "b\xc3\xa4rfoobz", 7, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "b\xc3\xa4\\+z",
|
||||
"b\xc3\xa4rfoob\xc3\xa4\xc3\xa4z", 7, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "b\xc3\xa4\\?z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "b\xc3\xa4\\{1,2\\}z",
|
||||
"b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\|xy*z$", "\xc3\xb6xyyz", 2, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\\\y\\{6\\}z\\+", "x\\yyyyyyzz\xc3\xb6", 0, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\\\y\\{2,36\\}z\\+", "x\\yzz\xc3\xb6", -1, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\\\y\\{,3\\}z\\+", "x\\yyyzz\xc3\xb6", 0, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\|x\xc3\xa4*z$",
|
||||
"\xc3\xb6x\xc3\xa4\xc3\xa4z", 2, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\\\\xc3\x84\\{6\\}z\\+",
|
||||
{BRE, "foo", "b\xc3\xa4rfoob\xc3\xa4z", 4, 1},
|
||||
{BRE, "b\xc3\xa4z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{BRE, "b\xc3\xa4*z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{BRE, "b\xc3\xa4*z", "b\xc3\xa4rfoobz", 7, 1},
|
||||
{BRE, "b\xc3\xa4\\+z", "b\xc3\xa4rfoob\xc3\xa4\xc3\xa4z", 7, 1},
|
||||
{BRE, "b\xc3\xa4\\?z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{BRE, "b\xc3\xa4\\{1,2\\}z", "b\xc3\xa4rfoob\xc3\xa4z", 7, 1},
|
||||
{BRE, "^x\\|xy*z$", "\xc3\xb6xyyz", 2, 1},
|
||||
{BRE, "^x\\\\y\\{6\\}z\\+", "x\\yyyyyyzz\xc3\xb6", 0, 1},
|
||||
{BRE, "^x\\\\y\\{2,36\\}z\\+", "x\\yzz\xc3\xb6", -1, 1},
|
||||
{BRE, "^x\\\\y\\{,3\\}z\\+", "x\\yyyzz\xc3\xb6", 0, 1},
|
||||
{BRE, "^x\\|x\xc3\xa4*z$", "\xc3\xb6x\xc3\xa4\xc3\xa4z", 2, 1},
|
||||
{BRE, "^x\\\\\xc3\x84\\{6\\}z\\+",
|
||||
"x\\\xc3\x84\xc3\x84\xc3\x84\xc3\x84\xc3\x84\xc3\x84zz\xc3\xb6", 0, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\\\\xc3\x84\\{2,36\\}z\\+",
|
||||
"x\\\xc3\x84zz\xc3\xb6", -1, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "^x\\\\\xc3\x84\\{,3\\}z\\+",
|
||||
{BRE, "^x\\\\\xc3\x84\\{2,36\\}z\\+", "x\\\xc3\x84zz\xc3\xb6", -1, 1},
|
||||
{BRE, "^x\\\\\xc3\x84\\{,3\\}z\\+",
|
||||
"x\\\xc3\x84\xc3\x84\xc3\x84zz\xc3\xb6", 0, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[C]y", "axCy", 1, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[ABC]y", "axCy", 1, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\`x\\|z\\'", "x\xe2\x80\x94", 0, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\(xy\\)z\\1a\\1", "\xe2\x80\x94xyzxyaxy\xc3\x84", 3, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "xy\\?z", "\xc3\x84xz\xc3\xb6", 2, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\`\xc3\x84\\|z\\'", "\xc3\x84\xe2\x80\x94", 0, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\(x\xc3\x84\\)z\\1\x61\\1",
|
||||
{BRE, "x[C]y", "axCy", 1, 1},
|
||||
{BRE, "x[ABC]y", "axCy", 1, 1},
|
||||
{BRE, "\\`x\\|z\\'", "x\xe2\x80\x94", 0, 1},
|
||||
{BRE, "\\(xy\\)z\\1a\\1", "\xe2\x80\x94xyzxyaxy\xc3\x84", 3, 1},
|
||||
{BRE, "xy\\?z", "\xc3\x84xz\xc3\xb6", 2, 1},
|
||||
{BRE, "\\`\xc3\x84\\|z\\'", "\xc3\x84\xe2\x80\x94", 0, 1},
|
||||
{BRE, "\\(x\xc3\x84\\)z\\1\x61\\1",
|
||||
"\xe2\x80\x94x\xc3\x84zx\xc3\x84\x61x\xc3\x84\xc3\x96", 3, 1},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x\xc3\x96\\?z", "\xc3\x84xz\xc3\xb6", 2, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "foo", "b\xc3\xa4rfoob\xc3\xa4z", 4, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "^x|xy*z$", "\xc3\xb6xyyz", 2, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "^x\\\\y{6}z+", "x\\yyyyyyzz\xc3\xb6", 0, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "^x\\\\y{2,36}z+", "x\\yzz\xc3\xb6", -1, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "^x\\\\y{,3}z+", "x\\yyyzz\xc3\xb6", 0, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[C]y", "axCy", 1, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[ABC]y", "axCy", 1, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "\\`x|z\\'", "x\xe2\x80\x94", 0, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "(xy)z\\1a\\1", "\xe2\x80\x94xyzxyaxy\xc3\x84", 3, 1},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "xy?z", "\xc3\x84xz\xc3\xb6", 2, 1},
|
||||
{BRE, "x\xc3\x96\\?z", "\xc3\x84xz\xc3\xb6", 2, 1},
|
||||
{BRE, "x.y", "ax\xe2\x80\x94yz", 1, 1},
|
||||
{BRE, "x.*z", "\xc3\x84xz", 2, 1},
|
||||
{BRE, "x.*z", "\xc3\x84x\xe2\x80\x94z", 2, 1},
|
||||
{BRE, "x.*z", "\xc3\x84x\xe2\x80\x94y\xf1\x90\x80\x90z", 2, 1},
|
||||
{BRE, "x.*z", "\xc3\x84x\xe2\x80\x94\xc3\x94\xf1\x90\x80\x90z", 2, 1},
|
||||
{BRE, "x.\\?z", "axz", 1, 1},
|
||||
{BRE, "x.\\?z", "axyz", 1, 1},
|
||||
{BRE, "x.\\?z", "ax\xc3\x84z", 1, 1},
|
||||
{BRE, "x.\\?z", "ax\xe2\x80\x94z", 1, 1},
|
||||
{BRE, "x.\\?z", "ax\xf0\x9d\x80\x80z", 1, 1},
|
||||
{BRE, "x.\\?z", "ax\xf9\x81\x82\x83\x84z", 1, 1},
|
||||
{BRE, "x.\\?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfz", 1, 1},
|
||||
{BRE, ".", "y", 0, 1},
|
||||
{BRE, ".", "\xc3\x84", 0, 1},
|
||||
{BRE, ".", "\xe2\x80\x94", 0, 1},
|
||||
{BRE, ".", "\xf0\x9d\x80\x80", 0, 1},
|
||||
{BRE, ".", "\xf9\x81\x82\x83\x84", 0, 1},
|
||||
{BRE, ".", "\xfd\xbf\xbf\xbf\xbf\xbf", 0, 1},
|
||||
{BRE, "x.\\?z", "axyyz", -1, 1},
|
||||
{BRE, "x.\\?z", "ax\xc3\x84\xc3\x96z", -1, 1},
|
||||
{BRE, "x.\\?z", "ax\xe2\x80\x94\xc3\xa4z", -1, 1},
|
||||
{BRE, "x.\\?z", "ax\xf0\x9d\x80\x80yz", -1, 1},
|
||||
{BRE, "x.\\?z", "ax\xf9\x81\x82\x83\x84\xf0\xf9\x80\x81z", -1, 1},
|
||||
{BRE, "x.\\?z", "ax\xfd\xbf\xbf\xbf\xbf\xbf\xc3\x96z", -1, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94xz", -1, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94xyz", 3, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94x\xc3\x84y\xe2\x80\x94z", 3, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94x.~\xe2\x80\x94\xf9\x81\x82\x83\x84z", 3, 1},
|
||||
{BRE, "x.\\+z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94xz", -1, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xc3\x96y\xc3\xa4z", -1, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94xyz", 3, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xc3\x84\xe2\x80\x94z", 3, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x~\xe2\x80\x94z", 3, 1},
|
||||
{BRE, "x.\\{1,2\\}z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
|
||||
{BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "axz", 1, 1},
|
||||
{BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfwz", 1, 1},
|
||||
{BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "ax\xc3\x86z", 1, 1},
|
||||
{BRE, "x\\(.w\\|\xc3\x86\\)\\?z", "ax\xe2\x80\x96wz", 1, 1},
|
||||
{ERE, "foo", "b\xc3\xa4rfoob\xc3\xa4z", 4, 1},
|
||||
{ERE, "^x|xy*z$", "\xc3\xb6xyyz", 2, 1},
|
||||
{ERE, "^x\\\\y{6}z+", "x\\yyyyyyzz\xc3\xb6", 0, 1},
|
||||
{ERE, "^x\\\\y{2,36}z+", "x\\yzz\xc3\xb6", -1, 1},
|
||||
{ERE, "^x\\\\y{,3}z+", "x\\yyyzz\xc3\xb6", 0, 1},
|
||||
{ERE, "x[C]y", "axCy", 1, 1},
|
||||
{ERE, "x[ABC]y", "axCy", 1, 1},
|
||||
{ERE, "\\`x|z\\'", "x\xe2\x80\x94", 0, 1},
|
||||
{ERE, "(xy)z\\1a\\1", "\xe2\x80\x94xyzxyaxy\xc3\x84", 3, 1},
|
||||
{ERE, "xy?z", "\xc3\x84xz\xc3\xb6", 2, 1},
|
||||
{ERE, "x.y", "ax\xe2\x80\x94yz", 1, 1},
|
||||
{ERE, "x.*z", "\xc3\x84xz", 2, 1},
|
||||
{ERE, "x.*z", "\xc3\x84x\xe2\x80\x94z", 2, 1},
|
||||
{ERE, "x.*z", "\xc3\x84x\xe2\x80\x94y\xf1\x90\x80\x90z", 2, 1},
|
||||
{ERE, "x.*z", "\xc3\x84x\xe2\x80\x94\xc3\x94\xf1\x90\x80\x90z", 2, 1},
|
||||
{ERE, "x.?z", "axz", 1, 1},
|
||||
{ERE, "x.?z", "axyz", 1, 1},
|
||||
{ERE, "x.?z", "ax\xc3\x84z", 1, 1},
|
||||
{ERE, "x.?z", "ax\xe2\x80\x94z", 1, 1},
|
||||
{ERE, "x.?z", "ax\xf0\x9d\x80\x80z", 1, 1},
|
||||
{ERE, "x.?z", "ax\xf9\x81\x82\x83\x84z", 1, 1},
|
||||
{ERE, "x.?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfz", 1, 1},
|
||||
{ERE, "x.?z", "axyyz", -1, 1},
|
||||
{ERE, "x.?z", "ax\xc3\x84\xc3\x96z", -1, 1},
|
||||
{ERE, "x.?z", "ax\xe2\x80\x94\xc3\xa4z", -1, 1},
|
||||
{ERE, "x.?z", "ax\xf0\x9d\x80\x80yz", -1, 1},
|
||||
{ERE, "x.?z", "ax\xf9\x81\x82\x83\x84\xf0\xf9\x80\x81z", -1, 1},
|
||||
{ERE, "x.?z", "ax\xfd\xbf\xbf\xbf\xbf\xbf\xc3\x96z", -1, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94xz", -1, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94xyz", 3, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94x\xc3\x84y\xe2\x80\x94z", 3, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94x.~\xe2\x80\x94\xf9\x81\x82\x83\x84z", 3, 1},
|
||||
{ERE, "x.+z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94xz", -1, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94x\xc3\x96y\xc3\xa4z", -1, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94xyz", 3, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94x\xc3\x84\xe2\x80\x94z", 3, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94x\xe2\x80\x94z", 3, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94x\xf0\x9d\x80\x80\xc3\x84z", 3, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94x~\xe2\x80\x94z", 3, 1},
|
||||
{ERE, "x.{1,2}z", "\xe2\x80\x94x\xfd\xbf\xbf\xbf\xbf\xbfz", 3, 1},
|
||||
{ERE, "x(.w|\xc3\x86)?z", "axz", 1, 1},
|
||||
{ERE, "x(.w|\xc3\x86)?z", "ax\xfd\xbf\xbf\xbf\xbf\xbfwz", 1, 1},
|
||||
{ERE, "x(.w|\xc3\x86)?z", "ax\xc3\x86z", 1, 1},
|
||||
{ERE, "x(.w|\xc3\x86)?z", "ax\xe2\x80\x96wz", 1, 1},
|
||||
/* Should not be optimized. */
|
||||
{RE_SYNTAX_POSIX_BASIC, "x.y", "ax\xe2\x80\x94yz", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[\xc3\x84\xc3\xa4]y", "ax\xc3\xa4y", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[A-Z,]y", "axCy", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[^y]z", "ax\xe2\x80\x94z", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[[:alnum:]]z", "ax\xc3\x96z", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[[=A=]]z", "axAz", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x[[=\xc3\x84=]]z", "ax\xc3\x84z", 1, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\<g", "\xe2\x80\x94g", 3, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\bg\\b", "\xe2\x80\x94g", 3, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "\\Bg\\B", "\xc3\xa4g\xc3\xa4", 2, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "a\\wz", "a\xc3\x84z", 0, 0},
|
||||
{RE_SYNTAX_POSIX_BASIC, "x\\Wz", "\xc3\x96x\xe2\x80\x94z", 2, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x.y", "ax\xe2\x80\x94yz", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[\xc3\x84\xc3\xa4]y", "ax\xc3\xa4y", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[A-Z,]y", "axCy", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[^y]z", "ax\xe2\x80\x94z", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[[:alnum:]]z", "ax\xc3\x96z", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[[=A=]]z", "axAz", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x[[=\xc3\x84=]]z", "ax\xc3\x84z", 1, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "\\<g", "\xe2\x80\x94g", 3, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "\\bg\\b", "\xe2\x80\x94g", 3, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "\\Bg\\B", "\xc3\xa4g\xc3\xa4", 2, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "a\\wz", "a\xc3\x84z", 0, 0},
|
||||
{RE_SYNTAX_POSIX_EXTENDED, "x\\Wz", "\xc3\x96x\xe2\x80\x94z", 2, 0},
|
||||
{BRE, "x[\xc3\x84\xc3\xa4]y", "ax\xc3\xa4y", 1, 0},
|
||||
{BRE, "x[A-Z,]y", "axCy", 1, 0},
|
||||
{BRE, "x[^y]z", "ax\xe2\x80\x94z", 1, 0},
|
||||
{BRE, "x[[:alnum:]]z", "ax\xc3\x96z", 1, 0},
|
||||
{BRE, "x[[=A=]]z", "axAz", 1, 0},
|
||||
{BRE, "x[[=\xc3\x84=]]z", "ax\xc3\x84z", 1, 0},
|
||||
{BRE, "\\<g", "\xe2\x80\x94g", 3, 0},
|
||||
{BRE, "\\bg\\b", "\xe2\x80\x94g", 3, 0},
|
||||
{BRE, "\\Bg\\B", "\xc3\xa4g\xc3\xa4", 2, 0},
|
||||
{BRE, "a\\wz", "a\xc3\x84z", 0, 0},
|
||||
{BRE, "x\\Wz", "\xc3\x96x\xe2\x80\x94z", 2, 0},
|
||||
{ERE, "x[\xc3\x84\xc3\xa4]y", "ax\xc3\xa4y", 1, 0},
|
||||
{ERE, "x[A-Z,]y", "axCy", 1, 0},
|
||||
{ERE, "x[^y]z", "ax\xe2\x80\x94z", 1, 0},
|
||||
{ERE, "x[[:alnum:]]z", "ax\xc3\x96z", 1, 0},
|
||||
{ERE, "x[[=A=]]z", "axAz", 1, 0},
|
||||
{ERE, "x[[=\xc3\x84=]]z", "ax\xc3\x84z", 1, 0},
|
||||
{ERE, "\\<g", "\xe2\x80\x94g", 3, 0},
|
||||
{ERE, "\\bg\\b", "\xe2\x80\x94g", 3, 0},
|
||||
{ERE, "\\Bg\\B", "\xc3\xa4g\xc3\xa4", 2, 0},
|
||||
{ERE, "a\\wz", "a\xc3\x84z", 0, 0},
|
||||
{ERE, "x\\Wz", "\xc3\x96x\xe2\x80\x94z", 2, 0},
|
||||
};
|
||||
|
||||
int
|
||||
@ -144,8 +221,8 @@ main (void)
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
res = re_search (®buf, tests[i].string, strlen (tests[i].string), 0,
|
||||
strlen (tests[i].string), NULL);
|
||||
int str_len = strlen (tests[i].string);
|
||||
res = re_search (®buf, tests[i].string, str_len, 0, str_len, NULL);
|
||||
if (res != tests[i].res)
|
||||
{
|
||||
printf ("re_search %zd failed: %d\n", i, res);
|
||||
@ -153,6 +230,16 @@ main (void)
|
||||
regfree (®buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
res = re_search (®buf, tests[i].string, str_len, str_len, -str_len,
|
||||
NULL);
|
||||
if (res != tests[i].res)
|
||||
{
|
||||
printf ("backward re_search %zd failed: %d\n", i, res);
|
||||
ret = 1;
|
||||
regfree (®buf);
|
||||
continue;
|
||||
}
|
||||
regfree (®buf);
|
||||
|
||||
re_set_syntax (tests[i].syntax | RE_ICASE);
|
||||
@ -175,15 +262,25 @@ main (void)
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
res = re_search (®buf, tests[i].string, strlen (tests[i].string), 0,
|
||||
strlen (tests[i].string), NULL);
|
||||
res = re_search (®buf, tests[i].string, str_len, 0, str_len, NULL);
|
||||
if (res != tests[i].res)
|
||||
{
|
||||
printf ("re_search %zd failed: %d\n", i, res);
|
||||
printf ("ICASE re_search %zd failed: %d\n", i, res);
|
||||
ret = 1;
|
||||
regfree (®buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX: This causes regex segfault. Disable for now.
|
||||
res = re_search (®buf, tests[i].string, str_len, str_len, -str_len,
|
||||
NULL);
|
||||
if (res != tests[i].res)
|
||||
{
|
||||
printf ("ICASE backward re_search %zd failed: %d\n", i, res);
|
||||
ret = 1;
|
||||
regfree (®buf);
|
||||
continue;
|
||||
} */
|
||||
regfree (®buf);
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,8 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
|
||||
}
|
||||
}
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
else if (type == END_OF_RE || type == OP_PERIOD)
|
||||
else if (type == END_OF_RE || type == OP_PERIOD
|
||||
|| type == OP_UTF8_PERIOD)
|
||||
{
|
||||
memset (fastmap, '\1', sizeof (char) * SBC_MAX);
|
||||
if (type == END_OF_RE)
|
||||
@ -765,7 +766,7 @@ re_compile_internal (preg, pattern, length, syntax)
|
||||
|
||||
#ifdef RE_ENABLE_I18N
|
||||
/* If possible, do searching in single byte encoding to speed things up. */
|
||||
if (dfa->is_utf8 && !(syntax & RE_ICASE))
|
||||
if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
|
||||
optimize_utf8 (dfa);
|
||||
#endif
|
||||
|
||||
@ -965,7 +966,7 @@ static void
|
||||
optimize_utf8 (dfa)
|
||||
re_dfa_t *dfa;
|
||||
{
|
||||
int node, i, mb_chars = 0;
|
||||
int node, i, mb_chars = 0, has_period = 0;
|
||||
|
||||
for (node = 0; node < dfa->nodes_len; ++node)
|
||||
switch (dfa->nodes[node].type)
|
||||
@ -987,10 +988,12 @@ optimize_utf8 (dfa)
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case OP_PERIOD:
|
||||
has_period = 1;
|
||||
break;
|
||||
case OP_BACK_REF:
|
||||
case OP_ALT:
|
||||
case END_OF_RE:
|
||||
case BACK_SLASH:
|
||||
case OP_DUP_ASTERISK:
|
||||
case OP_DUP_QUESTION:
|
||||
case OP_DUP_PLUS:
|
||||
@ -1007,16 +1010,20 @@ optimize_utf8 (dfa)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mb_chars)
|
||||
if (mb_chars || has_period)
|
||||
for (node = 0; node < dfa->nodes_len; ++node)
|
||||
if (dfa->nodes[node].type == CHARACTER
|
||||
&& dfa->nodes[node].opr.c >= 0x80)
|
||||
dfa->nodes[node].mb_partial = 0;
|
||||
{
|
||||
if (dfa->nodes[node].type == CHARACTER
|
||||
&& dfa->nodes[node].opr.c >= 0x80)
|
||||
dfa->nodes[node].mb_partial = 0;
|
||||
else if (dfa->nodes[node].type == OP_PERIOD)
|
||||
dfa->nodes[node].type = OP_UTF8_PERIOD;
|
||||
}
|
||||
|
||||
/* The search can be in single byte locale. */
|
||||
dfa->mb_cur_max = 1;
|
||||
dfa->is_utf8 = 0;
|
||||
dfa->has_mb_node = dfa->nbackref > 0;
|
||||
dfa->has_mb_node = dfa->nbackref > 0 || has_period;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1124,6 +1131,7 @@ calc_first (dfa, node)
|
||||
case OP_DUP_ASTERISK:
|
||||
case OP_DUP_QUESTION:
|
||||
#ifdef RE_ENABLE_I18N
|
||||
case OP_UTF8_PERIOD:
|
||||
case COMPLEX_BRACKET:
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
case SIMPLE_BRACKET:
|
||||
@ -3159,16 +3167,29 @@ parse_bracket_exp (regexp, dfa, token, syntax, err)
|
||||
{
|
||||
re_token_t alt_token;
|
||||
bin_tree_t *mbc_tree;
|
||||
int sbc_idx;
|
||||
/* Build a tree for complex bracket. */
|
||||
dfa->has_mb_node = 1;
|
||||
dfa->has_plural_match = 1;
|
||||
for (sbc_idx = 0; sbc_idx < BITSET_UINTS; ++sbc_idx)
|
||||
if (sbcset[sbc_idx])
|
||||
break;
|
||||
/* If there are no bits set in sbcset, there is no point
|
||||
of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */
|
||||
if (sbc_idx == BITSET_UINTS)
|
||||
{
|
||||
re_free (sbcset);
|
||||
dfa->nodes[new_idx].type = COMPLEX_BRACKET;
|
||||
dfa->nodes[new_idx].opr.mbcset = mbcset;
|
||||
return work_tree;
|
||||
}
|
||||
br_token.type = COMPLEX_BRACKET;
|
||||
br_token.opr.mbcset = mbcset;
|
||||
dfa->has_mb_node = 1;
|
||||
new_idx = re_dfa_add_node (dfa, br_token, 0);
|
||||
mbc_tree = create_tree (NULL, NULL, 0, new_idx);
|
||||
if (BE (new_idx == -1 || mbc_tree == NULL, 0))
|
||||
goto parse_bracket_exp_espace;
|
||||
/* Then join them by ALT node. */
|
||||
dfa->has_plural_match = 1;
|
||||
alt_token.type = OP_ALT;
|
||||
new_idx = re_dfa_add_node (dfa, alt_token, 0);
|
||||
work_tree = create_tree (work_tree, mbc_tree, 0, new_idx);
|
||||
|
@ -581,6 +581,8 @@ re_string_reconstruct (pstr, idx, eflags, newline)
|
||||
build_upper_buffer (pstr);
|
||||
else if (pstr->trans != NULL)
|
||||
re_string_translate_buffer (pstr);
|
||||
else
|
||||
pstr->valid_len = pstr->len;
|
||||
}
|
||||
pstr->cur_idx = 0;
|
||||
|
||||
@ -1257,6 +1259,7 @@ create_ci_newstate (dfa, nodes, hash)
|
||||
newstate->halt = 1;
|
||||
#ifdef RE_ENABLE_I18N
|
||||
else if (type == COMPLEX_BRACKET
|
||||
|| type == OP_UTF8_PERIOD
|
||||
|| (type == OP_PERIOD && dfa->mb_cur_max > 1))
|
||||
newstate->accept_mb = 1;
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
@ -1308,6 +1311,7 @@ create_cd_newstate (dfa, nodes, context, hash)
|
||||
newstate->halt = 1;
|
||||
#ifdef RE_ENABLE_I18N
|
||||
else if (type == COMPLEX_BRACKET
|
||||
|| type == OP_UTF8_PERIOD
|
||||
|| (type == OP_PERIOD && dfa->mb_cur_max > 1))
|
||||
newstate->accept_mb = 1;
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
|
@ -167,8 +167,31 @@ typedef enum
|
||||
{
|
||||
NON_TYPE = 0,
|
||||
|
||||
/* 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 */
|
||||
|
||||
EPSILON_BIT = 8,
|
||||
OP_OPEN_SUBEXP = EPSILON_BIT | 0,
|
||||
OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
|
||||
OP_ALT = EPSILON_BIT | 2,
|
||||
OP_DUP_ASTERISK = EPSILON_BIT | 3,
|
||||
OP_DUP_PLUS = EPSILON_BIT | 4,
|
||||
OP_DUP_QUESTION = EPSILON_BIT | 5,
|
||||
ANCHOR = EPSILON_BIT | 6,
|
||||
|
||||
/* Tree type, these are used only by tree. */
|
||||
CONCAT = 16,
|
||||
|
||||
/* Token type, these are used only by token. */
|
||||
OP_OPEN_BRACKET,
|
||||
OP_OPEN_BRACKET = 17,
|
||||
OP_CLOSE_BRACKET,
|
||||
OP_CHARSET_RANGE,
|
||||
OP_OPEN_DUP_NUM,
|
||||
@ -184,32 +207,8 @@ typedef enum
|
||||
OP_NOTWORD,
|
||||
OP_SPACE,
|
||||
OP_NOTSPACE,
|
||||
BACK_SLASH,
|
||||
BACK_SLASH
|
||||
|
||||
/* Tree type, these are used only by tree. */
|
||||
CONCAT,
|
||||
ALT,
|
||||
SUBEXP,
|
||||
SIMPLE_BRACKET,
|
||||
#ifdef RE_ENABLE_I18N
|
||||
COMPLEX_BRACKET,
|
||||
#endif /* RE_ENABLE_I18N */
|
||||
|
||||
/* Node type, These are used by token, node, tree. */
|
||||
OP_OPEN_SUBEXP,
|
||||
OP_CLOSE_SUBEXP,
|
||||
OP_PERIOD,
|
||||
CHARACTER,
|
||||
END_OF_RE,
|
||||
OP_ALT,
|
||||
OP_DUP_ASTERISK,
|
||||
OP_DUP_PLUS,
|
||||
OP_DUP_QUESTION,
|
||||
OP_BACK_REF,
|
||||
ANCHOR,
|
||||
|
||||
/* Dummy marker. */
|
||||
END_OF_RE_TOKEN_T
|
||||
} re_token_type_t;
|
||||
|
||||
#ifdef RE_ENABLE_I18N
|
||||
@ -284,13 +283,9 @@ typedef struct
|
||||
#endif
|
||||
} re_token_t;
|
||||
|
||||
#define IS_EPSILON_NODE(type) \
|
||||
((type) == OP_ALT || (type) == OP_DUP_ASTERISK || (type) == OP_DUP_PLUS \
|
||||
|| (type) == OP_DUP_QUESTION || (type) == ANCHOR \
|
||||
|| (type) == OP_OPEN_SUBEXP || (type) == OP_CLOSE_SUBEXP)
|
||||
|
||||
#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
|
||||
#define ACCEPT_MB_NODE(type) \
|
||||
((type) == COMPLEX_BRACKET || (type) == OP_PERIOD)
|
||||
((type) >= OP_PERIOD && (type) <= OP_UTF8_PERIOD)
|
||||
|
||||
struct re_string_t
|
||||
{
|
||||
|
104
posix/regexec.c
104
posix/regexec.c
@ -2339,7 +2339,7 @@ transit_state_mb (preg, pstate, mctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* How many bytes the node can accepts? */
|
||||
/* How many bytes the node can accept? */
|
||||
if (ACCEPT_MB_NODE (dfa->nodes[cur_node_idx].type))
|
||||
naccepted = check_node_accept_bytes (preg, cur_node_idx, mctx->input,
|
||||
re_string_cur_idx (mctx->input));
|
||||
@ -3366,6 +3366,14 @@ group_nodes_into_DFAstates (preg, state, dests_node, dests_ch)
|
||||
if (preg->syntax & RE_DOT_NOT_NULL)
|
||||
bitset_clear (accepts, '\0');
|
||||
}
|
||||
else if (type == OP_UTF8_PERIOD)
|
||||
{
|
||||
memset (accepts, 255, sizeof (unsigned int) * BITSET_UINTS / 2);
|
||||
if (!(preg->syntax & RE_DOT_NEWLINE))
|
||||
bitset_clear (accepts, '\n');
|
||||
if (preg->syntax & RE_DOT_NOT_NULL)
|
||||
bitset_clear (accepts, '\0');
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
@ -3480,13 +3488,67 @@ check_node_accept_bytes (preg, node_idx, input, str_idx)
|
||||
{
|
||||
const re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
|
||||
const re_token_t *node = dfa->nodes + node_idx;
|
||||
int elem_len = re_string_elem_size_at (input, str_idx);
|
||||
int char_len = re_string_char_size_at (input, str_idx);
|
||||
int char_len, elem_len;
|
||||
int i;
|
||||
if (elem_len <= 1 && char_len <= 1)
|
||||
return 0;
|
||||
|
||||
if (BE (node->type == OP_UTF8_PERIOD, 0))
|
||||
{
|
||||
unsigned char c = re_string_byte_at (input, str_idx), d;
|
||||
if (BE (c < 0xc2, 1))
|
||||
return 0;
|
||||
|
||||
if (str_idx + 2 > input->len)
|
||||
return 0;
|
||||
|
||||
d = re_string_byte_at (input, str_idx + 1);
|
||||
if (c < 0xe0)
|
||||
return (d < 0x80 || d > 0xbf) ? 0 : 2;
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
char_len = 3;
|
||||
if (c == 0xe0 && d < 0xa0)
|
||||
return 0;
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
char_len = 4;
|
||||
if (c == 0xf0 && d < 0x90)
|
||||
return 0;
|
||||
}
|
||||
else if (c < 0xfc)
|
||||
{
|
||||
char_len = 5;
|
||||
if (c == 0xf8 && d < 0x88)
|
||||
return 0;
|
||||
}
|
||||
else if (c < 0xfe)
|
||||
{
|
||||
char_len = 6;
|
||||
if (c == 0xfc && d < 0x84)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
if (str_idx + char_len > input->len)
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < char_len; ++i)
|
||||
{
|
||||
d = re_string_byte_at (input, str_idx + i);
|
||||
if (d < 0x80 || d > 0xbf)
|
||||
return 0;
|
||||
}
|
||||
return char_len;
|
||||
}
|
||||
|
||||
char_len = re_string_char_size_at (input, str_idx);
|
||||
if (node->type == OP_PERIOD)
|
||||
{
|
||||
if (char_len <= 1)
|
||||
return 0;
|
||||
/* FIXME: I don't think this if is needed, as both '\n'
|
||||
and '\0' are char_len == 1. */
|
||||
/* '.' accepts any one character except the following two cases. */
|
||||
if ((!(preg->syntax & RE_DOT_NEWLINE) &&
|
||||
re_string_byte_at (input, str_idx) == '\n') ||
|
||||
@ -3495,7 +3557,12 @@ check_node_accept_bytes (preg, node_idx, input, str_idx)
|
||||
return 0;
|
||||
return char_len;
|
||||
}
|
||||
else if (node->type == COMPLEX_BRACKET)
|
||||
|
||||
elem_len = re_string_elem_size_at (input, str_idx);
|
||||
if (elem_len <= 1 && char_len <= 1)
|
||||
return 0;
|
||||
|
||||
if (node->type == COMPLEX_BRACKET)
|
||||
{
|
||||
const re_charset_t *cset = node->opr.mbcset;
|
||||
# ifdef _LIBC
|
||||
@ -3731,15 +3798,22 @@ check_node_accept (preg, node, mctx, idx)
|
||||
return 0;
|
||||
}
|
||||
ch = re_string_byte_at (mctx->input, idx);
|
||||
if (node->type == CHARACTER)
|
||||
return node->opr.c == ch;
|
||||
else if (node->type == SIMPLE_BRACKET)
|
||||
return bitset_contain (node->opr.sbcset, ch);
|
||||
else if (node->type == OP_PERIOD)
|
||||
return !((ch == '\n' && !(preg->syntax & RE_DOT_NEWLINE))
|
||||
|| (ch == '\0' && (preg->syntax & RE_DOT_NOT_NULL)));
|
||||
else
|
||||
return 0;
|
||||
switch (node->type)
|
||||
{
|
||||
case CHARACTER:
|
||||
return node->opr.c == ch;
|
||||
case SIMPLE_BRACKET:
|
||||
return bitset_contain (node->opr.sbcset, ch);
|
||||
case OP_UTF8_PERIOD:
|
||||
if (ch >= 0x80)
|
||||
return 0;
|
||||
/* FALLTHROUGH */
|
||||
case OP_PERIOD:
|
||||
return !((ch == '\n' && !(preg->syntax & RE_DOT_NEWLINE))
|
||||
|| (ch == '\0' && (preg->syntax & RE_DOT_NOT_NULL)));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Extend the buffers, if the buffers have run out. */
|
||||
|
Loading…
Reference in New Issue
Block a user