regexec() can only return zero or NOMATCH according to its man page. This allows us to remove the error handler as it could never be executed.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-07-16 12:31:05 +02:00
parent e3fc3a78fb
commit fe23292434
+2 -6
View File
@@ -72,6 +72,8 @@ bool match_regex(const char *input, const unsigned char regexid)
// Try to match the compiled regular expression against input
int errcode = regexec(&regex[regexid][index], input, 0, NULL, 0);
// regexec() returns zero for a successful match or REG_NOMATCH for failure.
// We are only interested in the matching case here.
if (errcode == 0)
{
// Match, return true
@@ -82,12 +84,6 @@ bool match_regex(const char *input, const unsigned char regexid)
logg("Regex %s in line %i \"%s\" matches \"%s\"", regextype[regexid], index+1, regexbuffer[regexid][index], input);
break;
}
else if (errcode != REG_NOMATCH)
{
// Error, return false afterwards
log_regex_error("matching", errcode, index, regexid, "");
break;
}
}
double elapsed = timer_elapsed_msec(REGEX_TIMER);