summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/pdftexdir/writezip.c
diff options
context:
space:
mode:
authorMartin Schröder <martin@oneiros.de>2006-12-26 23:37:34 +0000
committerMartin Schröder <martin@oneiros.de>2006-12-26 23:37:34 +0000
commit812aa90acbef4930ae356ab194f3f2a8f573f6e4 (patch)
treea1b8b3d895238994c60580df9e6f0619b2034923 /Build/source/texk/web2c/pdftexdir/writezip.c
parente3bba99884ce591c9485122e96fff7071fc7c112 (diff)
Import pdftex 1.40-rc4, which also changes the signature of
print_version_and_exit, and adds a new library (libs/obsdcompat). git-svn-id: svn://tug.org/texlive/trunk@2959 c570f23f-e606-0410-a88d-b1316a301751
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);
}