From: north Date: Mon, 28 Jan 2008 21:40:51 +0000 (+0000) Subject: fix attribute write bug (from agraph) X-Git-Tag: LAST_LIBGRAPH~32^2~4808 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d67f671f2ac54b63970a192308f476176dbf061a;p=graphviz fix attribute write bug (from agraph) --- diff --git a/lib/cgraph/write.c b/lib/cgraph/write.c index ebf87e596..c382d7e52 100644 --- a/lib/cgraph/write.c +++ b/lib/cgraph/write.c @@ -258,7 +258,7 @@ static void write_hdr(Agraph_t * g, iochan_t * ofile, int top) ioput(g, ofile, "{\n"); Level++; write_dicts(g, ofile); - AGATTRWF(g) = NOT(AGATTRWF(g)); + AGATTRWF(g) = TRUE; } static void write_trl(Agraph_t * g, iochan_t * ofile) @@ -425,7 +425,7 @@ static void write_nondefault_attrs(void *obj, iochan_t * ofile, ioput(g, ofile, "]"); Level--; } - AGATTRWF((Agobj_t *) obj) = NOT(AGATTRWF((Agobj_t *) obj)); + AGATTRWF((Agobj_t *) obj) = TRUE; } static void write_nodename(Agnode_t * n, iochan_t * ofile) @@ -445,7 +445,7 @@ static void write_nodename(Agnode_t * n, iochan_t * ofile) static int attrs_written(void *obj) { - return NOT(AGATTRWF((Agobj_t *) obj) == Attrs_not_written_flag); + return (AGATTRWF((Agobj_t *) obj)); } static void write_node(Agnode_t * n, iochan_t * ofile, Dict_t * d) @@ -560,9 +560,29 @@ static void write_body(Agraph_t * g, iochan_t * ofile) } } +static void set_attrwf(Agraph_t *g, int toplevel, int value) +{ + Agraph_t *subg; + Agnode_t *n; + Agedge_t *e; + + AGATTRWF(g) = value; + for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) { + set_attrwf(subg, FALSE, value); + } + if (toplevel) { + for (n = agfstnode(g); n; n = agnxtnode(g,n)) { + AGATTRWF(n) = value; + for (e = agfstout(g,n); e; e = agnxtout(g,e)) + AGATTRWF(e) = value; + } + } +} + int agwrite(Agraph_t * g, void *ofile) { Level = 0; /* re-initialize tab level */ + set_attrwf(g,TRUE,FALSE); write_hdr(g, ofile, TRUE); write_body(g, ofile); write_trl(g, ofile);