string test alignment fix by Mahesh Bodapati
[libc-test.git] / src / regression / regexec-nosub.c
blob4c580d98643005d1f34d4710d9ee1dfe720cc13a
1 // commit: 72ed3d47e567b1635a35d3c1d174c8a8b2787e30 2014-07-17
2 // regexec should not crash on non-zero nmatch with REG_NOSUB
3 #include <regex.h>
4 #include "test.h"
6 int main(void)
8 regex_t re;
9 int r;
11 r = regcomp(&re, "abc", REG_NOSUB);
12 if (r)
13 t_error("regcomp failed: %d\n", r);
14 r = regexec(&re, "zyx abc", 1, 0, 0);
15 if (r == REG_NOMATCH)
16 t_error("regexec failed to match\n");
17 else if (r)
18 t_error("regexec returned invalid code: %d\n", r);
19 regfree(&re);
20 return t_status;