]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: (filter) use also rpmatch() for boolean
authorKarel Zak <kzak@redhat.com>
Mon, 9 Oct 2023 11:41:06 +0000 (13:41 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 20 Nov 2023 21:25:47 +0000 (22:25 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/filter-param.c

index 31f24bbac6e88af976b0e1621366c31d9021e252..673c9d90175e9a9ae8309a6a6f52094f78a092af 100644 (file)
@@ -4,6 +4,7 @@
 #include <unistd.h>
 #include <regex.h>
 
+#include "rpmatch.h"
 #include "smartcolsP.h"
 
 struct filter_param {
@@ -596,9 +597,10 @@ static int string_cast(int type, struct filter_param *n)
        }
        case SCOLS_DATA_BOOLEAN:
        {
-               bool x = (!str || !*str
-                              || strcasecmp(str, "false") == 0
-                              || strcasecmp(str, "0") == 0) ? false : true;
+               bool x = str && *str
+                            && (strcasecmp(str, "1") == 0
+                                || strcasecmp(str, "true") == 0
+                                || rpmatch(str) == RPMATCH_YES);
                n->val.boolean = x;
                break;
        }