From 0fdc6c4d7fa162ff5e9a7cda910ccfc357b4a567 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 16 Jan 2022 11:30:36 -0800 Subject: [PATCH] use C99 bools to set 'onstack' --- cmd/tools/acyclic.c | 5 +++-- lib/common/ns.c | 11 +++++++---- lib/dotgen/acyclic.c | 5 +++-- lib/dotgen/mincross.c | 7 ++++--- lib/dotgen/rank.c | 10 ++++++---- lib/neatogen/neatoinit.c | 6 +++--- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/cmd/tools/acyclic.c b/cmd/tools/acyclic.c index 8ad095bba..903804bf9 100644 --- a/cmd/tools/acyclic.c +++ b/cmd/tools/acyclic.c @@ -19,6 +19,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include #include @@ -72,7 +73,7 @@ static int dfs(Agraph_t * g, Agnode_t * t, int hasCycle) Agnode_t *h; ND_mark(t) = 1; - ND_onstack(t) = 1; + ND_onstack(t) = true; for (e = agfstout(g, t); e; e = f) { f = agnxtout(g, e); if (agtail(e) == aghead(e)) @@ -92,7 +93,7 @@ static int dfs(Agraph_t * g, Agnode_t * t, int hasCycle) } else if (ND_mark(h) == 0) hasCycle |= dfs(g, h, hasCycle); } - ND_onstack(t) = 0; + ND_onstack(t) = false; return hasCycle; } diff --git a/lib/common/ns.c b/lib/common/ns.c index 430da327a..3c2244419 100644 --- a/lib/common/ns.c +++ b/lib/common/ns.c @@ -14,6 +14,7 @@ */ #include +#include static void dfs_cutval(node_t * v, edge_t * par); static int dfs_range(node_t * v, edge_t * par, int low); @@ -1146,7 +1147,7 @@ static node_t *checkdfs(graph_t* g, node_t * n) if (ND_mark(n)) return 0; ND_mark(n) = TRUE; - ND_onstack(n) = TRUE; + ND_onstack(n) = true; for (i = 0; (e = ND_out(n).list[i]); i++) { w = aghead(e); if (ND_onstack(w)) { @@ -1173,15 +1174,17 @@ static node_t *checkdfs(graph_t* g, node_t * n) } } } - ND_onstack(n) = FALSE; + ND_onstack(n) = false; return 0; } void check_cycles(graph_t * g) { node_t *n; - for (n = GD_nlist(g); n; n = ND_next(n)) - ND_mark(n) = ND_onstack(n) = FALSE; + for (n = GD_nlist(g); n; n = ND_next(n)) { + ND_mark(n) = FALSE; + ND_onstack(n) = false; + } for (n = GD_nlist(g); n; n = ND_next(n)) checkdfs(g, n); } diff --git a/lib/dotgen/acyclic.c b/lib/dotgen/acyclic.c index 1cd0bffc8..f98ed93ad 100644 --- a/lib/dotgen/acyclic.c +++ b/lib/dotgen/acyclic.c @@ -14,6 +14,7 @@ */ #include +#include void reverse_edge(edge_t * e) { @@ -36,7 +37,7 @@ dfs(node_t * n) if (ND_mark(n)) return; ND_mark(n) = TRUE; - ND_onstack(n) = TRUE; + ND_onstack(n) = true; for (i = 0; (e = ND_out(n).list[i]); i++) { w = aghead(e); if (ND_onstack(w)) { @@ -47,7 +48,7 @@ dfs(node_t * n) dfs(w); } } - ND_onstack(n) = FALSE; + ND_onstack(n) = false; } diff --git a/lib/dotgen/mincross.c b/lib/dotgen/mincross.c index 43e3d4c6d..32609344c 100644 --- a/lib/dotgen/mincross.c +++ b/lib/dotgen/mincross.c @@ -1214,7 +1214,7 @@ static void flat_search(graph_t * g, node_t * v) adjmatrix_t *M = GD_rank(g)[ND_rank(v)].flat; ND_mark(v) = TRUE; - ND_onstack(v) = TRUE; + ND_onstack(v) = true; hascl = GD_n_cluster(dot_root(g)) > 0; if (ND_flat_out(v).list) for (i = 0; (e = ND_flat_out(v).list[i]); i++) { @@ -1239,7 +1239,7 @@ static void flat_search(graph_t * g, node_t * v) flat_search(g, aghead(e)); } } - ND_onstack(v) = FALSE; + ND_onstack(v) = false; } static void flat_breakcycles(graph_t * g) @@ -1251,7 +1251,8 @@ static void flat_breakcycles(graph_t * g) flat = 0; for (i = 0; i < GD_rank(g)[r].n; i++) { v = GD_rank(g)[r].v[i]; - ND_mark(v) = ND_onstack(v) = FALSE; + ND_mark(v) = FALSE; + ND_onstack(v) = false; flatindex(v) = i; if (ND_flat_out(v).size > 0 && flat == 0) { GD_rank(g)[r].flat = diff --git a/lib/dotgen/rank.c b/lib/dotgen/rank.c index e420d144a..f0a9f71ca 100644 --- a/lib/dotgen/rank.c +++ b/lib/dotgen/rank.c @@ -938,7 +938,7 @@ static void dfs(graph_t * g, node_t * v) if (ND_mark(v)) return; ND_mark(v) = TRUE; - ND_onstack(v) = TRUE; + ND_onstack(v) = true; for (e = agfstout(g, v); e; e = f) { f = agnxtout(g, e); w = aghead(e); @@ -949,15 +949,17 @@ static void dfs(graph_t * g, node_t * v) dfs(g, w); } } - ND_onstack(v) = FALSE; + ND_onstack(v) = false; } static void break_cycles(graph_t * g) { node_t *n; - for (n = agfstnode(g); n; n = agnxtnode(g, n)) - ND_mark(n) = ND_onstack(n) = FALSE; + for (n = agfstnode(g); n; n = agnxtnode(g, n)) { + ND_mark(n) = FALSE; + ND_onstack(n) = false; + } for (n = agfstnode(g); n; n = agnxtnode(g, n)) dfs(g, n); } diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index d1d9b0386..b27539f86 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -709,7 +709,7 @@ dfsCycle (vtx_data* graph, int i,int mode, node_t* nodes[]) np = nodes[i]; ND_mark(np) = TRUE; - ND_onstack(np) = TRUE; + ND_onstack(np) = true; for (e = 1; e < graph[i].nedges; e++) { if (graph[i].edists[e] == 1.0) continue; /* in edge */ j = graph[i].edges[e]; @@ -723,7 +723,7 @@ dfsCycle (vtx_data* graph, int i,int mode, node_t* nodes[]) else if (!ND_mark(hp)) dfsCycle(graph, j, mode, nodes); } - ND_onstack(np) = FALSE; + ND_onstack(np) = false; } /* acyclic: @@ -738,7 +738,7 @@ acyclic (vtx_data* graph, int nv, int mode, node_t* nodes[]) for (i = 0; i < nv; i++) { np = nodes[i]; ND_mark(np) = FALSE; - ND_onstack(np) = FALSE; + ND_onstack(np) = false; } for (i = 0; i < nv; i++) { if (ND_mark(nodes[i])) continue; -- 2.40.0