Browse Source

regexec: check on success return code

on OpenBSD: "Other non-zero error codes may be returned in exceptional
situations; see DIAGNOSTICS" regcomp(3).
master
Hiltjo Posthuma lostd 10 years ago
parent
commit
a7b29afcef
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      noice.c

+ 2
- 2
noice.c View File

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


Loading…
Cancel
Save