From: Florian Forster Date: Thu, 8 Jul 2010 09:40:04 +0000 (+0200) Subject: "list graphs" action: Don't show graphs without instances. X-Git-Tag: v4.0.0~122 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d57d345c057f784293439936f8a62fe01cffde06;p=collection4.git "list graphs" action: Don't show graphs without instances. --- diff --git a/src/action_list_graphs.c b/src/action_list_graphs.c index 2b26043..7973a08 100644 --- a/src/action_list_graphs.c +++ b/src/action_list_graphs.c @@ -135,6 +135,9 @@ static int print_graph_html (graph_config_t *cfg, /* {{{ */ char params[1024]; char title[1024]; + if (graph_num_instances (cfg) < 1) + return (0); + memset (title, 0, sizeof (title)); graph_get_title (cfg, title, sizeof (title)); html_escape_buffer (title, sizeof (title)); diff --git a/src/graph.c b/src/graph.c index f2699e1..9b545fd 100644 --- a/src/graph.c +++ b/src/graph.c @@ -490,6 +490,14 @@ static int graph_sort_instances_cb (const void *v0, const void *v1) /* {{{ */ *(graph_instance_t * const *) v1)); } /* }}} int graph_sort_instances_cb */ +size_t graph_num_instances (graph_config_t *cfg) /* {{{ */ +{ + if (cfg == NULL) + return ((size_t) -1); + + return (cfg->instances_num); +} /* }}} size_t graph_num_instances */ + int graph_sort_instances (graph_config_t *cfg) /* {{{ */ { if (cfg == NULL) diff --git a/src/graph.h b/src/graph.h index 26b4ac6..b6f2e7c 100644 --- a/src/graph.h +++ b/src/graph.h @@ -85,6 +85,8 @@ int graph_inst_search_field (graph_config_t *cfg, int graph_compare (graph_config_t *cfg, const graph_ident_t *ident); +size_t graph_num_instances (graph_config_t *cfg); + int graph_sort_instances (graph_config_t *cfg); int graph_clear_instances (graph_config_t *cfg);