From 49008048b65b497c823cbf9e6ea73d97c9b4958e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 15 Jan 2022 10:41:34 -0800 Subject: [PATCH] API BREAK: use C99 bools for 'rank_t' boolean fields --- CHANGELOG.md | 2 ++ lib/common/types.h | 4 ++-- lib/dotgen/cluster.c | 7 ++++--- lib/dotgen/mincross.c | 30 +++++++++++++++--------------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69b7a173..d5e12d21d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 C99 `bool`s instead of Graphviz-specific `boolean`s. - **Breaking**: The `usershape` field of the `shape_desc` struct is now a C99 `bool` instead of a Graphviz-specific `boolean`. +- **Breaking**: The `candidate` and `valid` fields of the `rank_t` struct are + now C99 `bool`s instead of Graphviz-specific `boolean`s. - **Breaking**: Graphviz headers no longer define the constant `MAXSHORT`. A drop-in replacement is `SHRT_MAX` in the C standard library’s limits.h. - **Breaking**: Graphviz headers no lnger define `NIL` macros. A drop-in diff --git a/lib/common/types.h b/lib/common/types.h index 75ed36c93..133ed65b5 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -210,8 +210,8 @@ extern "C" { double ht2; /* height below/above centerline */ double pht1; /* as above, but only primitive nodes */ double pht2; /* as above, but only primitive nodes */ - boolean candidate; /* for transpose () */ - boolean valid; + bool candidate; /* for transpose () */ + bool valid; int cache_nc; /* caches number of crossings */ adjmatrix_t *flat; } rank_t; diff --git a/lib/dotgen/cluster.c b/lib/dotgen/cluster.c index edcf24634..d15774cf1 100644 --- a/lib/dotgen/cluster.c +++ b/lib/dotgen/cluster.c @@ -10,6 +10,7 @@ #include #include +#include static node_t* map_interclust_node(node_t * n) @@ -233,7 +234,7 @@ merge_ranks(graph_t * subg) root = dot_root(subg); if (GD_minrank(subg) > 0) - GD_rank(root)[GD_minrank(subg) - 1].valid = FALSE; + GD_rank(root)[GD_minrank(subg) - 1].valid = false; for (r = GD_minrank(subg); r <= GD_maxrank(subg); r++) { d = GD_rank(subg)[r].n; ipos = pos = ND_order(GD_rankleader(subg)[r]); @@ -249,10 +250,10 @@ merge_ranks(graph_t * subg) GD_n_nodes(root)++; } GD_rank(subg)[r].v = GD_rank(root)[r].v + ipos; - GD_rank(root)[r].valid = FALSE; + GD_rank(root)[r].valid = false; } if (r < GD_maxrank(root)) - GD_rank(root)[r].valid = FALSE; + GD_rank(root)[r].valid = false; GD_expanded(subg) = TRUE; } diff --git a/lib/dotgen/mincross.c b/lib/dotgen/mincross.c index 139fc3d98..78f1cc68d 100644 --- a/lib/dotgen/mincross.c +++ b/lib/dotgen/mincross.c @@ -727,7 +727,7 @@ static int balance(graph_t * g) for (r = GD_maxrank(g); r >= GD_minrank(g); r--) { - GD_rank(g)[r].candidate = FALSE; + GD_rank(g)[r].candidate = false; for (i = 0; i < GD_rank(g)[r].n - 1; i++) { v = GD_rank(g)[r].v[i]; w = GD_rank(g)[r].v[i + 1]; @@ -759,7 +759,7 @@ static int transpose_step(graph_t * g, int r, bool reverse) node_t *v, *w; rv = 0; - GD_rank(g)[r].candidate = FALSE; + GD_rank(g)[r].candidate = false; for (i = 0; i < GD_rank(g)[r].n - 1; i++) { v = GD_rank(g)[r].v[i]; w = GD_rank(g)[r].v[i + 1]; @@ -778,16 +778,16 @@ static int transpose_step(graph_t * g, int r, bool reverse) if (c1 < c0 || (c0 > 0 && reverse && c1 == c0)) { exchange(v, w); rv += c0 - c1; - GD_rank(Root)[r].valid = FALSE; - GD_rank(g)[r].candidate = TRUE; + GD_rank(Root)[r].valid = false; + GD_rank(g)[r].candidate = true; if (r > GD_minrank(g)) { - GD_rank(Root)[r - 1].valid = FALSE; - GD_rank(g)[r - 1].candidate = TRUE; + GD_rank(Root)[r - 1].valid = false; + GD_rank(g)[r - 1].candidate = true; } if (r < GD_maxrank(g)) { - GD_rank(Root)[r + 1].valid = FALSE; - GD_rank(g)[r + 1].candidate = TRUE; + GD_rank(Root)[r + 1].valid = false; + GD_rank(g)[r + 1].candidate = true; } } } @@ -799,7 +799,7 @@ static void transpose(graph_t * g, bool reverse) int r, delta; for (r = GD_minrank(g); r <= GD_maxrank(g); r++) - GD_rank(g)[r].candidate = TRUE; + GD_rank(g)[r].candidate = true; do { delta = 0; for (r = GD_minrank(g); r <= GD_maxrank(g); r++) { @@ -886,7 +886,7 @@ static void restore_best(graph_t * g) } } for (r = GD_minrank(g); r <= GD_maxrank(g); r++) { - GD_rank(Root)[r].valid = FALSE; + GD_rank(Root)[r].valid = false; qsort(GD_rank(g)[r].v, GD_rank(g)[r].n, sizeof(GD_rank(g)[0].v[0]), (qsort_cmpf) nodeposcmpf); } @@ -1397,7 +1397,7 @@ void build_ranks(graph_t * g, int pass) if (dequeue(q)) agerr(AGERR, "surprise\n"); for (i = GD_minrank(g); i <= GD_maxrank(g); i++) { - GD_rank(Root)[i].valid = FALSE; + GD_rank(Root)[i].valid = false; if (GD_flip(g) && GD_rank(g)[i].n > 0) { int n, ndiv2; node_t **vlist = GD_rank(g)[i].v; @@ -1544,7 +1544,7 @@ static void flat_reorder(graph_t * g) /* postprocess to restore intended order */ } /* else do no harm! */ - GD_rank(Root)[r].valid = FALSE; + GD_rank(Root)[r].valid = false; } if (temprank) free(temprank); @@ -1596,9 +1596,9 @@ static void reorder(graph_t * g, int r, bool reverse, bool hasfixed) } if (changed) { - GD_rank(Root)[r].valid = FALSE; + GD_rank(Root)[r].valid = false; if (r > 0) - GD_rank(Root)[r - 1].valid = FALSE; + GD_rank(Root)[r - 1].valid = false; } } @@ -1713,7 +1713,7 @@ int ncross(graph_t * g) else { nc = GD_rank(g)[r].cache_nc = rcross(g, r); count += nc; - GD_rank(g)[r].valid = TRUE; + GD_rank(g)[r].valid = true; } } return count; -- 2.40.0