]> granicus.if.org Git - graphviz/commitdiff
fix mutiple input graph postscript output
authorellson <devnull@localhost>
Fri, 27 May 2005 01:42:18 +0000 (01:42 +0000)
committerellson <devnull@localhost>
Fri, 27 May 2005 01:42:18 +0000 (01:42 +0000)
lib/common/emit.c
lib/common/input.c
lib/common/psgen.c
lib/gvc/gvrender.c

index c9d92f49ad9d5f72c9ac75c73c7ed75df1487b4b..1ae457d4746d6a6c6c97e6bedd67abe5ff64f677 100644 (file)
@@ -1752,13 +1752,12 @@ static void init_bb(graph_t *g)
 void emit_jobs (GVC_t * gvc, graph_t * g)
 {
     GVJ_t *job;
-    char *prev_langname = "";
 
     init_gvc_from_graph(gvc, g);
     init_layering(gvc, g);
     init_bb(g);
 
-    gvc->active_jobs = NULL;
+/*     gvc->active_jobs = NULL;  acive job sets can straddle multiple input graphs */
     for (job = gvrender_first_job(gvc); job; job = gvrender_next_job(gvc)) {
        job->g = g;
 
@@ -1775,21 +1774,23 @@ void emit_jobs (GVC_t * gvc, graph_t * g)
            return;
        }
 
+        
+       if (gvc->active_jobs && strcmp(job->output_langname,gvc->active_jobs->output_langname) != 0) {
+           /* finalize previous jobs */
+           gvrender_finalize(gvc);
+           /* clear active list */
+           gvc->active_jobs = NULL;
+        }
+       if (! gvc->active_jobs)
+           gvrender_initialize(gvc);
+
        /* insert job in active list */
        job->next_active = gvc->active_jobs;
        gvc->active_jobs = job;
 
-       if (strcmp(job->output_langname,prev_langname) != 0) {
-           prev_langname = job->output_langname;
-           gvrender_initialize(gvc);
-       }
-
         emit_job(job, g);
 
-       if (!job->next || strcmp(job->next->output_langname,prev_langname) != 0) {
-           gvrender_finalize(gvc);
-           /* clear active list */
-           gvc->active_jobs = NULL;
-        }
+       /* last job, after all input graphs are processed, is finalized from dotneato_terminate() */
+
     }
 }
index 61908bce12d4b861016d4e3ace515393848f68dd..6bcfd9bc921592b3942598f5fc017d510ae6ee7a 100644 (file)
@@ -745,6 +745,7 @@ void do_graph_label(graph_t * sg)
 
 void dotneato_terminate(GVC_t * gvc)
 {
+    gvrender_finalize(gvc);
     emit_jobs_eof(gvc);
     exit(graphviz_errors + agerrors());
 }
index 69cc85902ca0dda4f22d8ef4a4ae356d2e9682f8..66d10883fe38cef3d4c1b554940f058317e9414b 100644 (file)
@@ -74,13 +74,15 @@ ps_begin_job(FILE * ofp, graph_t * g, char **lib, char *user, char *info[],
     U_lib = lib;
     /* wrong when drawing more than one than one graph - use (atend) */
     N_pages = pages.x * pages.y;
-    Cur_page = 0;
-    fprintf(Output_file, "%%!PS-Adobe-2.0\n");
-    fprintf(Output_file, "%%%%Creator: %s version %s (%s)\n",
-           info[0], info[1], info[2]);
-    fprintf(Output_file, "%%%%For: %s\n", user);
-    fprintf(Output_file, "%%%%Title: %s\n", g->name);
-    fprintf(Output_file, "%%%%Pages: (atend)\n");
+    if (onetime) {
+        Cur_page = 0;
+        fprintf(Output_file, "%%!PS-Adobe-2.0\n");
+        fprintf(Output_file, "%%%%Creator: %s version %s (%s)\n",
+               info[0], info[1], info[2]);
+        fprintf(Output_file, "%%%%For: %s\n", user);
+        fprintf(Output_file, "%%%%Title: %s\n", g->name);
+        fprintf(Output_file, "%%%%Pages: (atend)\n");
+    }
 
     /* remainder is emitted by first begin_graph */
 }
index d67ed4504dd40a00445fd528af13cc840aa12d63..131fbe669de4b37f908a24f62b6d062fb1b9b906 100644 (file)
@@ -132,7 +132,7 @@ void gvrender_initialize(GVC_t * gvc)
 
 void gvrender_finalize(GVC_t * gvc)
 {
-    GVJ_t *job = gvc->job;
+    GVJ_t *job = gvc->active_jobs;
     gvrender_engine_t *gvre = job->render_engine;
 
     if (gvre) {