diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-11-18 23:40:59 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-11-18 23:40:59 +0000 |
commit | ad7f28c29d06ddb4506d0d75e089732740b5bd2b (patch) | |
tree | de9ee40c2d213a4113e3da2b8cedc3d505386bc1 /posix/bug-regex20.c | |
parent | 5146ec9a2c092cb74b5cd0eb8b5e938b46f1631b (diff) | |
download | glibc-ad7f28c29d06ddb4506d0d75e089732740b5bd2b.tar glibc-ad7f28c29d06ddb4506d0d75e089732740b5bd2b.tar.gz glibc-ad7f28c29d06ddb4506d0d75e089732740b5bd2b.tar.bz2 glibc-ad7f28c29d06ddb4506d0d75e089732740b5bd2b.zip |
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>
Diffstat (limited to 'posix/bug-regex20.c')
-rw-r--r-- | posix/bug-regex20.c | 229 |
1 files changed, 163 insertions, 66 deletions
diff --git a/posix/bug-regex20.c b/posix/bug-regex20.c index 74662e6246..7f5d0310ca 100644 --- a/posix/bug-regex20.c +++ b/posix/bug-regex20.c @@ -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); } |