regexec: check on success return code

on OpenBSD: "Other non-zero error codes may be returned in exceptional
situations; see DIAGNOSTICS" regcomp(3).
This commit is contained in:
Hiltjo Posthuma 2014-12-17 11:25:55 +00:00 committed by lostd
parent 82747b38f9
commit a7b29afcef

View file

@ -189,7 +189,7 @@ openwith(char *file)
if (regcomp(&regex, assocs[i].regex,
REG_NOSUB | REG_EXTENDED) != 0)
continue;
if (regexec(&regex, file, 0, NULL, 0) != REG_NOMATCH) {
if (regexec(&regex, file, 0, NULL, 0) == 0) {
bin = assocs[i].bin;
break;
}
@ -219,7 +219,7 @@ setfilter(regex_t *regex, char *filter)
int
visible(regex_t *regex, char *file)
{
if (regexec(regex, file, 0, NULL, 0) != REG_NOMATCH)
if (regexec(regex, file, 0, NULL, 0) == 0)
return 1;
return 0;
}