From bceccd5ecc393c344ab008737ba6aab211a5ea9f Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 13 Feb 2015 18:37:43 -0500 Subject: Add helper for fnmatch over strv --- src/analyze/analyze.c | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'src/analyze/analyze.c') 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 #include #include -#include #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); } -- cgit v1.2.3-54-g00ecf