summaryrefslogtreecommitdiffabout
path: root/src/comp.c
Side-by-side diff
Diffstat (limited to 'src/comp.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/comp.c80
1 files changed, 32 insertions, 48 deletions
diff --git a/src/comp.c b/src/comp.c
index 28d4d6d..09f9611 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -403,44 +403,24 @@ list_str_cmp (const void *a, const void *b)
DP is a transitive closure of depmap.
*/
static void
-report_cyclic_dependency (pies_depmap_t dp, size_t idx)
+report_cyclic_dependency (struct depmap_path *path)
{
- size_t i;
-
- i = idx;
- do
+ struct depmap_path_elem *p;
+ for (p = path->head; p; p = p->next)
{
- size_t n;
- pies_depmap_pos_t pos;
-
- logmsg_printf (LOG_NOTICE, "%s -> ", comp_array[i]->tag);
- comp_array[i]->flags |= CF_REMOVE;
- for (n = depmap_first (depmap, depmap_col, i, &pos);
- n != (size_t)-1;
- n = depmap_next (depmap, pos))
- {
- if (n == i)
- continue;
- if (depmap_isset (dp, n, i) && depmap_isset (dp, n, n))
- break;
- }
- depmap_end (pos);
-
- if (n == (size_t)-1)
- break;
- i = n;
+ logmsg_printf (LOG_NOTICE, "%s -> ", comp_array[p->idx]->tag);
+ comp_array[p->idx]->flags |= CF_REMOVE;
}
- while (i != idx);
- logmsg_printf (LOG_NOTICE, "%s\n", comp_array[idx]->tag);
+ logmsg_printf (LOG_NOTICE, "%s\n", comp_array[path->head->idx]->tag);
}
void
component_build_depmap (void)
{
- size_t i;
- pies_depmap_t dp;
-
- free (depmap);
+ struct depmap_path *path;
+ int i;
+
+ depmap_free (depmap);
depmap = depmap_alloc (comp_count);
for (i = 0; i < comp_count; )
{
@@ -482,24 +462,22 @@ component_build_depmap (void)
i++;
}
- dp = depmap_copy (depmap);
- depmap_tc (dp);
- for (i = 0; i < comp_count; i++)
- if (!(comp_array[i]->flags & CF_REMOVE) && depmap_isset (dp, i, i))
- {
- logmsg (LOG_ERR, _("component %s depends on itself"),
- comp_array[i]->tag);
- report_cyclic_dependency (dp, i);
- }
-
-
- for (i = 0; i < comp_count;)
- if (comp_array[i]->flags & CF_REMOVE)
- comp_array_remove (i);
- else
- i++;
-
- free (dp);
+ path = depmap_cycle_detect (depmap);
+ if (path)
+ {
+ struct depmap_path *p;
+
+ logmsg (LOG_ERR, "%s", _("cyclic dependencies detected:"));
+ for (p = path; p; p = p->next)
+ report_cyclic_dependency (p);
+ depmap_path_free (path);
+
+ for (i = 0; i < comp_count;)
+ if (comp_array[i]->flags & CF_REMOVE)
+ comp_array_remove (i);
+ else
+ i++;
+ }
}
void
@@ -806,6 +784,12 @@ depmap_dump (pies_depmap_t dpm)
{
size_t i, j;
+ if (depmap_dim (dpm) == 0)
+ {
+ printf ("%s\n", _("No components defined"));
+ return;
+ }
+
printf ("%s:\n", _("Dependency map"));
printf (" ");
for (i = 0; i < comp_count; i++)

Return to:

Send suggestions and report system problems to the System administrator.