summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d3cf935)
raw | patch | inline | side by side (parent: d3cf935)
author | Florian Forster <ff@octo.it> | |
Wed, 23 Jun 2010 07:31:04 +0000 (09:31 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 23 Jun 2010 07:31:07 +0000 (09:31 +0200) |
src/graph.c | patch | blob | history |
diff --git a/src/graph.c b/src/graph.c
index 02b3ebf7bc36b692218ada66700d6ddeab043cd5..fc6a636e4660dd32985b03127a3e9d469bfac832 100644 (file)
--- a/src/graph.c
+++ b/src/graph.c
graph_inst_callback_t callback, void *user_data)
{
size_t i;
+ const char *selector_field;
+ _Bool need_check_instances = 0;
if ((cfg == NULL) || (field_value == NULL) || (callback == NULL))
return (EINVAL);
if (!graph_matches_field (cfg, field, field_value))
return (0);
+ selector_field = ident_get_field (cfg->select, field);
+ if (selector_field == NULL)
+ return (-1);
+
+ if (IS_ALL (selector_field) || IS_ANY (selector_field))
+ need_check_instances = 1;
+
for (i = 0; i < cfg->instances_num; i++)
{
- if (inst_matches_field (cfg->instances[i], field, field_value))
- {
- int status;
+ int status;
- status = (*callback) (cfg, cfg->instances[i], user_data);
- if (status != 0)
- return (status);
- }
+ if (need_check_instances
+ && !inst_matches_field (cfg->instances[i], field, field_value))
+ continue;
+
+ status = (*callback) (cfg, cfg->instances[i], user_data);
+ if (status != 0)
+ return (status);
}
return (0);