From: Emden Gansner Date: Fri, 30 Oct 2015 18:04:07 +0000 (-0400) Subject: Allow graphs and subgraphs to have an empty string as a name. X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~92 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80d6ed709b365d39fe63dd279d137749a7ae42c2;p=graphviz 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. --- 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"));