From 80d6ed709b365d39fe63dd279d137749a7ae42c2 Mon Sep 17 00:00:00 2001 From: Emden Gansner Date: Fri, 30 Oct 2015 14:04:07 -0400 Subject: [PATCH] Allow graphs and subgraphs to have an empty string as a name. Besides there being no reason not to, this avoids exposing in internal %x name for anonymous graphs in a tootltip. --- lib/cgraph/write.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/cgraph/write.c b/lib/cgraph/write.c index 77ffbffc7..fb74f7106 100644 --- a/lib/cgraph/write.c +++ b/lib/cgraph/write.c @@ -300,6 +300,7 @@ static int write_hdr(Agraph_t * g, iochan_t * ofile, int top) { char *name, *sep, *kind, *strict; int root = 0; + int hasName = 1; Attrs_not_written_flag = AGATTRWF(g); strict = ""; @@ -318,17 +319,19 @@ static int write_hdr(Agraph_t * g, iochan_t * ofile, int top) } name = agnameof(g); sep = " "; - if (!name || name[0] == LOCALNAMEPREFIX) + if (!name || name[0] == LOCALNAMEPREFIX) { sep = name = ""; + hasName = 0; + } CHKRV(indent(g, ofile)); CHKRV(ioput(g, ofile, strict)); /* output "graph" only for root graphs or graphs with names */ - if (*name || root) { + if (root || hasName) { CHKRV(ioput(g, ofile, kind)); CHKRV(ioput(g, ofile, "graph ")); } - if (name[0]) + if (hasName) CHKRV(write_canonstr(g, ofile, name)); CHKRV(ioput(g, ofile, sep)); CHKRV(ioput(g, ofile, "{\n")); -- 2.40.0