summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/pdftexdir/writezip.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/pdftexdir/writezip.c')
-rw-r--r--Build/source/texk/web2c/pdftexdir/writezip.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/writezip.c b/Build/source/texk/web2c/pdftexdir/writezip.c
index 3669397617c..a24d7fffdd1 100644
--- a/Build/source/texk/web2c/pdftexdir/writezip.c
+++ b/Build/source/texk/web2c/pdftexdir/writezip.c
@@ -17,14 +17,12 @@ You should have received a copy of the GNU General Public License
along with pdfTeX; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/writezip.c#7 $
+$Id: writezip.c,v 1.2 2006/01/14 20:35:43 hahe Exp $
*/
#include "ptexlib.h"
#include "zlib.h"
-
-static const char perforce_id[] =
- "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/writezip.c#7 $";
+#include <assert.h>
#define ZIP_BUF_SIZE 32768
@@ -32,37 +30,29 @@ static const char perforce_id[] =
if (f != Z_OK) \
pdftex_fail("zlib: %s() failed", fn)
-
static char zipbuf[ZIP_BUF_SIZE];
-static z_stream c_stream; /* compression stream */
+static z_stream c_stream; /* compression stream */
void writezip(boolean finish)
{
int err;
-
- if (!getpdfcompresslevel()) {
- if (pdfptr) {
- pdfgone += xfwrite(pdfbuf, 1, pdfptr, pdffile);
- pdfstreamlength += pdfptr;
- }
- return;
- }
-
+ assert(getpdfcompresslevel() > 0);
cur_file_name = NULL;
if (pdfstreamlength == 0) {
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
+ c_stream.zalloc = (alloc_func) 0;
+ c_stream.zfree = (free_func) 0;
+ c_stream.opaque = (voidpf) 0;
check_err(deflateInit(&c_stream, getpdfcompresslevel()), "deflateInit");
- c_stream.next_out = (Bytef*)zipbuf;
+ c_stream.next_out = (Bytef *) zipbuf;
c_stream.avail_out = ZIP_BUF_SIZE;
}
c_stream.next_in = pdfbuf;
c_stream.avail_in = pdfptr;
- for(;;) {
+ for (;;) {
if (c_stream.avail_out == 0) {
pdfgone += xfwrite(zipbuf, 1, ZIP_BUF_SIZE, pdffile);
- c_stream.next_out = (Bytef*)zipbuf;
+ pdflastbyte = zipbuf[ZIP_BUF_SIZE - 1]; /* not needed */
+ c_stream.next_out = (Bytef *) zipbuf;
c_stream.avail_out = ZIP_BUF_SIZE;
}
err = deflate(&c_stream, finish ? Z_FINISH : Z_NO_FLUSH);
@@ -73,8 +63,11 @@ void writezip(boolean finish)
break;
}
if (finish) {
- if (c_stream.avail_out < ZIP_BUF_SIZE) /* at least one byte has been output */
- pdfgone += xfwrite(zipbuf, 1, ZIP_BUF_SIZE - c_stream.avail_out, pdffile);
+ if (c_stream.avail_out < ZIP_BUF_SIZE) { /* at least one byte has been output */
+ pdfgone +=
+ xfwrite(zipbuf, 1, ZIP_BUF_SIZE - c_stream.avail_out, pdffile);
+ pdflastbyte = zipbuf[ZIP_BUF_SIZE - c_stream.avail_out - 1];
+ }
check_err(deflateEnd(&c_stream), "deflateEnd");
xfflush(pdffile);
}