-
Notifications
You must be signed in to change notification settings - Fork 0
/
regextest.c
72 lines (63 loc) · 1.53 KB
/
regextest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* f-dirprecheck-v1.1/regextest.c */
/* simple test code to check regexes from config.h */
#include <stdlib.h>
#include <stdio.h>
#include <regex.h>
/* our user config settings */
#include CONFIG_H
int main()
{
int bad = 0;
#if USEREGEXLIST == 1
#define REGEXNUM (sizeof regexlist / sizeof regexlist[0])
{
unsigned int n;
regex_t reg;
for (n = 0; n < REGEXNUM; n++) {
if (regexlist[n].regex) {
if (regcomp(®, regexlist[n].regex, REG_EXTENDED) != 0) {
printf("Cannot compile: %s\n", regexlist[n].regex);
bad = 1;
}
else regfree(®);
}
if (regexlist[n].pathmatch) {
if (regcomp(®, regexlist[n].pathmatch, REG_EXTENDED) != 0) {
printf("Cannot compile: %s\n", regexlist[n].pathmatch);
bad = 1;
}
else regfree(®);
}
if (regexlist[n].pathignore) {
if (regcomp(®, regexlist[n].pathignore, REG_EXTENDED) != 0) {
printf("Cannot compile: %s\n", regexlist[n].pathignore);
bad = 1;
}
else regfree(®);
}
}
}
#endif
#if CROSSSECTIONTESTS == 1
#define CROSSNUM (sizeof crosscheck / sizeof crosscheck[0])
{
unsigned int n;
regex_t reg;
for (n = 0; n < CROSSNUM; n++) {
if (!crosscheck[n].cwdregex) {
printf("Cross-section test %d doesnt have a cwdpathregex.\n", n);
bad = 1;
}
else {
if (regcomp(®, crosscheck[n].cwdregex, REG_EXTENDED) != 0) {
printf("Cannot compile: %s\n", crosscheck[n].cwdregex);
bad = 1;
}
else regfree(®);
}
}
}
#endif
if (bad) return 1;
return 0;
}