From: ellson Date: Tue, 1 Feb 2005 18:56:27 +0000 (+0000) Subject: Merge emit_eof() and dotneato_eof() into emit_jobs_eof(), eliminating one from render... X-Git-Tag: LAST_LIBGRAPH~32^2~7961 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfc1af5727b6ff920ae7da3f5da40ba6fac55901;p=graphviz Merge emit_eof() and dotneato_eof() into emit_jobs_eof(), eliminating one from renderprocs.h Be consistent about generation of global variable: Output_lang, Output_file, Obj Make rec_attach_bb() static in output.c and remove from renderprocs.h --- diff --git a/lib/common/emit.c b/lib/common/emit.c index e30597ee1..f78ccee3b 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -25,7 +25,6 @@ #include "gvc.h" #include -int Obj; static attrsym_t *G_peripheries; static char *defaultlinestyle[3] = { "solid\0", "setlinewidth\0001\0", 0 }; @@ -1237,11 +1236,19 @@ static void emit_once_reset() } } -void emit_eof(GVC_t * gvc) +void emit_jobs_eof(GVC_t * gvc) { - if (gvc->job->pageNum > 0) { - emit_deinit_job(gvc); - emit_once_reset(); + gvrender_job_t *job; + + for (job = gvrender_first_job(gvc); job; job = gvrender_next_job(gvc)) { + if (job->output_file) { + if (gvc->job->pageNum > 0) { + emit_deinit_job(gvc); + emit_once_reset(); + } + fclose(job->output_file); + job->output_file = NULL; + } } } diff --git a/lib/common/globals.h b/lib/common/globals.h index c8b7d1a64..7de767dc1 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -60,9 +60,9 @@ extern "C" { external int y_invert; /* invert y in dot & plain output */ #ifndef DISABLE_CODEGENS - external int Output_lang; /* POSTSCRIPT, DOT, etc. */ - external FILE *Output_file; - external int Obj; + EXTERN int Output_lang; /* POSTSCRIPT, DOT, etc. */ + EXTERN FILE *Output_file; + EXTERN int Obj; extern codegen_t FIG_CodeGen, HPGL_CodeGen, MAP_CodeGen, MIF_CodeGen, XDot_CodeGen, MP_CodeGen, PIC_CodeGen, diff --git a/lib/common/input.c b/lib/common/input.c index b96f68cd5..d7d21e8f3 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -698,7 +698,7 @@ void do_graph_label(graph_t * sg) void dotneato_terminate(GVC_t * gvc) { - dotneato_eof(gvc); + emit_jobs_eof(gvc); exit(graphviz_errors + agerrors()); } diff --git a/lib/common/output.c b/lib/common/output.c index 7c2af179c..e726c81f1 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -18,11 +18,6 @@ #include "gvc.h" #include "agxbuf.h" -#ifndef DISABLE_CODEGENS -FILE *Output_file; -int Output_lang; -#endif - static int e_arrows; /* graph has edges with end arrows */ static int s_arrows; /* graph has edges with start arrows */ static agxbuf outbuf; @@ -336,19 +331,6 @@ void write_canonical_dot(graph_t *g, FILE *f) agwrite(g, f); } -void dotneato_eof(GVC_t * gvc) -{ - gvrender_job_t *job; - - for (job = gvrender_first_job(gvc); job; job = gvrender_next_job(gvc)) { - if (job->output_file) { - emit_eof(gvc); - fclose(job->output_file); - job->output_file = NULL; - } - } -} - static void set_record_rects(node_t * n, field_t * f, agxbuf * xb) { int i; @@ -366,6 +348,24 @@ static void set_record_rects(node_t * n, field_t * f, agxbuf * xb) set_record_rects(n, f->fld[i], xb); } +static void rec_attach_bb(graph_t * g) +{ + int c; + char buf[32]; + point pt; + + sprintf(buf, "%d,%d,%d,%d", GD_bb(g).LL.x, Y(GD_bb(g).LL.y), + GD_bb(g).UR.x, Y(GD_bb(g).UR.y)); + agset(g, "bb", buf); + if (GD_label(g) && GD_label(g)->text[0]) { + pt = GD_label(g)->p; + sprintf(buf, "%d,%d", pt.x, Y(pt.y)); + agset(g, "lp", buf); + } + for (c = 1; c <= GD_n_cluster(g); c++) + rec_attach_bb(GD_clust(g)[c]); +} + void attach_attrs(graph_t * g) { int i, j, sides; @@ -500,21 +500,3 @@ void attach_attrs(graph_t * g) if (HAS_CLUST_EDGE(g)) undoClusterEdges(g); } - -void rec_attach_bb(graph_t * g) -{ - int c; - char buf[32]; - point pt; - - sprintf(buf, "%d,%d,%d,%d", GD_bb(g).LL.x, Y(GD_bb(g).LL.y), - GD_bb(g).UR.x, Y(GD_bb(g).UR.y)); - agset(g, "bb", buf); - if (GD_label(g) && GD_label(g)->text[0]) { - pt = GD_label(g)->p; - sprintf(buf, "%d,%d", pt.x, Y(pt.y)); - agset(g, "lp", buf); - } - for (c = 1; c <= GD_n_cluster(g); c++) - rec_attach_bb(GD_clust(g)[c]); -} diff --git a/lib/common/renderprocs.h b/lib/common/renderprocs.h index 24406d921..48ab132ca 100644 --- a/lib/common/renderprocs.h +++ b/lib/common/renderprocs.h @@ -67,7 +67,6 @@ extern "C" { extern void dotneato_usage(int); extern void dotneato_postprocess(Agraph_t *, nodesizefn_t); extern void dotneato_set_margins(GVC_t * gvc, Agraph_t *); - extern void dotneato_eof(GVC_t * gvc); extern void dotneato_terminate(GVC_t * gvc); extern void dotneato_write(GVC_t * gvc, graph_t *g); extern void dotneato_write_one(GVC_t * gvc, graph_t *g); @@ -76,11 +75,11 @@ extern "C" { extern void enqueue_neighbors(queue *, Agnode_t *, int); extern void emit_attachment(GVC_t * gvc, textlabel_t *, splines *); extern void emit_clusters(GVC_t * gvc, Agraph_t * g, int flags); - extern void emit_eof(GVC_t * gvc); extern void emit_graph(GVC_t * gvc, graph_t * g); extern void emit_label(GVC_t * gvc, textlabel_t *, void *obj); extern int emit_once(char *message); extern void emit_jobs(GVC_t * gvc, graph_t *g); + extern void emit_jobs_eof(GVC_t * gvc); extern void endpath(path *, Agedge_t *, int, pathend_t *, boolean); extern void epsf_init(node_t * n); extern void epsf_free(node_t * n); @@ -149,7 +148,6 @@ extern "C" { extern int processClusterEdges(graph_t * g); extern char *ps_string(char *s); extern void rank(graph_t * g, int balance, int maxiter); - extern void rec_attach_bb(Agraph_t *); extern void routesplinesinit(void); extern point *routesplines(path *, int *); extern void routesplinesterm(void);