Remove unused macro ALLOCA_LIMIT.
[glibc.git] / posix / bug-regex24.c
blob97c5c3508a9ea469e0a84e1f6a640ada02d03f1f
1 #include <regex.h>
2 #include <stdio.h>
3 #include <string.h>
5 #define str "civic"
7 #define N 10
8 static const char *expected[N] =
10 str, "c", "i", "", "", "", "", "", "", ""
13 static int
14 do_test (void)
16 regex_t rbuf;
17 static const char pat[] = "\
18 ^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$";
20 int err = regcomp (&rbuf, pat, REG_EXTENDED);
21 if (err != 0)
23 char errstr[300];
24 regerror (err, &rbuf, errstr, sizeof (errstr));
25 puts (errstr);
26 return err;
29 regmatch_t m[N];
30 err = regexec (&rbuf, str, N, m, 0);
31 if (err != 0)
33 puts ("regexec failed");
34 return 1;
37 int result = 0;
38 for (int i = 0; i < N; ++i)
39 if (m[i].rm_so == -1)
41 printf ("m[%d] unused\n", i);
42 result = 1;
44 else
46 int len = m[i].rm_eo - m[i].rm_so;
48 printf ("m[%d] = \"%.*s\"\n", i, len, str + m[i].rm_so);
50 if (strlen (expected[i]) != len
51 || memcmp (expected[i], str + m[i].rm_so, len) != 0)
52 result = 1;
55 return result;
58 #define TIMEOUT 30
59 #define TEST_FUNCTION do_test ()
60 #include "../test-skeleton.c"