From: erg Date: Tue, 15 Nov 2005 22:55:48 +0000 (+0000) Subject: Fix no-op code in neato to be really no-op when gvpack is using it. X-Git-Tag: LAST_LIBGRAPH~32^2~6966 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5be56e08a0c7f9de17b34b1a3ef6649f2fdbb057;p=graphviz Fix no-op code in neato to be really no-op when gvpack is using it. --- diff --git a/cmd/tools/gvpack.c b/cmd/tools/gvpack.c index 438253d0a..6095f47e3 100644 --- a/cmd/tools/gvpack.c +++ b/cmd/tools/gvpack.c @@ -254,7 +254,7 @@ static void init_graph(Agraph_t * g, bool fill) } Ndim = GD_ndim(g) = 2; init_node_edge(g); - if (fill && init_nop(g)) { + if (fill && init_nop(g, 0)) { exit(1); } } diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 23b380d0b..bf5edaac8 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -201,9 +201,11 @@ static int numFields(unsigned char *pos) do { while (isspace(*pos)) pos++; /* skip white space */ - cnt++; - while ((c = *pos) && !isspace(c) && (c != ';')) - pos++; /* skip token */ + if (c = *pos) { /* skip token */ + cnt++; + while ((c = *pos) && !isspace(c) && (c != ';')) + pos++; + } } while (isspace(c)); return cnt; } @@ -286,6 +288,7 @@ static int user_spline(attrsym_t * E_pos, edge_t * e) pp++; n--; } + while (isspace(*pos)) pos++; if (*pos == '\0') more = 0; else @@ -535,7 +538,7 @@ static void translate(Agraph_t * g, pos_edge posEdges) * is missing, init_nop will use a standard neato technique to * supply it. */ -int init_nop(Agraph_t * g) +int init_nop(Agraph_t * g, int adjust) { int i; node_t *np; @@ -554,7 +557,7 @@ int init_nop(Agraph_t * g) nop_init_graphs(g, G_lp, G_bb); posEdges = nop_init_edges(g); - if (Nop == 1) + if (adjust && Nop == 1) adjustNodes(g); /* If G_bb not defined, define it */ @@ -568,20 +571,23 @@ int init_nop(Agraph_t * g) /* At this point, all bounding boxes should be correctly defined. * If necessary, we translate the graph to the origin. */ - if (GD_bb(g).LL.x || GD_bb(g).LL.y) + if (adjust && (GD_bb(g).LL.x || GD_bb(g).LL.y)) translate(g, posEdges); - if (posEdges != AllEdges) - spline_edges0(g); - else { + if (!adjust) { node_t *n; - neato_set_aspect(g); State = GVSPLINES; for (n = agfstnode(g); n; n = agnxtnode(g, n)) { ND_coord_i(n).x = POINTS(ND_pos(n)[0]); ND_coord_i(n).y = POINTS(ND_pos(n)[1]); } } + else if (posEdges != AllEdges) + spline_edges0(g); + else { + State = GVSPLINES; + neato_set_aspect(g); + } return 0; } @@ -1155,7 +1161,7 @@ void neato_layout(Agraph_t * g) neato_init_graph(g); if (Nop) { addZ (g); - if (init_nop(g)) { + if (init_nop(g, 1)) { agerr(AGPREV, "as required by the -n flag\n"); exit(1); } diff --git a/lib/neatogen/neatoprocs.h b/lib/neatogen/neatoprocs.h index 37d594dfe..93c4247d9 100644 --- a/lib/neatogen/neatoprocs.h +++ b/lib/neatogen/neatoprocs.h @@ -46,7 +46,7 @@ extern "C" { extern void makeSpline(edge_t *, Ppoly_t **, int, bool); extern void make_spring(graph_t *, Agnode_t *, Agnode_t *, double); extern void move_node(graph_t *, int, Agnode_t *); - extern int init_nop(graph_t * g); + extern int init_nop(graph_t * g, int); extern void neato_nodesize(node_t * n, bool flip); extern void neato_cleanup(graph_t * g); extern void neato_cleanup_edge(edge_t * e); diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index a89c71956..b5a8b77d5 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -909,7 +909,6 @@ static void _neato_set_aspect(graph_t * g) * allocate it in the root graph and the connected components. */ for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - /* for (i = 0; (n = GD_neato_nlist(g)[i]); i++) { */ ND_pos(n)[0] = ND_pos(n)[0] * xf; ND_pos(n)[1] = ND_pos(n)[1] * yf; } @@ -926,7 +925,7 @@ static void _neato_set_aspect(graph_t * g) } /* neato_set_aspect: - * Sets aspect ration if necessary; real work done in _neato_set_aspect; + * Sets aspect ratio if necessary; real work done in _neato_set_aspect; * This also copies the internal layout coordinates (ND_pos) to the * external ones (ND_coord_i). */