From 6759211ad8a5006689216a86c3267bb503bfccc1 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 9 Sep 2011 23:18:57 -0700 Subject: zlib 1.0.8 --- ChangeLog | 27 +++++++++- Makefile | 28 ++++++---- Makefile.in | 28 ++++++---- README | 45 +++++++++------- compress.c | 35 ++++++++----- configure | 39 ++++++++------ contrib/README.contrib | 3 +- contrib/asm386/gvmat32.asm | 25 ++++----- crc32.c | 8 +-- deflate.c | 4 +- example.c | 40 +++++++++++--- gzio.c | 17 ++++-- infblock.c | 12 ++--- inflate.c | 3 +- inftrees.c | 2 +- minigzip.c | 9 ++-- msdos/zlib.def | 2 +- msdos/zlib.rc | 8 +-- test.c | 2 + trees.c | 112 +++++++++++++++++++++++++++++++++------ trees.h | 128 +++++++++++++++++++++++++++++++++++++++++++++ zconf.h | 3 +- zlib.3 | 8 +-- zlib.h | 25 +++++++-- ztest28975.c | 1 + zutil.c | 2 - zutil.h | 10 +++- 27 files changed, 482 insertions(+), 144 deletions(-) create mode 100644 test.c create mode 100644 trees.h create mode 100644 ztest28975.c diff --git a/ChangeLog b/ChangeLog index 4498345..a94955f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,32 @@ ChangeLog file for zlib +Changes in 1.0.8 (27 Jan 1998) +- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) +- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) +- added compress2() to allow setting the compression level +- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) +- use constant arrays for the static trees in trees.c instead of computing + them at run time (thanks to Ken Raeburn for this suggestion). To create + trees.h, compile with GEN_TREES_H and run "make test". +- check return code of example in "make test" and display result +- pass minigzip command line options to file_compress +- simplifying code of inflateSync to avoid gcc 2.8 bug + +- support CC="gcc -Wall" in configure -s (QingLong) +- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) +- fix test for shared library support to avoid compiler warnings +- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) +- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) +- do not use fdopen for Metrowerks on Mac (Brad Pettit)) +- add checks for gzputc and gzputc in example.c +- avoid warnings in gzio.c and deflate.c (Andreas Kleinert) +- use const for the CRC table (Ken Raeburn) +- fixed "make uninstall" for shared libraries +- use Tracev instead of Trace in infblock.c +- in example.c use correct compressed length for test_sync +- suppress +vnocompatwarnings in configure for HPUX (not always supported) + Changes in 1.0.7 (20 Jan 1998) - fix gzseek which was broken in write mode - return error for gzseek to negative absolute position @@ -81,7 +107,6 @@ Changes in 1.0.6 (19 Jan 1998) - in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) - Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. - check for unistd.h in configure (for off_t) -- use Tracev instead of Trace in infblock.c - remove useless check parameter in inflate_blocks_free - avoid useless assignment of s->check to itself in inflate_blocks_new - do not flush twice in gzclose (thanks to Ken Raeburn) diff --git a/Makefile b/Makefile index 3981614..0de616c 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ # To compile and test, type: # ./configure; make test # The call of configure is optional if you don't have special requirements +# If you wish to build zlib as a shared library, use: ./configure -s # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: # make install @@ -22,7 +23,7 @@ CFLAGS=-O LDFLAGS=-L. -lz LDSHARED=$(CC) -VER=1.0.7 +VER=1.0.8 LIBS=libz.a SHAREDLIB=libz.so @@ -51,8 +52,13 @@ all: example minigzip test: all @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ - ./example ; \ - echo hello world | ./minigzip | ./minigzip -d + echo hello world | ./minigzip | ./minigzip -d || \ + echo ' *** minigzip test FAILED ***' ; \ + if ./example; then \ + echo ' *** zlib test OK ***'; \ + else \ + echo ' *** zlib test FAILED ***'; \ + fi libz.a: $(OBJS) $(AR) $@ $(OBJS) @@ -88,12 +94,16 @@ install: $(LIBS) # ldconfig is for Linux uninstall: - cd $(exec_prefix)/lib; rm -f $(LIBS); \ - if test -f $(SHAREDLIB); then \ - v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p'<$(prefix)/include/zlib.h`;\ - rm -f $(SHAREDLIB).$$v $(SHAREDLIB); \ + cd $(prefix)/include; \ + v=$(VER); \ + if test -f zlib.h; then \ + v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \ + rm -f zlib.h zconf.h; \ + fi; \ + cd $(exec_prefix)/lib; rm -f libz.a; \ + if test -f $(SHAREDLIB).$$v; then \ + rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ fi - cdz $(prefix)/include; rm -f zlib.h zconf.h clean: rm -f *.o *~ example minigzip libz.a libz.so* foo.gz @@ -141,6 +151,6 @@ inflate.o: zutil.h zlib.h zconf.h infblock.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h minigzip.o: zlib.h zconf.h -trees.o: deflate.h zutil.h zlib.h zconf.h +trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h diff --git a/Makefile.in b/Makefile.in index 3981614..0de616c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,6 +5,7 @@ # To compile and test, type: # ./configure; make test # The call of configure is optional if you don't have special requirements +# If you wish to build zlib as a shared library, use: ./configure -s # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: # make install @@ -22,7 +23,7 @@ CFLAGS=-O LDFLAGS=-L. -lz LDSHARED=$(CC) -VER=1.0.7 +VER=1.0.8 LIBS=libz.a SHAREDLIB=libz.so @@ -51,8 +52,13 @@ all: example minigzip test: all @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ - ./example ; \ - echo hello world | ./minigzip | ./minigzip -d + echo hello world | ./minigzip | ./minigzip -d || \ + echo ' *** minigzip test FAILED ***' ; \ + if ./example; then \ + echo ' *** zlib test OK ***'; \ + else \ + echo ' *** zlib test FAILED ***'; \ + fi libz.a: $(OBJS) $(AR) $@ $(OBJS) @@ -88,12 +94,16 @@ install: $(LIBS) # ldconfig is for Linux uninstall: - cd $(exec_prefix)/lib; rm -f $(LIBS); \ - if test -f $(SHAREDLIB); then \ - v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p'<$(prefix)/include/zlib.h`;\ - rm -f $(SHAREDLIB).$$v $(SHAREDLIB); \ + cd $(prefix)/include; \ + v=$(VER); \ + if test -f zlib.h; then \ + v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \ + rm -f zlib.h zconf.h; \ + fi; \ + cd $(exec_prefix)/lib; rm -f libz.a; \ + if test -f $(SHAREDLIB).$$v; then \ + rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ fi - cdz $(prefix)/include; rm -f zlib.h zconf.h clean: rm -f *.o *~ example minigzip libz.a libz.so* foo.gz @@ -141,6 +151,6 @@ inflate.o: zutil.h zlib.h zconf.h infblock.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h minigzip.o: zlib.h zconf.h -trees.o: deflate.h zutil.h zlib.h zconf.h +trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h diff --git a/README b/README index 8d33fb9..0adc66f 100644 --- a/README +++ b/README @@ -1,15 +1,16 @@ -zlib 1.0.7 is a general purpose data compression library. All the code -is reentrant (thread safe). The data format used by the zlib library +zlib 1.0.8 is a general purpose data compression library. All the code +is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). These documents are also available in other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html -All functions of the compression library are documented in the file -zlib.h. A usage example of the library is given in the file example.c -which also tests that the library is working correctly. Another -example is given in the file minigzip.c. The compression library itself -is composed of all source files except example.c and minigzip.c. +All functions of the compression library are documented in the file zlib.h +(volunteer to write man pages welcome, contact jloup@gzip.org). A usage +example of the library is given in the file example.c which also tests that +the library is working correctly. Another example is given in the file +minigzip.c. The compression library itself is composed of all source files +except example.c and minigzip.c. To compile all files and run the test program, follow the instructions given at the top of Makefile. In short "make test; make install" @@ -24,18 +25,18 @@ Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available in http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm -The changes made in version 1.0.7 are documented in the file ChangeLog. -The main changes since 1.0.6 are: +The changes made in version 1.0.8 are documented in the file ChangeLog. +The main changes since 1.0.7 are: -- fix gzseek which was broken in write mode -- return error for gzseek to negative absolute position -- fix configure for Linux (Chun-Chung Chen) -- increase stack space for MSC (Tim Wegner) -- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) -- define EXPORTVA for gzprintf (Gilles Vollant) -- added mini man page zlib.3 (Rick Rodgers) [volunteers to write full - man pages from zlib.h most welcome. write to jloup@gzip.org] -- for contrib/untgz, fix makedir() and improve Makefile +- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) +- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) +- added compress2() to allow setting the compression level +- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) +- use constant arrays for the static trees in trees.c instead of computing + them at run time (thanks to Ken Raeburn for this suggestion). To create + trees.h, compile with GEN_TREES_H and run "make test". +- check return code of example in "make test" and display result +- pass minigzip command line options to file_compress Unsupported third party contributions are provided in directory "contrib". @@ -64,6 +65,9 @@ Notes for some targets: See contrib/visual-basic.txt for more information. I don't know how to handle structures in Visual Basic, sorry. +- "make test" fails on Solaris 2.6 with gcc 2.8.0. It works with cc and + with gcc 2.7.2.1. + - For 64-bit Irix, deflate.c must be compiled without any optimization. With -O, one libpng test fails. The test works in 32 bit mode (with the -n32 compiler flag). The compiler bug has been reported to SGI. @@ -74,7 +78,10 @@ Notes for some targets: - zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not accepting the -O option). It works with the other cc compiler. -- gzdopen is not supported on RISCOS +- For shared memory multiprocessors, the decompression code assumes that + writes to pointers are atomic. + +- gzdopen is not supported on RISCOS, BEOS and Mac - For Turbo C the small model is supported only with reduced performance to avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 diff --git a/compress.c b/compress.c index 7be0b3d..b77674a 100644 --- a/compress.c +++ b/compress.c @@ -8,22 +8,22 @@ #include "zlib.h" /* =========================================================================== - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least 0.1% larger than - sourceLen plus 8 bytes. Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. */ -int EXPORT compress (dest, destLen, source, sourceLen) +int EXPORT compress2 (dest, destLen, source, sourceLen, level) Bytef *dest; uLongf *destLen; const Bytef *source; uLong sourceLen; + int level; { z_stream stream; int err; @@ -42,7 +42,7 @@ int EXPORT compress (dest, destLen, source, sourceLen) stream.zfree = (free_func)0; stream.opaque = (voidpf)0; - err = deflateInit(&stream, Z_DEFAULT_COMPRESSION); + err = deflateInit(&stream, level); if (err != Z_OK) return err; err = deflate(&stream, Z_FINISH); @@ -55,3 +55,14 @@ int EXPORT compress (dest, destLen, source, sourceLen) err = deflateEnd(&stream); return err; } + +/* =========================================================================== + */ +int EXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} diff --git a/configure b/configure index 520d205..f0d01e8 100755 --- a/configure +++ b/configure @@ -29,15 +29,23 @@ case "$1" in -h* | --h*) echo 'syntax: configure [ --shared ]'; exit 0;; esac -test -z "$CC" && echo Checking for gcc... test=ztest$$ cat > $test.c </dev/null; then - CC=gcc + +test -z "$CC" && echo Checking for gcc... +cc=${CC-gcc} +cflags=${CFLAGS-"-O3"} +case "$cc" in + *gcc*) gcc=1;; +esac + +if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then + CC="$cc" SFLAGS=${CFLAGS-"-fPIC -O3"} - CFLAGS=${CFLAGS-"-O3"} + CFLAGS="$cflags" case `(uname -s || echo unknown) 2>/dev/null` in Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};; *) LDSHARED=${LDSHARED-"gcc -shared"};; @@ -65,7 +73,8 @@ else LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; HP-UX*) SFLAGS=${CFLAGS-"-O +z"} CFLAGS=${CFLAGS-"-O"} - LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} +# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} + LDSHARED=${LDSHARED-"ld -b"} shared_ext='.sl' SHAREDLIB='libz.sl';; UNIX_System_V\ 4.2.0) @@ -108,14 +117,14 @@ fi # udpate Makefile sed < Makefile.in " -/^CC *=/s,=.*,=$CC, -/^CFLAGS *=/s/=.*/=$CFLAGS/ +/^CC *=/s%=.*%=$CC% +/^CFLAGS *=/s%=.*%=$CFLAGS% /^LDSHARED *=/s%=.*%=$LDSHARED% -/^LIBS *=/s,=.*,=$LIBS, -/^SHAREDLIB *=/s,=.*,=$SHAREDLIB, -/^AR *=/s,=.*,=$AR, -/^RANLIB *=/s,=.*,=$RANLIB, -/^VER *=/s/=.*/=$VER/ -/^prefix *=/s,=.*,=$prefix, -/^exec_prefix *=/s,=.*,=$exec_prefix, +/^LIBS *=/s%=.*%=$LIBS% +/^SHAREDLIB *=/s%=.*%=$SHAREDLIB% +/^AR *=/s%=.*%=$AR% +/^RANLIB *=/s%=.*%=$RANLIB% +/^VER *=/s%=.*%=$VER% +/^prefix *=/s%=.*%=$prefix% +/^exec_prefix *=/s%=.*%=$exec_prefix% " > Makefile diff --git a/contrib/README.contrib b/contrib/README.contrib index 87eb1e3..443eb6b 100644 --- a/contrib/README.contrib +++ b/contrib/README.contrib @@ -5,8 +5,7 @@ for help about these, not the zlib authors. Thanks. asm386/ by Gilles Vollant - 386 asm code replacing longest_match(). This code may be slower - than the C code if you have a good compiler. + 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c iostream/ by Kevin Ruland A C++ I/O streams interface to the zlib gz* functions diff --git a/contrib/asm386/gvmat32.asm b/contrib/asm386/gvmat32.asm index b175871..2918a5d 100644 --- a/contrib/asm386/gvmat32.asm +++ b/contrib/asm386/gvmat32.asm @@ -53,17 +53,19 @@ @lmtype TYPEDEF PROTO C :PTR , :SDWORD longest_match_c PROTO @lmtype - dep_max_chain_length equ 70h - dep_window equ 2ch - dep_strstart equ 60h - dep_prev_length equ 6ch - dep_nice_match equ 84h - dep_w_size equ 20h - dep_prev equ 34h - dep_w_mask equ 28h - dep_good_match equ 80h - dep_match_start equ 64h - dep_lookahead equ 68h + ; all the +4 offsets are due to the addition of pending_buf_size + ; in the deflate_state structure since the asm code was first written + dep_chain_length equ 70h+4 + dep_window equ 2ch+4 + dep_strstart equ 60h+4 + dep_prev_length equ 6ch+4 + dep_nice_match equ 84h+4 + dep_w_size equ 20h+4 + dep_prev equ 34h+4 + dep_w_mask equ 28h+4 + dep_good_match equ 80h+4 + dep_match_start equ 64h+4 + dep_lookahead equ 68h+4 _TEXT segment @@ -461,4 +463,3 @@ _longest_match_asm7fff endp _TEXT ends end - \ No newline at end of file diff --git a/crc32.c b/crc32.c index b0471e3..cc9851e 100644 --- a/crc32.c +++ b/crc32.c @@ -45,7 +45,7 @@ local void make_crc_table() int n, k; uLong poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ - static Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; /* make exclusive-or pattern from polynomial (0xedb88320L) */ poly = 0L; @@ -65,7 +65,7 @@ local void make_crc_table() /* ======================================================================== * Table of CRC-32's of all single-byte values (made by make_crc_table) */ -local uLongf crc_table[256] = { +local const uLongf crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, @@ -124,12 +124,12 @@ local uLongf crc_table[256] = { /* ========================================================================= * This function can be used by asm versions of crc32() */ -uLongf * EXPORT get_crc_table() +const uLongf * EXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif - return (uLongf *)crc_table; + return (const uLongf *)crc_table; } /* ========================================================================= */ diff --git a/deflate.c b/deflate.c index acbdc08..16d6a1d 100644 --- a/deflate.c +++ b/deflate.c @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.0.7 Copyright 1995-1998 Jean-loup Gailly "; + " deflate 1.0.8 Copyright 1995-1998 Jean-loup Gailly "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -842,7 +842,7 @@ local uInt longest_match(s, cur_match) } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0); - if ((uInt)best_len <= s->lookahead) return best_len; + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; return s->lookahead; } #endif /* ASMV */ diff --git a/example.c b/example.c index 7349dec..656ab37 100644 --- a/example.c +++ b/example.c @@ -41,7 +41,7 @@ void test_large_deflate OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_large_inflate OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); -void test_flush OF((Byte *compr, uLong comprLen)); +void test_flush OF((Byte *compr, uLong *comprLen)); void test_sync OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_dict_deflate OF((Byte *compr, uLong comprLen)); @@ -69,6 +69,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad uncompress\n"); + exit(1); } else { printf("uncompress(): %s\n", uncompr); } @@ -93,8 +94,10 @@ void test_gzio(out, in, uncompr, uncomprLen) fprintf(stderr, "gzopen error\n"); exit(1); } - if (gzprintf(file, "%s, %s!", "hello", "hello") != len-1) { + gzputc(file, 'h'); + if (gzprintf(file, "%s, %s!", "ello", "hello") != len-2) { fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); + exit(1); } gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ gzclose(file); @@ -108,24 +111,35 @@ void test_gzio(out, in, uncompr, uncomprLen) uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); if (uncomprLen != len) { fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); + exit(1); } if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad gzread\n"); + fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); + exit(1); } else { printf("gzread(): %s\n", uncompr); } - pos = gzseek(file, -7L, SEEK_CUR); - if (pos != 7 || gztell(file) != pos) { + pos = gzseek(file, -8L, SEEK_CUR); + if (pos != 6 || gztell(file) != pos) { fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", pos, gztell(file)); + exit(1); } + + if (gzgetc(file) != ' ') { + fprintf(stderr, "gzgetc error\n"); + exit(1); + } + uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); if (uncomprLen != 7) { fprintf(stderr, "gzread err after gzseek: %s\n", gzerror(file, &err)); + exit(1); } if (strcmp((char*)uncompr, hello+7)) { fprintf(stderr, "bad gzread after gzseek\n"); + exit(1); } else { printf("gzread() after gzseek: %s\n", uncompr); } @@ -206,6 +220,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad inflate\n"); + exit(1); } else { printf("inflate(): %s\n", uncompr); } @@ -240,6 +255,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) CHECK_ERR(err, "deflate"); if (c_stream.avail_in != 0) { fprintf(stderr, "deflate not greedy\n"); + exit(1); } /* Feed in already compressed data and switch to no compression: */ @@ -259,6 +275,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); + exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); @@ -299,6 +316,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) if (d_stream.total_out != 2*uncomprLen + comprLen/2) { fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); + exit(1); } else { printf("large_inflate(): OK\n"); } @@ -309,7 +327,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) */ void test_flush(compr, comprLen) Byte *compr; - uLong comprLen; + uLong *comprLen; { z_stream c_stream; /* compression stream */ int err; @@ -325,7 +343,7 @@ void test_flush(compr, comprLen) c_stream.next_in = (Bytef*)hello; c_stream.next_out = compr; c_stream.avail_in = 3; - c_stream.avail_out = (uInt)comprLen; + c_stream.avail_out = (uInt)*comprLen; err = deflate(&c_stream, Z_FULL_FLUSH); CHECK_ERR(err, "deflate"); @@ -338,6 +356,8 @@ void test_flush(compr, comprLen) } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); + + *comprLen = c_stream.total_out; } /* =========================================================================== @@ -376,6 +396,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) if (err != Z_DATA_ERROR) { fprintf(stderr, "inflate should report DATA_ERROR\n"); /* Because of incorrect adler32 */ + exit(1); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); @@ -414,6 +435,7 @@ void test_dict_deflate(compr, comprLen) err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); + exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); @@ -463,6 +485,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad inflate with dict\n"); + exit(1); } else { printf("inflate with dictionary: %s\n", uncompr); } @@ -510,8 +533,9 @@ int main(argc, argv) test_large_deflate(compr, comprLen, uncompr, uncomprLen); test_large_inflate(compr, comprLen, uncompr, uncomprLen); - test_flush(compr, comprLen); + test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); + comprLen = uncomprLen; test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); diff --git a/gzio.c b/gzio.c index 0b9915c..a9aa830 100644 --- a/gzio.c +++ b/gzio.c @@ -150,7 +150,12 @@ local gzFile gz_open (path, mode, fd) */ fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->startpos = ftell(s->file); + s->startpos = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an + * fflush on some systems. This version of the library doesn't use + * startpos anyway in write mode, so this initialization is not + * necessary. + */ } else { check_header(s); /* skip the .gz header */ s->startpos = (ftell(s->file) - s->stream.avail_in); @@ -423,7 +428,7 @@ int EXPORT gzread (file, buf, len) int EXPORT gzgetc(file) gzFile file; { - int c; + unsigned char c; return gzread(file, &c, 1) == 1 ? c : -1; } @@ -524,7 +529,9 @@ int EXPORT gzputc(file, c) gzFile file; int c; { - return gzwrite(file, &c, 1) == 1 ? c : -1; + unsigned char cc = (unsigned char) c; /* required for big endian systems */ + + return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; } @@ -627,7 +634,7 @@ z_off_t EXPORT gzseek (file, offset, whence) offset -= size; } - return s->stream.total_in; + return (z_off_t)s->stream.total_in; #endif } /* Rest of function is for reading only */ @@ -667,7 +674,7 @@ z_off_t EXPORT gzseek (file, offset, whence) if (size <= 0) return -1L; offset -= size; } - return s->stream.total_out; + return (z_off_t)s->stream.total_out; } /* =========================================================================== diff --git a/infblock.c b/infblock.c index 4d81d72..7e9c7af 100644 --- a/infblock.c +++ b/infblock.c @@ -82,7 +82,7 @@ uLongf *c; s->read = s->write = s->window; if (s->checkfn != Z_NULL) z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); - Trace((stderr, "inflate: blocks reset\n")); + Tracev((stderr, "inflate: blocks reset\n")); } @@ -104,7 +104,7 @@ uInt w; s->end = s->window + w; s->checkfn = c; s->mode = TYPE; - Trace((stderr, "inflate: blocks allocated\n")); + Tracev((stderr, "inflate: blocks allocated\n")); inflate_blocks_reset(s, z, Z_NULL); return s; } @@ -139,7 +139,7 @@ int r; switch (t >> 1) { case 0: /* stored */ - Trace((stderr, "inflate: stored block%s\n", + Tracev((stderr, "inflate: stored block%s\n", s->last ? " (last)" : "")); DUMPBITS(3) t = k & 7; /* go to byte boundary */ @@ -147,7 +147,7 @@ int r; s->mode = LENS; /* get length of stored block */ break; case 1: /* fixed */ - Trace((stderr, "inflate: fixed codes block%s\n", + Tracev((stderr, "inflate: fixed codes block%s\n", s->last ? " (last)" : "")); { uInt bl, bd; @@ -167,7 +167,7 @@ int r; s->mode = CODES; break; case 2: /* dynamic */ - Trace((stderr, "inflate: dynamic codes block%s\n", + Tracev((stderr, "inflate: dynamic codes block%s\n", s->last ? " (last)" : "")); DUMPBITS(3) s->mode = TABLE; @@ -387,7 +387,7 @@ z_streamp z; inflate_blocks_reset(s, z, Z_NULL); ZFREE(z, s->window); ZFREE(z, s); - Trace((stderr, "inflate: blocks freed\n")); + Tracev((stderr, "inflate: blocks freed\n")); return Z_OK; } diff --git a/inflate.c b/inflate.c index 5bdd997..3cff366 100644 --- a/inflate.c +++ b/inflate.c @@ -321,7 +321,8 @@ z_streamp z; /* search */ while (n && m < 4) { - if (*p == (Byte)(m < 2 ? 0 : 0xff)) + static const Byte mark[4] = {0, 0, 0xff, 0xff}; + if (*p == mark[m]) m++; else if (*p) m = 0; diff --git a/inftrees.c b/inftrees.c index bdd3a98..3c2facf 100644 --- a/inftrees.c +++ b/inftrees.c @@ -7,7 +7,7 @@ #include "inftrees.h" const char inflate_copyright[] = - " inflate 1.0.7 Copyright 1995-1998 Mark Adler "; + " inflate 1.0.8 Copyright 1995-1998 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot diff --git a/minigzip.c b/minigzip.c index ee52ab6..fb7f278 100644 --- a/minigzip.c +++ b/minigzip.c @@ -66,7 +66,7 @@ char *prog; void error OF((const char *msg)); void gz_compress OF((FILE *in, gzFile out)); void gz_uncompress OF((gzFile in, FILE *out)); -void file_compress OF((char *file)); +void file_compress OF((char *file, char *mode)); void file_uncompress OF((char *file)); int main OF((int argc, char *argv[])); @@ -135,8 +135,9 @@ void gz_uncompress(in, out) * Compress the given file: create a corresponding .gz file and remove the * original. */ -void file_compress(file) +void file_compress(file, mode) char *file; + char *mode; { local char outfile[MAX_NAME_LEN]; FILE *in; @@ -150,7 +151,7 @@ void file_compress(file) perror(file); exit(1); } - out = gzopen(outfile, "wb"); /* use "wb9" for maximal compression */ + out = gzopen(outfile, mode); if (out == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); exit(1); @@ -253,7 +254,7 @@ int main(argc, argv) if (uncompr) { file_uncompress(*argv); } else { - file_compress(*argv); + file_compress(*argv, outmode); } } while (argv++, --argc); } diff --git a/msdos/zlib.def b/msdos/zlib.def index 346cce7..9bcdea4 100644 --- a/msdos/zlib.def +++ b/msdos/zlib.def @@ -8,7 +8,7 @@ SUBSYSTEM WINDOWS STUB 'WINSTUB.EXE' -VERSION 1.07 +VERSION 1.08 CODE EXECUTE READ diff --git a/msdos/zlib.rc b/msdos/zlib.rc index a5a9fcb..cda7744 100644 --- a/msdos/zlib.rc +++ b/msdos/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1,0,7,0 - PRODUCTVERSION 1,0,7,0 + FILEVERSION 1,0,8,0 + PRODUCTVERSION 1,0,8,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,9 +17,9 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression library\0" - VALUE "FileVersion", "1.0.7\0" + VALUE "FileVersion", "1.0.8\0" VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlib.lib\0" + VALUE "OriginalFilename", "zlib.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "LegalCopyright", "(C) 1995-1998 Jean-loup Gailly & Mark Adler\0" diff --git a/test.c b/test.c new file mode 100644 index 0000000..4ac763a --- /dev/null +++ b/test.c @@ -0,0 +1,2 @@ +extern int getchar(); +int hello() {return getchar();} diff --git a/trees.c b/trees.c index fe86c77..e2c230f 100644 --- a/trees.c +++ b/trees.c @@ -31,6 +31,8 @@ /* @(#) $Id$ */ +/* #define GEN_TREES_H */ + #include "deflate.h" #ifdef DEBUG @@ -80,6 +82,11 @@ local const uch bl_order[BL_CODES] * Local data. These are initialized only once. */ +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + local ct_data static_ltree[L_CODES+2]; /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However @@ -92,8 +99,8 @@ local ct_data static_dtree[D_CODES]; * 5 bits.) */ -local uch dist_code[512]; -/* distance codes. The first 256 values correspond to the distances +local uch dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances * 3 .. 258, the last 256 values correspond to the top 8 bits of * the 15 bit distances. */ @@ -107,8 +114,12 @@ local int base_length[LENGTH_CODES]; local int base_dist[D_CODES]; /* First normalized distance for each code (0 = distance of 1) */ +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + struct static_tree_desc_s { - ct_data *static_tree; /* static tree or NULL */ + const ct_data *static_tree; /* static tree or NULL */ const intf *extra_bits; /* extra bits for each code or NULL */ int extra_base; /* base index for extra_bits */ int elems; /* max number of elements in the tree */ @@ -122,7 +133,7 @@ local static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; local static_tree_desc static_bl_desc = -{(ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== * Local (static) routines in this file. @@ -148,6 +159,10 @@ local void bi_flush OF((deflate_state *s)); local void copy_block OF((deflate_state *s, charf *buf, unsigned len, int header)); +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + #ifndef DEBUG # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) /* Send a code of the given tree. c and tree must not have side effects */ @@ -226,12 +241,11 @@ local void send_bits(s, value, length) /* the arguments must not have side effects */ /* =========================================================================== - * Initialize the various 'constant' tables. In a multi-threaded environment, - * this function may be called by two threads concurrently, but this is - * harmless since both invocations do exactly the same thing. + * Initialize the various 'constant' tables. */ local void tr_static_init() { +#if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ int bits; /* bit counter */ @@ -295,7 +309,73 @@ local void tr_static_init() static_dtree[n].Code = bi_reverse((unsigned)n, 5); } static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "local const uch dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "local const uch length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); } +#endif /* GEN_TREES_H */ /* =========================================================================== * Initialize the tree data structures for a new zlib stream. @@ -413,12 +493,12 @@ local void gen_bitlen(s, desc) deflate_state *s; tree_desc *desc; /* the tree descriptor */ { - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ @@ -542,9 +622,9 @@ local void build_tree(s, desc) deflate_state *s; tree_desc *desc; /* the tree descriptor */ { - ct_data *tree = desc->dyn_tree; - ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; + ct_data *tree = desc->dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node; /* new node being created */ diff --git a/trees.h b/trees.h new file mode 100644 index 0000000..45f9dd3 --- /dev/null +++ b/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +local const uch dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +local const uch length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/zconf.h b/zconf.h index d95edb6..7bc054f 100644 --- a/zconf.h +++ b/zconf.h @@ -186,7 +186,8 @@ typedef uLong FAR uLongf; #endif #ifdef HAVE_UNISTD_H -# include /* for SEEK_* and off_t */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ # define z_off_t off_t #endif #ifndef SEEK_SET diff --git a/zlib.3 b/zlib.3 index 764ecd7..3c442bc 100644 --- a/zlib.3 +++ b/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "20 January 1998" +.TH ZLIB 3 "26 January 1998" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -9,7 +9,7 @@ for full descripton] The .I zlib library is a general purpose data compression library. -The code is reentrant (thread safe). +The code is thread safe. It provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) @@ -66,7 +66,7 @@ zlib@quest.jpl.nasa.gov or, if this fails, to the author addresses given below. The zlib home page is: .IP -http://www.cdrom.com/infozip/zlib/ +http://www.cdrom.com/pub/infozip/zlib/ .LP The data format used by the zlib library is described by RFC (Request for Comments) 1950 to 1952 in the files: @@ -81,7 +81,7 @@ These documents are also available in other formats from: .IP ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html .SH AUTHORS -Version 1.0.7. +Version 1.0.8. Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org) and Mark Adler (madler@alumni.caltech.edu). .LP diff --git a/zlib.h b/zlib.h index cc1b423..2319835 100644 --- a/zlib.h +++ b/zlib.h @@ -1,5 +1,5 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.0.7, Jan 20th, 1998 + version 1.0.8, Jan 27th, 1998 Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler @@ -37,7 +37,7 @@ extern "C" { #include "zconf.h" -#define ZLIB_VERSION "1.0.7" +#define ZLIB_VERSION "1.0.8" /* The 'zlib' compression library provides in-memory compression and @@ -614,6 +614,21 @@ extern int EXPORT compress OF((Bytef *dest, uLongf *destLen, buffer. */ +extern int EXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* @@ -842,9 +857,9 @@ extern int EXPORT inflateInit2_ OF((z_streamp strm, int windowBits, struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif -extern const char * EXPORT zError OF((int err)); -extern int EXPORT inflateSyncPoint OF((z_streamp z)); -extern uLongf * EXPORT get_crc_table OF((void)); +extern const char * EXPORT zError OF((int err)); +extern int EXPORT inflateSyncPoint OF((z_streamp z)); +extern const uLongf * EXPORT get_crc_table OF((void)); #ifdef __cplusplus } diff --git a/ztest28975.c b/ztest28975.c new file mode 100644 index 0000000..6ecfc44 --- /dev/null +++ b/ztest28975.c @@ -0,0 +1 @@ +int hello() {return 0;} diff --git a/zutil.c b/zutil.c index 84b7ee1..87f6678 100644 --- a/zutil.c +++ b/zutil.c @@ -5,8 +5,6 @@ /* @(#) $Id$ */ -#include - #include "zutil.h" struct internal_state {int dummy;}; /* for buggy compilers */ diff --git a/zutil.h b/zutil.h index 082a87b..ac30b8e 100644 --- a/zutil.h +++ b/zutil.h @@ -110,8 +110,16 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ # define OS_CODE 0x05 #endif -#ifdef MACOS +#if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 0x07 +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +#endif +#if defined(__MWERKS__) && !defined(fdopen) +# if __dest_os != __be_os && __dest_os != __win32_os +# define fdopen(fd,mode) NULL +# endif #endif #ifdef __50SERIES /* Prime/PRIMOS */ -- cgit v1.2.3-55-g6feb