When a graph or subgraph contained exclusively subnodes that were clusters (that
is, it contained a non-zero number of subnodes, but all of them were clusters),
the output of `-Tjson` would contain an extra comma. This malformed JSON could
not be ingested by most downstream parsers.
This appears to have been a mistake in
f82c51fc9644047e9ce80d860fea562e98d3311c
that introduced cluster skipping in the loop that emits nodes in JSON. It did
not account for the earlier part of the containing function that was intended to
early-exit if the loop would have a 0 iteration count.
As noted in the discussion of #2282, a couple of the maintainers believe this
manual JSON writing code is inherently fragile and likely contains more latent
bugs. But we do not have maintainer consensus on migrating to an established
JSON-writing library. This fix attempts to surgically address the current known
bug. But I cannot guarantee it does not introduce others.
Gitlab: fixes #2282
a regression in 2.49.2 See #2279 for details.
- Graphviz no longer fails to load private Ghostscript symbols ("Could not load
`libgvplugin_gs.so.6`) #2280
+- trailing commas issue with fdp layout #2282
## [6.0.1] – 2022-09-11
}
static int write_nodes(Agraph_t *g, GVJ_t *job, bool top, bool has_subgs, state_t *sp) {
- Agnode_t* n;
- n = agfstnode(g);
- if (!n) {
+ // is every subcomponent of this graph a cluster?
+ bool only_clusters = true;
+ for (Agnode_t *n = agfstnode(g); n; n = agnxtnode(g, n)) {
+ if (!IS_CLUST_NODE(n)) {
+ only_clusters = false;
+ break;
+ }
+ }
+
+ if (only_clusters) {
if (has_subgs && top) {
sp->Level--;
gvputs(job, "\n");
indent(job, sp->Level);
}
const char *separator = "";
- for (; n; n = agnxtnode(g, n)) {
+ for (Agnode_t *n = agfstnode(g); n; n = agnxtnode(g, n)) {
if (IS_CLUST_NODE(n)) continue;
gvputs(job, separator);
write_node (n, job, top, sp);
# run the test
run_c(c_src, link=["cgraph", "gvc"])
-@pytest.mark.xfail(strict=True)
def test_2282():
"""
using the `fdp` layout with JSON output should result in valid JSON