From: ellson Date: Wed, 15 Oct 2008 17:47:24 +0000 (+0000) Subject: cgraph changes X-Git-Tag: LAST_LIBGRAPH~32^2~3108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b09bcaaab83eac98b06fe6b8b06414d9d275ff1d;p=graphviz cgraph changes --- diff --git a/lib/common/output.c b/lib/common/output.c index 95eef95d7..79afc8433 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -45,15 +45,17 @@ static void setYInvert(graph_t * g) /* canon: * Canonicalize a string which may not have been allocated using agstrdup. */ -static char* canon (char* s) +static char* canon (graph_t *g, char* s) { - char* ns = agstrdup (s); #ifndef WITH_CGRAPH + char* ns = agstrdup (s); char* cs = agcanonical (ns); + agstrfree (ns); #else + char* ns = agstrdup (g, s); char* cs = agcanonStr (ns); + agstrfree (g, ns); #endif - agstrfree (ns); return cs; } @@ -61,7 +63,7 @@ static void writenodeandport(FILE * fp, node_t * node, char *port) { char *name; if (IS_CLUST_NODE(node)) - name = canon (strchr(agnameof(node), ':') + 1); + name = canon (agraphof(node), strchr(agnameof(node), ':') + 1); else #ifndef WITH_CGRAPH name = agcanonical (agnameof(node)); @@ -114,11 +116,7 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) lbl = agcanonStr (agxget(n, N_label)); #endif else -#ifndef WITH_CGRAPH - lbl = canon(ND_label(n)->text); -#else lbl = canon(agraphof(n),ND_label(n)->text); -#endif fprintf(f, " %.5g %.5g %s %s %s %s %s\n", ND_width(n), ND_height(n), lbl, late_nnstring(n, N_style, "solid"), @@ -169,11 +167,7 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) } } if (ED_label(e)) { -#ifndef WITH_CGRAPH - fprintf(f, " %s", canon(ED_label(e)->text)); -#else fprintf(f, " %s", canon(agraphof(e),ED_label(e)->text)); -#endif printptf(f, ED_label(e)->pos); } fprintf(f, " %s %s\n", late_nnstring(e, E_style, "solid"), diff --git a/lib/common/types.h b/lib/common/types.h index d21064348..15e9b580b 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -741,10 +741,21 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #ifdef WITH_CGRAPH #include "cgraph.h" +#define SET_RANKDIR(g,rd) (GD_rankdir2(g) = rd) #else #include "graph.h" +#define SET_RANKDIR(g,rd) ((g)->u.rankdir = (rd)) +#define agnameof(x) ((x)->name) + /* warning, agraphof doesn't work for edges */ +#define agraphof(n) ((n)->graph) +#define agroot(g) ((g)->root) +#define aghead(e) ((e)->head) +#define agtail(e) ((e)->tail) +#define agisdirected(g) ((g)->kind & AGFLAG_DIRECTED) +#define AGID(x) ((x)->id) #endif + typedef struct { int useGrid; /* use grid for speed up */ int useNew; /* encode x-K into attractive force */