From ca59019d8bafde77986d00352951bc6acd2bcf97 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 22 Mar 2015 19:00:24 +0000 Subject: [PATCH] fix BRE \0 test case --- src/regression/regex-backref-0.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/regression/regex-backref-0.c b/src/regression/regex-backref-0.c index c5f20b5..289be3b 100644 --- a/src/regression/regex-backref-0.c +++ b/src/regression/regex-backref-0.c @@ -1,4 +1,5 @@ -// \0 is not a valid backref +// \0 is not a valid backref, it is undefined by the standard +// we treat such cases as literal char #include #include "test.h" @@ -10,10 +11,15 @@ int main(void) int n; n = regcomp(&r, pat, 0); - // standard allows REG_BADPAT for all pattern errors - if (n != REG_ESUBREG && n != REG_BADPAT) { + if (n) { regerror(n, &r, buf, sizeof buf); - t_error("regcomp(%s) returned %d (%s) wanted REG_ESUBREG\n", pat, n, buf); + t_error("regcomp(%s) returned %d (%s) wanted 0\n", pat, n, buf); + } + n = regexec(&r, "a0", 0, 0, 0); + if (n) { + regerror(n, &r, buf, sizeof buf); + t_error("regexec(/%s/ ~ \"a0\") returned %d (%s), wanted 0\n", + pat, n, buf); } return t_status; -- 2.20.1