1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
* posix/bug-regex11.c: Add some more tests which fail so far.
	Disable them.  Patch by Paolo Bonzini <bonzini@gnu.org>.

2003-10-05  Paolo Bonzini  <bonzini@gnu.org>

	* posix/bug-regex11.c: Add more backreference-related test cases.
	(main): Show the failing regex in the error messages.
	* posix/regexec.c (check_dst_limits_calc_pos):
	Simplify some nested conditionals.  Replace if's with a switch
	statement.
	(check_dst_limits_calc_pos <TYPE_BKREF>): Rename parameter NODE to
	FROM_NODE, it shadows a local variable; don't recurse if FROM_NODE
	does not change in the recursive invocation, fixing an infinite loop
	in the ()\1*\1* regex.
	(sift_states_backward): Fix function comment.
	* posix/regcomp.c (calc_epsdest): Add an assertion.

2003-10-06  Ulrich Drepper  <drepper@redhat.com>
This commit is contained in:
Ulrich Drepper
2003-10-06 23:44:15 +00:00
parent 4bd2533694
commit d0b96fc49b
3 changed files with 101 additions and 31 deletions

View File

@ -35,6 +35,7 @@ struct
/* Test for newline handling in regex. */
{ "[^~]*~", "\nx~y", 0, 2, { { 0, 3 }, { -1, -1 } } },
/* Other tests. */
{ "a(.*)b", "a b", REG_EXTENDED, 2, { { 0, 3 }, { 1, 2 } } },
{ ".*|\\([KIO]\\)\\([^|]*\\).*|?[KIO]", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
{ { 0, 21 }, { 15, 16 }, { 16, 18 } } },
{ ".*|\\([KIO]\\)\\([^|]*\\).*|?\\1", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
@ -52,6 +53,18 @@ struct
/* Here ^ cannot be treated as an anchor according to POSIX. */
{ "(^|foo)bar", "(^|foo)bar", 0, 2, { { 0, 10 }, { -1, -1 } } },
{ "(foo|^)bar", "(foo|^)bar", 0, 2, { { 0, 10 }, { -1, -1 } } },
/* More tests on backreferences. */
{ "()\\1*\\1*", "", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } },
{ "([0-9]).*\\1(a*)", "7;7a6", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } },
{ "([0-9]).*\\1(a*)", "7;7a", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } },
#if 0
/* XXX This test seems wrong. --drepper */
{ "()(b)\\1c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 1, 2 } } },
/* XXX Not used since they fail so far. */
{ "(b())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 2 }, { 0, 1 }, { 1, 1 } } },
{ "(bb())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 4 }, { 0, 2 }, { 2, 2 } } },
#endif
};
int
@ -71,14 +84,14 @@ main (void)
{
char buf[500];
regerror (n, &re, buf, sizeof (buf));
printf ("regcomp %zd failed: %s\n", i, buf);
printf ("%s: regcomp %zd failed: %s\n", tests[i].pattern, i, buf);
ret = 1;
continue;
}
if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0))
{
printf ("regexec %zd failed\n", i);
printf ("%s: regexec %zd failed\n", tests[i].pattern, i);
ret = 1;
regfree (&re);
continue;
@ -90,8 +103,8 @@ main (void)
{
if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
break;
printf ("regexec match failure rm[%d] %d..%d\n",
n, rm[n].rm_so, rm[n].rm_eo);
printf ("%s: regexec %zd match failure rm[%d] %d..%d\n",
tests[i].pattern, i, n, rm[n].rm_so, rm[n].rm_eo);
ret = 1;
break;
}