]> granicus.if.org Git - graphviz/commitdiff
some more checks for (ab)use of proto*
authorJohn Ellson <ellson@research.att.com>
Thu, 23 Feb 2012 16:09:37 +0000 (11:09 -0500)
committerJohn Ellson <ellson@research.att.com>
Thu, 23 Feb 2012 16:09:37 +0000 (11:09 -0500)
tclpkg/gv/gv.cpp

index 29596413ef192d2a2c68eaa6f5a6b57d5b4da196..2376713f26d18019cfd177308d1b0c80e0d1c84d 100644 (file)
@@ -148,6 +148,9 @@ Agedge_t *edge(Agnode_t *t, Agnode_t *h)
     if (!gvc || !t || !h)
         return NULL;
 #ifdef WITH_CGRAPH
+    // edges from/to the protonode are not permitted
+    if (AGTYPE(t) == AGRAPH || AGTYPE(h) == AGRAPH)
+       return NULL;
     return agedge(agraphof(t), t, h, NULL, 1);
 #else
     // edges from/to the protonode are not permitted
@@ -429,6 +432,10 @@ Agedge_t *findedge(Agnode_t *t, Agnode_t *h)
 {
     if (!t || !h)
         return NULL;
+#ifndef WITH_CGRAPH
+    if (AGTYPE(t) == AGRAPH || AGTYPE(h) == AGRAPH)
+       return NULL;
+#endif
     return agfindedge(agraphof(t), t, h);
 }
 
@@ -459,6 +466,10 @@ Agnode_t *headof(Agedge_t *e)
 {
     if (!e)
         return NULL;
+#ifndef WITH_CGRAPH
+    if (AGTYPE(e) == AGRAPH)
+       return NULL;
+#endif
     return aghead(e);
 }
 
@@ -466,6 +477,10 @@ Agnode_t *tailof(Agedge_t *e)
 {
     if (!e)
         return NULL;
+#ifndef WITH_CGRAPH
+    if (AGTYPE(e) == AGRAPH)
+       return NULL;
+#endif
     return agtail(e);
 }
 
@@ -480,6 +495,10 @@ Agraph_t *graphof(Agedge_t *e)
 {
     if (!e)
         return NULL;
+#ifndef WITH_CGRAPH
+    if (AGTYPE(e) == AGRAPH)
+       return (Agraph_t*)e; /* graph of protoedge is itself recast */
+#endif
     return agraphof(agtail(e));
 }
 
@@ -487,6 +506,10 @@ Agraph_t *graphof(Agnode_t *n)
 {
     if (!n)
         return NULL;
+#ifndef WITH_CGRAPH
+    if (AGTYPE(e) == AGRAPH)
+       return (Agraph_t*)n;  /* graph of protonode is itself recast */
+#endif
     return agraphof(n);
 }
 
@@ -531,12 +554,20 @@ char *nameof(Agnode_t *n)
 {
     if (!n)
         return NULL;
+#ifndef WITH_CGRAPH
+    if (AGTYPE(n) == AGRAPH)
+       return NULL;
+#endif
     return agnameof(n);
 }
 //char *nameof(Agedge_t *e)
 //{
 //    if (!e)
 //        return NULL;
+//#ifndef WITH_CGRAPH
+//    if (AGTYPE(e) == AGRAPH)
+//     return NULL;
+//#endif
 //    return agnameof(e);
 //}
 char *nameof(Agsym_t *a)