]> granicus.if.org Git - graphviz/commitdiff
Change semantics of agnameof() so that NULL is returned for anonymous edges.
authorerg <devnull@localhost>
Thu, 8 Nov 2007 21:41:21 +0000 (21:41 +0000)
committererg <devnull@localhost>
Thu, 8 Nov 2007 21:41:21 +0000 (21:41 +0000)
lib/cgraph/id.c

index 59d03166055cd2a5436997b9530e36e90ef7c261..3121962eeab12a8158955186ef99d88f74f34d9c 100644 (file)
@@ -129,6 +129,12 @@ void agfreeid(Agraph_t * g, int objtype, unsigned long id)
     (AGDISC(g, id)->free) (AGCLOS(g, id), objtype, id);
 }
 
+/* agnameof:
+ * Return string representation of object.
+ * In general, returns the name of node or graph,
+ * and the key of an edge. If edge is anonymous, returns NULL.
+ * Uses static buffer for anonymous graphs.
+ */
 char *agnameof(void *obj)
 {
     Agraph_t *g;
@@ -145,9 +151,11 @@ char *agnameof(void *obj)
             AGDISC(g, id)->print(AGCLOS(g, id), AGTYPE(obj), AGID(obj))))
            return rv;
     }
-    if (AGTYPE(obj) != AGEDGE)
+    if (AGTYPE(obj) != AGEDGE) {
        sprintf(buf, "%c%ld", LOCALNAMEPREFIX, AGID(obj));
+       rv = buf;
+    }
     else
-       buf[0] = 0;
-    return buf;
+       rv = 0;
+    return rv;
 }