1#include <mcheck.h>
2#include <regex.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <sys/types.h>
6
7int
8main (void)
9{
10 mtrace ();
11
12 int res = 0;
13 char *buf = NULL;
14 size_t len = 0;
15 while (! feof (stdin))
16 {
17 ssize_t n = getline (lineptr: &buf, n: &len, stdin);
18 if (n <= 0)
19 break;
20 if (buf[n - 1] == '\n')
21 buf[n - 1] = '\0';
22
23 regex_t regex;
24 int rc = regcomp (preg: &regex, pattern: buf, REG_EXTENDED);
25 if (rc != 0)
26 printf (format: "%s: Error %d (expected)\n", buf, rc);
27 else
28 {
29 printf (format: "%s: succeeded !\n", buf);
30 res = 1;
31 }
32 }
33
34 free (ptr: buf);
35
36 return res;
37}
38

source code of glibc/posix/bug-regex31.c