From db4994c6c4bd213870f10d5beaea4595a03341f6 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sun, 13 Jan 2019 11:11:45 +0000 Subject: [PATCH] libre2c_posix (test): clear error status on expected failures. --- re2c/libre2c_posix/test.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/re2c/libre2c_posix/test.cpp b/re2c/libre2c_posix/test.cpp index ab013aa0..4e216acd 100644 --- a/re2c/libre2c_posix/test.cpp +++ b/re2c/libre2c_posix/test.cpp @@ -20,12 +20,20 @@ static int test(const char *pattern, const char *string } result = regexec(&re, string, nmatch, pmatch, 0); - if (result != 0 && nmatch > 0) { - fprintf(stderr, "regexec() failed for RE %s and string %s\n" - , pattern, string); - goto end; + if (result != 0) { + if (nmatch == 0) { + // failure was expected => it's a success + result = 0; + } + else if (nmatch > 0) { + fprintf(stderr, "regexec() failed for RE %s and string %s\n" + , pattern, string); + goto end; + } } - else if (result == 0 && nmatch == 0) { + else if (nmatch == 0) { + // regexed must have failed, something is wrong + result = REG_NOMATCH; fprintf(stderr, "regexec() didn't fail while it should" " for RE %s and string %s\n", pattern, string); goto end; -- 2.40.0