1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

2002-09-28 Jakub Jelinek <jakub@redhat.com>

* posix/bug-regex11.c (tests): Add flags field.
	(main): Avoid warnings.  Use test[i].flags.  Return nonzero
	if any of the tests failed.
	* posix/bug-regex12.c: New file.
	* posix/Makefile (tests): Add bug-regex12.
This commit is contained in:
Roland McGrath
2002-09-28 20:51:17 +00:00
parent 100a05053c
commit ab635ab254
3 changed files with 81 additions and 8 deletions

View File

@ -24,19 +24,20 @@
#include <stdio.h>
#include <stdlib.h>
/* Tests supposed to match. */
struct
{
const char *pattern;
const char *string;
int nmatch;
int flags, nmatch;
regmatch_t rm[4];
} tests[] = {
/* Test for newline handling in regex. */
{ "[^~]*~", "\nx~y", 2, { { 0, 3 }, { -1, -1 } } },
{ "[^~]*~", "\nx~y", 0, 2, { { 0, 3 }, { -1, -1 } } },
/* Other tests. */
{ ".*|\\([KIO]\\)\\([^|]*\\).*|?[KIO]", "10~.~|P|K0|I10|O16|?KSb", 3,
{ ".*|\\([KIO]\\)\\([^|]*\\).*|?[KIO]", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
{ { 0, 21 }, { 15, 16 }, { 16, 18 } } },
{ ".*|\\([KIO]\\)\\([^|]*\\).*|?\\1", "10~.~|P|K0|I10|O16|?KSb", 3,
{ ".*|\\([KIO]\\)\\([^|]*\\).*|?\\1", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
{ { 0, 21 }, { 8, 9 }, { 9, 10 } } }
};
@ -45,13 +46,14 @@ main (void)
{
regex_t re;
regmatch_t rm[4];
int n, i, ret = 0;
size_t i;
int n, ret = 0;
mtrace ();
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
{
n = regcomp (&re, tests[i].pattern, 0);
n = regcomp (&re, tests[i].pattern, tests[i].flags);
if (n != 0)
{
char buf[500];
@ -84,5 +86,5 @@ main (void)
regfree (&re);
}
return 0;
return ret;
}