10 /* lowercase chars mapped to uppercase */
11 static const char casetable
[] = {
12 '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
13 '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
14 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
15 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
16 /* ' ' '!' '"' '#' '$' '%' '&' ''' */
17 '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
18 /* '(' ')' '*' '+' ',' '-' '.' '/' */
19 '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
20 /* '0' '1' '2' '3' '4' '5' '6' '7' */
21 '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
22 /* '8' '9' ':' ';' '<' '=' '>' '?' */
23 '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
24 /* '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' */
25 '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
26 /* 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' */
27 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
28 /* 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' */
29 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
30 /* 'X' 'Y' 'Z' '[' '\' ']' '^' '_' */
31 '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
32 /* '`' 'a' 'b' 'c' 'd' 'e' 'f' 'g' */
33 '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
34 /* 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' */
35 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
36 /* 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' */
37 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
38 /* 'x' 'y' 'z' '{' '|' '}' '~' */
39 '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
42 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
43 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
44 '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
45 '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
46 '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
47 '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
48 '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
49 '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
50 '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
51 '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
52 '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
53 '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
54 '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
55 '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
56 '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
57 '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
62 run_test (const char *pattern
, struct re_registers
*regs
)
64 static char text
[] = "1111AAAA2222bbbb";
66 struct re_pattern_buffer pat
;
72 memset (&pat
, '\0', sizeof (pat
));
73 memset (regs
, '\0', 2 * sizeof (regs
[0]));
74 pat
.allocated
= 0; /* regex will allocate the buffer */
75 pat
.fastmap
= (char *) malloc (256);
76 if (pat
.fastmap
== NULL
)
78 puts ("out of memory");
82 pat
.translate
= (unsigned char *) casetable
;
84 err
= re_compile_pattern (pattern
, strlen (pattern
), &pat
);
87 fprintf (stderr
, "/%s/: %s\n", pattern
, err
);
90 res
= re_search (&pat
, text
, strlen (text
), 0, strlen (text
), ®s
[0]);
92 printf ("search 1: res = %d\n", res
);
94 printf ("search 1: res = %d, start = %d, end = %d\n",
95 res
, regs
[0].start
[0], regs
[0].end
[0]);
97 if (regs
[0].end
== NULL
)
100 start2
= regs
[0].end
[0] + 1;
102 res
= re_search (&pat
, text
, strlen (text
), start2
, strlen (text
), ®s
[1]);
104 printf ("search 2: res = %d\n", res
);
106 printf ("search 2: res = %d, start = %d, end = %d\n",
107 res
, regs
[1].start
[0], regs
[1].end
[0]);
109 return res
< 0 ? 1 : 0;
116 static const char lower
[] = "[[:lower:]]+";
117 static const char upper
[] = "[[:upper:]]+";
118 struct re_registers regs
[4];
120 setlocale (LC_ALL
, "C");
122 (void) re_set_syntax (RE_SYNTAX_GNU_AWK
);
126 if (exp) { puts (#exp); result = 1; }
128 result
= run_test (lower
, regs
);
129 result
|= run_test (upper
, ®s
[2]);
132 CHECK (regs
[0].start
[0] != regs
[2].start
[0]);
133 CHECK (regs
[0].end
[0] != regs
[2].end
[0]);
134 CHECK (regs
[1].start
[0] != regs
[3].start
[0]);
135 CHECK (regs
[1].end
[0] != regs
[3].end
[0]);
141 #define TEST_FUNCTION do_test ()
142 #include "../test-skeleton.c"