From 4048db7dc932aac332c5302a272ea9342438f43c Mon Sep 17 00:00:00 2001 From: John Ellson Date: Thu, 23 Feb 2012 11:09:37 -0500 Subject: [PATCH] some more checks for (ab)use of proto* --- tclpkg/gv/gv.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tclpkg/gv/gv.cpp b/tclpkg/gv/gv.cpp index 29596413e..2376713f2 100644 --- a/tclpkg/gv/gv.cpp +++ b/tclpkg/gv/gv.cpp @@ -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) -- 2.40.0