From: ellson Date: Wed, 15 Oct 2008 19:31:12 +0000 (+0000) Subject: a few fixes for cgraph merge X-Git-Tag: LAST_LIBGRAPH~32^2~3104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d761238009e8c715b830acb7a1eb105b1dc868c3;p=graphviz a few fixes for cgraph merge --- diff --git a/lib/common/emit.c b/lib/common/emit.c index 81037d7c1..0ee93c34e 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1024,7 +1024,11 @@ static boolean clust_in_layer(GVJ_t *job, graph_t * sg) if (job->numLayers <= 1) return TRUE; +#ifndef WITH_CGRAPH + pg = late_string(sg, agfindattr(sg, "layer"), ""); +#else pg = late_string(sg, agfindattr(sg, "layer"), ""); +#endif if (selectedlayer(job, pg)) return TRUE; if (pg[0]) @@ -1564,7 +1568,7 @@ static void emit_begin_edge(GVJ_t * job, edge_t * e, char** styles) if (flags & GVRENDER_DOES_MAPS) { s = agget(e, "id"); if (!s || !*s) { /* no external id, so use the internal one */ - sprintf(buf,"edge%d", AGID(e)); + sprintf(buf,"edge%ld", AGID(e)); s = buf; } obj->id = strdup_and_subst_obj(s, (void*)e); @@ -2062,7 +2066,11 @@ static void init_job_viewport(GVJ_t * job, graph_t * g) junk = malloc(strlen(str)+1); rv = sscanf(str, "%lf,%lf,%lf,\'%[^\']\'", &X, &Y, &Z, nodename); if (rv == 4) { +#ifndef WITH_CGRAPH n = agfindnode(g->root, nodename); +#else + n = agnode(g->root, nodename, 0); +#endif if (n) { x = ND_coord(n).x; y = ND_coord(n).y; @@ -2071,7 +2079,11 @@ static void init_job_viewport(GVJ_t * job, graph_t * g) else { rv = sscanf(str, "%lf,%lf,%lf,%[^,]%s", &X, &Y, &Z, nodename, junk); if (rv == 4) { +#ifndef WITH_CGRAPH n = agfindnode(g->root, nodename); +#else + n = agnode(g->root, nodename, 0); +#endif if (n) { x = ND_coord(n).x; y = ND_coord(n).y; diff --git a/lib/common/input.c b/lib/common/input.c index 9329284d8..1d7774158 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -167,11 +167,11 @@ static void use_library(GVC_t *gvc, const char *name) } #ifdef WITH_CGRAPH -static void global_def(const char *dcl,int kind, +static void global_def(char *dcl, int kind, attrsym_t * ((*dclfun) (Agraph_t *, int kind, char *, char *)) ) { char *p; - const char *rhs = "true"; + char *rhs = "true"; attrsym_t *sym; if ((p = strchr(dcl, '='))) { @@ -182,11 +182,11 @@ static void global_def(const char *dcl,int kind, sym->fixed = 1; } #else -static void global_def(const char *dcl, +static void global_def(char *dcl, attrsym_t * ((*dclfun) (Agraph_t *, char *, char *))) { char *p; - const char *rhs = "true"; + char *rhs = "true"; attrsym_t *sym; if ((p = strchr(dcl, '='))) { @@ -224,8 +224,8 @@ graph_t *gvPluginsGraph(GVC_t *gvc) void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) { - char c; - const char *rest, *val; + char c, *rest; + const char *val; int i, v, nfiles; /* establish if we are running in a CGI environment */ @@ -270,7 +270,7 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) case 'G': if (*rest) #ifdef WITH_CGRAPH - global_def(rest,AGRAPH,agattr); + global_def(rest, AGRAPH, agattr); #else global_def(rest, agraphattr); #endif diff --git a/lib/common/output.c b/lib/common/output.c index 993c73560..83d449210 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -79,11 +79,6 @@ static void writenodeandport(FILE * fp, node_t * node, char *port) #endif } -/* FIXME - there must be a proper way to get port info - these are - * supposed to be private to libgraph - from libgraph.h */ -#define TAILX 1 -#define HEADX 2 - /* _write_plain: */ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) @@ -126,20 +121,24 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) } for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { + +/* FIXME - there must be a proper way to get port info - these are + * supposed to be private to libgraph - from libgraph.h */ +#define TAILX 1 +#define HEADX 2 + #ifndef WITH_CGRAPH if (extend && e->attr) { tport = e->attr[TAILX]; hport = e->attr[HEADX]; - } else + } #else /* WITH_CGRAPH */ - - if (extend) { //assuming these two attrs have already been created by cgraph - - tport =agget(e,TAILX); - hport = agget(e,HEADX); + if (extend) { //assuming these two attrs have already been created by cgraph + tport = agget(e,TAILX); + hport = agget(e,HEADX); } - else #endif /* WITH_CGRAPH */ + else tport = hport = ""; if (ED_spl(e)) { splinePoints = 0; @@ -148,17 +147,9 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) splinePoints += bz.size; } fprintf(f, "edge "); -#ifndef WITH_CGRAPH - writenodeandport(f, e->tail, tport); -#else /* WITH_CGRAPH */ writenodeandport(f, agtail(e), tport); -#endif /* WITH_CGRAPH */ fprintf(f, " "); -#ifndef WITH_CGRAPH - writenodeandport(f, e->head, hport); -#else /* WITH_CGRAPH */ writenodeandport(f, aghead(e), hport); -#endif /* WITH_CGRAPH */ fprintf(f, " %d", splinePoints); for (i = 0; i < ED_spl(e)->size; i++) { bz = ED_spl(e)->list[i]; diff --git a/lib/common/psusershape.c b/lib/common/psusershape.c index 52d8cbd84..ce2fa2367 100644 --- a/lib/common/psusershape.c +++ b/lib/common/psusershape.c @@ -42,7 +42,7 @@ static Dtdisc_t ImageDictDisc = { NIL(Dtevent_f) }; -static usershape_t *user_init(char *str) +static usershape_t *user_init(const char *str) { char *contents; char line[BUFSIZ]; @@ -100,7 +100,7 @@ static usershape_t *user_init(char *str) void epsf_init(node_t * n) { epsf_t *desc; - char *str; + const char *str; usershape_t *us; int dx, dy; @@ -117,11 +117,7 @@ void epsf_init(node_t * n) desc->offset.x = -us->x - (dx) / 2; desc->offset.y = -us->y - (dy) / 2; } else -#ifndef WITH_CGRAPH - agerr(AGWARN, "shapefile not set for epsf node %s\n", n->name); -#else /* WITH_CGRAPH */ agerr(AGWARN, "shapefile not set for epsf node %s\n", agnameof(n)); -#endif /* WITH_CGRAPH */ } void epsf_free(node_t * n)