diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-23 13:08:08 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-23 13:08:08 +0300 |
commit | bd19f38853dad5a89abada6ee5e7a23c65173894 (patch) | |
tree | 57b53cdceeb69db1bb51e8df48eb4f007c6ecb97 /src/depmap.c | |
parent | 3ad426f88d274535d7e04e12add72534034ac075 (diff) | |
download | pies-bd19f38853dad5a89abada6ee5e7a23c65173894.tar.gz pies-bd19f38853dad5a89abada6ee5e7a23c65173894.tar.bz2 |
Revise dependency handling. Correctly display cyclic dependencies.
* src/comp.c (component_log_dep): Remove.
(report_cyclic_dependency): New function.
(comp_array_remove): New function.
(component_build_depmap): Remove erroneous components both from
the component table and dependency map.
(components_dump_depmap): Avoid trailing whitespace in the output.
* src/depmap.c (depmap_clear_all): Remove.
(depmap_remove): New function.
* src/pies.h (CF_REMOVE): New flag.
(depmap_clear_all): Remove prototype.
(depmap_remove): New prototype.
* tests/Makefile.am: Add new test.
* tests/atlocal.in (trimws): New function.
* tests/cyclic.at: New test.
* tests/testsuite.at: Include new test.
Diffstat (limited to 'src/depmap.c')
-rw-r--r-- | src/depmap.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/depmap.c b/src/depmap.c index 3ea5722..cb50548 100644 --- a/src/depmap.c +++ b/src/depmap.c @@ -81,9 +81,9 @@ TC (unsigned *R, int n) struct pies_depmap { - size_t nrows; - size_t rowlen; - unsigned r[1]; + size_t nrows; /* Number of rows (== number of mapped elements) */ + size_t rowlen; /* Length of a row in words */ + unsigned r[1]; /* Data rows */ }; pies_depmap_t @@ -97,11 +97,18 @@ depmap_alloc (size_t count) return dmap; } +/* Return size of a depmap row in bytes */ +static inline size_t +depmap_row_size (pies_depmap_t dpm) +{ + return dpm->rowlen * sizeof (unsigned); +} + pies_depmap_t depmap_copy (pies_depmap_t dpm) { pies_depmap_t copy = depmap_alloc (dpm->nrows); - memcpy (copy->r, dpm->r, dpm->nrows * dpm->rowlen * sizeof (unsigned)); + memcpy (copy->r, dpm->r, dpm->nrows * depmap_row_size (dpm)); return copy; } @@ -174,21 +181,22 @@ depmap_end (pies_depmap_pos_t pos) grecs_free (pos); } +/* Remove nth row and column from the map */ void -depmap_clear_all (pies_depmap_t dmap, enum pies_depmap_direction dir, - size_t coord) +depmap_remove (pies_depmap_t dmap, size_t n) { - size_t i; - - switch (dir) + if (n < dmap->nrows - 1) { - case depmap_row: - for (i = 0; i < dmap->nrows; i++) - depmap_clear (dmap, coord, i); - break; - - case depmap_col: + size_t i, j; + + /* Remove nth row */ + memmove (depmap_rowptr (dmap, n), depmap_rowptr (dmap, n + 1), + (dmap->nrows - n - 1) * depmap_row_size (dmap)); + /* Renumber all columns j >= n: j = j - 1 */ for (i = 0; i < dmap->nrows; i++) - depmap_clear (dmap, i, coord); + for (j = n; j < dmap->nrows - 1; j++) + (depmap_isset (dmap, i, j + 1) ? depmap_set : depmap_clear) + (dmap, i, j); } + dmap->nrows--; } |