add regexec REG_NOSUB regression test by Hiltjo Posthuma
authorSzabolcs Nagy <nsz@port70.net>
Fri, 18 Jul 2014 12:28:37 +0000 (14:28 +0200)
committerSzabolcs Nagy <nsz@port70.net>
Fri, 18 Jul 2014 12:28:37 +0000 (14:28 +0200)
src/regression/regexec-nosub.c [new file with mode: 0644]

diff --git a/src/regression/regexec-nosub.c b/src/regression/regexec-nosub.c
new file mode 100644 (file)
index 0000000..4c580d9
--- /dev/null
@@ -0,0 +1,21 @@
+// commit: 72ed3d47e567b1635a35d3c1d174c8a8b2787e30 2014-07-17
+// regexec should not crash on non-zero nmatch with REG_NOSUB
+#include <regex.h>
+#include "test.h"
+
+int main(void)
+{
+       regex_t re;
+       int r;
+
+       r = regcomp(&re, "abc", REG_NOSUB);
+       if (r)
+               t_error("regcomp failed: %d\n", r);
+       r = regexec(&re, "zyx abc", 1, 0, 0);
+       if (r == REG_NOMATCH)
+               t_error("regexec failed to match\n");
+       else if (r)
+               t_error("regexec returned invalid code: %d\n", r);
+       regfree(&re);
+       return t_status;
+}