regex backref \0 regression test
authorSzabolcs Nagy <nsz@port70.net>
Sun, 22 Mar 2015 00:24:15 +0000 (00:24 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Sun, 22 Mar 2015 00:24:15 +0000 (00:24 +0000)
src/regression/regex-backref-0.c [new file with mode: 0644]

diff --git a/src/regression/regex-backref-0.c b/src/regression/regex-backref-0.c
new file mode 100644 (file)
index 0000000..c5f20b5
--- /dev/null
@@ -0,0 +1,20 @@
+// \0 is not a valid backref
+#include <regex.h>
+#include "test.h"
+
+int main(void)
+{
+       char buf[200];
+       char pat[] = "a\\0";
+       regex_t r;
+       int n;
+
+       n = regcomp(&r, pat, 0);
+       // standard allows REG_BADPAT for all pattern errors
+       if (n != REG_ESUBREG && n != REG_BADPAT) {
+               regerror(n, &r, buf, sizeof buf);
+               t_error("regcomp(%s) returned %d (%s) wanted REG_ESUBREG\n", pat, n, buf);
+       }
+
+       return t_status;
+}