]> granicus.if.org Git - graphviz/commitdiff
fix flushing of zlib buffers
authorellson <devnull@localhost>
Tue, 9 Sep 2008 15:13:48 +0000 (15:13 +0000)
committerellson <devnull@localhost>
Tue, 9 Sep 2008 15:13:48 +0000 (15:13 +0000)
lib/gvc/gvdevice.c

index 6c5088698fda67abe9b0b823f3e1177d51bbe337..f01be80c16db99c150fe6d615a47efcc41540820 100644 (file)
@@ -283,9 +283,7 @@ static void gvdevice_flush(GVJ_t * job)
 {
     if (job->output_file
       && ! job->external_context
-      && ! job->gvc->write_fn
-      && job->output_lang != TK
-      && ! (job->flags & GVDEVICE_COMPRESSED_FORMAT)) {
+      && ! job->gvc->write_fn) {
        fflush(job->output_file);
     }
 }
@@ -329,8 +327,12 @@ void gvdevice_finalize(GVJ_t * job)
        z->avail_in = 0;
        z->next_out = df;
        z->avail_out = dfallocated;
-       ret = deflate (z, Z_FINISH);
-       if (ret != Z_STREAM_END && ret != Z_OK) {
+       while ((ret = deflate (z, Z_FINISH)) == Z_OK && (cnt++ <= 100)) {
+           gvwrite_no_z(job, (char*)df, z->next_out - df);
+           z->next_out = df;
+           z->avail_out = dfallocated;
+       }
+       if (ret != Z_STREAM_END) {
             (job->common->errorfn) ("deflation finish problem %d cnt=%d\n", ret, cnt);
            exit(1);
        }