diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-02-13 18:37:43 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-02-16 13:16:45 -0500 |
commit | bceccd5ecc393c344ab008737ba6aab211a5ea9f (patch) | |
tree | ce4ef4ed45bb54764fe6703372477103c4fad01d /src/analyze | |
parent | 488c8d08c322471f2e702e25b75f31bed7ae5975 (diff) |
Add helper for fnmatch over strv
Diffstat (limited to 'src/analyze')
-rw-r--r-- | src/analyze/analyze.c | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 46a97eb8e7..672a0d7976 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -25,7 +25,6 @@ #include <getopt.h> #include <locale.h> #include <sys/utsname.h> -#include <fnmatch.h> #include "sd-bus.h" #include "bus-util.h" @@ -985,46 +984,15 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop, return r; STRV_FOREACH(unit, units) { - char **p; - bool match_found; - - if (!strv_isempty(arg_dot_from_patterns)) { - match_found = false; - - STRV_FOREACH(p, arg_dot_from_patterns) - if (fnmatch(*p, u->id, 0) == 0) { - match_found = true; - break; - } - - if (!match_found) - continue; - } - - if (!strv_isempty(arg_dot_to_patterns)) { - match_found = false; - - STRV_FOREACH(p, arg_dot_to_patterns) - if (fnmatch(*p, *unit, 0) == 0) { - match_found = true; - break; - } - - if (!match_found) - continue; - } + if (!strv_fnmatch_or_empty(u->id, arg_dot_from_patterns, 0)) + continue; - if (!strv_isempty(patterns)) { - match_found = false; + if (!strv_fnmatch_or_empty(*unit, arg_dot_to_patterns, 0)) + continue; - STRV_FOREACH(p, patterns) - if (fnmatch(*p, u->id, 0) == 0 || fnmatch(*p, *unit, 0) == 0) { - match_found = true; - break; - } - if (!match_found) - continue; - } + if (!strv_fnmatch_or_empty(u->id, patterns, 0) && + !strv_fnmatch_or_empty(*unit, patterns, 0)) + continue; printf("\t\"%s\"->\"%s\" [color=\"%s\"];\n", u->id, *unit, color); } |