]> granicus.if.org Git - graphviz/commitdiff
fix attribute write bug (from agraph)
authornorth <devnull@localhost>
Mon, 28 Jan 2008 21:40:51 +0000 (21:40 +0000)
committernorth <devnull@localhost>
Mon, 28 Jan 2008 21:40:51 +0000 (21:40 +0000)
lib/cgraph/write.c

index ebf87e596ed1d200fdd3fedad64bf925765b8617..c382d7e5268874a1aa7dc6d66555c756887ea2ab 100644 (file)
@@ -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);