]> Sergey Matveev's repositories - nnn.git/commitdiff
regexec: check on success return code
authorHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 17 Dec 2014 11:25:55 +0000 (11:25 +0000)
committerlostd <lostd@2f30.org>
Thu, 18 Dec 2014 09:02:34 +0000 (11:02 +0200)
on OpenBSD: "Other non-zero error codes may be returned in exceptional
situations; see DIAGNOSTICS" regcomp(3).

noice.c

diff --git a/noice.c b/noice.c
index 831f4756a7e1c92c6e9a31877cacdbc45c83cdf0..135f453b6bac8a8168d541431d491dc726a13723 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -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;
 }