From ad053ceb601521dd14bfa98f70594288f41c01c1 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 15 Jan 2022 10:31:55 -0800 Subject: [PATCH] API BREAK: use C99 bools for 'textlabel_t' fields instead of booleans --- CHANGELOG.md | 2 ++ lib/common/htmltable.c | 2 +- lib/common/labels.c | 4 ++-- lib/common/postproc.c | 2 +- lib/common/splines.c | 2 +- lib/common/types.h | 4 ++-- lib/dotgen/dotsplines.c | 14 +++++++------- lib/neatogen/neatoinit.c | 6 +++--- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de817f73..029980b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `boolean`s. - **Breaking**: The `defined`, `constrained`, `clip`, and `dyna` fields of the `port` struct are now C99 `bool`s instead of Graphviz-specific `boolean`s. +- **Breaking**: The `set` and `html` fields of the `textlabel_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/htmltable.c b/lib/common/htmltable.c index 317d46288..4dc2ecb66 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -2025,7 +2025,7 @@ int make_html_label(void *obj, textlabel_t * lp) agxbuf xb; unsigned char buf[SMALLBUF]; agxbinit(&xb, SMALLBUF, buf); - lp->html = FALSE; + lp->html = false; lp->text = strdup(nameOf(obj, &xb)); switch (lp->charset) { case CHAR_LATIN1: diff --git a/lib/common/labels.c b/lib/common/labels.c index 246b3cb0b..7c5dcf4ea 100644 --- a/lib/common/labels.c +++ b/lib/common/labels.c @@ -139,12 +139,12 @@ textlabel_t *make_label(void *obj, char *str, int kind, double fontsize, char *f if (kind & LT_RECD) { rv->text = strdup(str); if (kind & LT_HTML) { - rv->html = TRUE; + rv->html = true; } } else if (kind == LT_HTML) { rv->text = strdup(str); - rv->html = TRUE; + rv->html = true; if (make_html_label(obj, rv)) { switch (agobjkind(obj)) { case AGRAPH: diff --git a/lib/common/postproc.c b/lib/common/postproc.c index 2f9dba6f8..bc712030d 100644 --- a/lib/common/postproc.c +++ b/lib/common/postproc.c @@ -756,7 +756,7 @@ void place_graph_label(graph_t * g) p.x = (GD_bb(g).LL.x + GD_bb(g).UR.x) / 2; } GD_label(g)->pos = p; - GD_label(g)->set = TRUE; + GD_label(g)->set = true; } for (c = 1; c <= GD_n_cluster(g); c++) diff --git a/lib/common/splines.c b/lib/common/splines.c index 79df01a3a..1ddab3aa8 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -1411,7 +1411,7 @@ int place_portlabel(edge_t * e, bool head_p) dist = PORT_LABEL_DISTANCE * late_double(e, E_labeldistance, 1.0, 0.0); l->pos.x = pe.x + dist * cos(angle); l->pos.y = pe.y + dist * sin(angle); - l->set = TRUE; + l->set = true; return 1; } diff --git a/lib/common/types.h b/lib/common/types.h index aaf389d43..bb96d83b4 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -133,8 +133,8 @@ extern "C" { htmllabel_t *html; } u; char valign; /* 't' 'c' 'b' */ - boolean set; /* true if position is set */ - boolean html; /* true if html label */ + bool set; /* true if position is set */ + bool html; /* true if html label */ } textlabel_t; typedef struct polygon_t { /* mutable shape information for a node */ diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index 383bede8b..9232cc2a1 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -294,7 +294,7 @@ setEdgeLabelPos (graph_t * g) l = ED_label(fe); assert (l); l->pos = ND_coord(n); - l->set = TRUE; + l->set = true; } else if ((l = ND_label(n))) {// label of regular edge place_vnlabel(n); @@ -375,7 +375,7 @@ static void _dot_splines(graph_t * g, int normalize) edge_t* fe = (edge_t*)ND_alg(n); assert (ED_label(fe)); ED_label(fe)->pos = ND_coord(n); - ED_label(fe)->set = TRUE; + ED_label(fe)->set = true; } if (ND_node_type(n) != NORMAL && !sinfo.splineMerge(n)) continue; @@ -600,7 +600,7 @@ place_vnlabel(node_t * n) width = GD_flip(agraphof(n)) ? dimen.y : dimen.x; ED_label(e)->pos.x = ND_coord(n).x + width / 2.0; ED_label(e)->pos.y = ND_coord(n).y; - ED_label(e)->set = TRUE; + ED_label(e)->set = true; } static void @@ -1067,7 +1067,7 @@ makeSimpleFlatLabels (node_t* tn, node_t* hn, edge_t** edges, int ind, int cnt, clip_and_install(e, aghead(e), points, pointn, &sinfo); ED_label(e)->pos.x = ctrx; ED_label(e)->pos.y = tp.y + (ED_label(e)->dimen.y+LBL_SPACE)/2.0; - ED_label(e)->set = TRUE; + ED_label(e)->set = true; miny = tp.y + LBL_SPACE/2.0; maxy = miny + ED_label(e)->dimen.y; @@ -1126,7 +1126,7 @@ makeSimpleFlatLabels (node_t* tn, node_t* hn, edge_t** edges, int ind, int cnt, } ED_label(e)->pos.x = ctrx; ED_label(e)->pos.y = ctry; - ED_label(e)->set = TRUE; + ED_label(e)->set = true; clip_and_install(e, aghead(e), ps, pn, &sinfo); free(ps); } @@ -1382,7 +1382,7 @@ make_flat_adj_edges(graph_t* g, path* P, edge_t** edges, int ind, int cnt, edge_ } if (ED_label(e)) { ED_label(e)->pos = transformf(ED_label(auxe)->pos, del, GD_flip(g)); - ED_label(e)->set = TRUE; + ED_label(e)->set = true; updateBB(g, ED_label(e)); } } @@ -1448,7 +1448,7 @@ make_flat_labeled_edge(graph_t* g, spline_info_t* sp, path* P, edge_t* e, int et for (f = ED_to_virt(e); ED_to_virt(f); f = ED_to_virt(f)); ln = agtail(f); ED_label(e)->pos = ND_coord(ln); - ED_label(e)->set = TRUE; + ED_label(e)->set = true; if (et == EDGETYPE_LINE) { pointf startp, endp, lp; diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 18317e045..9092c4267 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -177,7 +177,7 @@ static void set_label(void* obj, textlabel_t * l, char *name) lp = agget(obj, name); if (lp && sscanf(lp, "%lf,%lf", &x, &y) == 2) { l->pos = pointfof(x, y); - l->set = TRUE; + l->set = true; } } @@ -497,7 +497,7 @@ nop_init_graphs(Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb) s = agxget(g, G_lp); if (sscanf(s, "%lf,%lf", &x, &y) == 2) { GD_label(g)->pos = pointfof(x, y); - GD_label(g)->set = TRUE; + GD_label(g)->set = true; } } @@ -562,7 +562,7 @@ int init_nop(Agraph_t * g, int adjust) didAdjust = adjustNodes(g); if (didAdjust) { - if (GD_label(g)) GD_label(g)->set = FALSE; + if (GD_label(g)) GD_label(g)->set = false; /* FIX: * - if nodes are moved, clusters are no longer valid. */ -- 2.40.0