summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:18:57 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:18:57 -0700
commit6759211ad8a5006689216a86c3267bb503bfccc1 (patch)
treedc0f61f4c4a44828ad7d30e376ef21840b137f44
parent7850e4e406dce1f7a819297eeb151d1ca18e7cd9 (diff)
downloadzlib-1.0.8.tar.gz
zlib-1.0.8.tar.bz2
zlib-1.0.8.zip
zlib 1.0.8v1.0.8
-rw-r--r--ChangeLog27
-rw-r--r--Makefile28
-rw-r--r--Makefile.in28
-rw-r--r--README45
-rw-r--r--compress.c35
-rwxr-xr-xconfigure39
-rw-r--r--contrib/README.contrib3
-rw-r--r--contrib/asm386/gvmat32.asm25
-rw-r--r--crc32.c8
-rw-r--r--deflate.c4
-rw-r--r--example.c40
-rw-r--r--gzio.c17
-rw-r--r--infblock.c12
-rw-r--r--inflate.c3
-rw-r--r--inftrees.c2
-rw-r--r--minigzip.c9
-rw-r--r--msdos/zlib.def2
-rw-r--r--msdos/zlib.rc8
-rw-r--r--test.c2
-rw-r--r--trees.c112
-rw-r--r--trees.h128
-rw-r--r--zconf.h3
-rw-r--r--zlib.38
-rw-r--r--zlib.h25
-rw-r--r--ztest28975.c1
-rw-r--r--zutil.c2
-rw-r--r--zutil.h10
27 files changed, 482 insertions, 144 deletions
diff --git a/ChangeLog b/ChangeLog
index 4498345..a94955f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,32 @@
1 1
2 ChangeLog file for zlib 2 ChangeLog file for zlib
3 3
4Changes in 1.0.8 (27 Jan 1998)
5- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
6- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
7- added compress2() to allow setting the compression level
8- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
9- use constant arrays for the static trees in trees.c instead of computing
10 them at run time (thanks to Ken Raeburn for this suggestion). To create
11 trees.h, compile with GEN_TREES_H and run "make test".
12- check return code of example in "make test" and display result
13- pass minigzip command line options to file_compress
14- simplifying code of inflateSync to avoid gcc 2.8 bug
15
16- support CC="gcc -Wall" in configure -s (QingLong)
17- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
18- fix test for shared library support to avoid compiler warnings
19- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
20- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
21- do not use fdopen for Metrowerks on Mac (Brad Pettit))
22- add checks for gzputc and gzputc in example.c
23- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
24- use const for the CRC table (Ken Raeburn)
25- fixed "make uninstall" for shared libraries
26- use Tracev instead of Trace in infblock.c
27- in example.c use correct compressed length for test_sync
28- suppress +vnocompatwarnings in configure for HPUX (not always supported)
29
4Changes in 1.0.7 (20 Jan 1998) 30Changes in 1.0.7 (20 Jan 1998)
5- fix gzseek which was broken in write mode 31- fix gzseek which was broken in write mode
6- return error for gzseek to negative absolute position 32- return error for gzseek to negative absolute position
@@ -81,7 +107,6 @@ Changes in 1.0.6 (19 Jan 1998)
81- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) 107- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
82- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. 108- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
83- check for unistd.h in configure (for off_t) 109- check for unistd.h in configure (for off_t)
84- use Tracev instead of Trace in infblock.c
85- remove useless check parameter in inflate_blocks_free 110- remove useless check parameter in inflate_blocks_free
86- avoid useless assignment of s->check to itself in inflate_blocks_new 111- avoid useless assignment of s->check to itself in inflate_blocks_new
87- do not flush twice in gzclose (thanks to Ken Raeburn) 112- 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 @@
5# To compile and test, type: 5# To compile and test, type:
6# ./configure; make test 6# ./configure; make test
7# The call of configure is optional if you don't have special requirements 7# The call of configure is optional if you don't have special requirements
8# If you wish to build zlib as a shared library, use: ./configure -s
8 9
9# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: 10# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
10# make install 11# make install
@@ -22,7 +23,7 @@ CFLAGS=-O
22LDFLAGS=-L. -lz 23LDFLAGS=-L. -lz
23LDSHARED=$(CC) 24LDSHARED=$(CC)
24 25
25VER=1.0.7 26VER=1.0.8
26LIBS=libz.a 27LIBS=libz.a
27SHAREDLIB=libz.so 28SHAREDLIB=libz.so
28 29
@@ -51,8 +52,13 @@ all: example minigzip
51 52
52test: all 53test: all
53 @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ 54 @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
54 ./example ; \ 55 echo hello world | ./minigzip | ./minigzip -d || \
55 echo hello world | ./minigzip | ./minigzip -d 56 echo ' *** minigzip test FAILED ***' ; \
57 if ./example; then \
58 echo ' *** zlib test OK ***'; \
59 else \
60 echo ' *** zlib test FAILED ***'; \
61 fi
56 62
57libz.a: $(OBJS) 63libz.a: $(OBJS)
58 $(AR) $@ $(OBJS) 64 $(AR) $@ $(OBJS)
@@ -88,12 +94,16 @@ install: $(LIBS)
88# ldconfig is for Linux 94# ldconfig is for Linux
89 95
90uninstall: 96uninstall:
91 cd $(exec_prefix)/lib; rm -f $(LIBS); \ 97 cd $(prefix)/include; \
92 if test -f $(SHAREDLIB); then \ 98 v=$(VER); \
93 v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p'<$(prefix)/include/zlib.h`;\ 99 if test -f zlib.h; then \
94 rm -f $(SHAREDLIB).$$v $(SHAREDLIB); \ 100 v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
101 rm -f zlib.h zconf.h; \
102 fi; \
103 cd $(exec_prefix)/lib; rm -f libz.a; \
104 if test -f $(SHAREDLIB).$$v; then \
105 rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
95 fi 106 fi
96 cdz $(prefix)/include; rm -f zlib.h zconf.h
97 107
98clean: 108clean:
99 rm -f *.o *~ example minigzip libz.a libz.so* foo.gz 109 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
141inftrees.o: zutil.h zlib.h zconf.h inftrees.h 151inftrees.o: zutil.h zlib.h zconf.h inftrees.h
142infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h 152infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
143minigzip.o: zlib.h zconf.h 153minigzip.o: zlib.h zconf.h
144trees.o: deflate.h zutil.h zlib.h zconf.h 154trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
145uncompr.o: zlib.h zconf.h 155uncompr.o: zlib.h zconf.h
146zutil.o: zutil.h zlib.h zconf.h 156zutil.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 @@
5# To compile and test, type: 5# To compile and test, type:
6# ./configure; make test 6# ./configure; make test
7# The call of configure is optional if you don't have special requirements 7# The call of configure is optional if you don't have special requirements
8# If you wish to build zlib as a shared library, use: ./configure -s
8 9
9# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: 10# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
10# make install 11# make install
@@ -22,7 +23,7 @@ CFLAGS=-O
22LDFLAGS=-L. -lz 23LDFLAGS=-L. -lz
23LDSHARED=$(CC) 24LDSHARED=$(CC)
24 25
25VER=1.0.7 26VER=1.0.8
26LIBS=libz.a 27LIBS=libz.a
27SHAREDLIB=libz.so 28SHAREDLIB=libz.so
28 29
@@ -51,8 +52,13 @@ all: example minigzip
51 52
52test: all 53test: all
53 @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ 54 @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
54 ./example ; \ 55 echo hello world | ./minigzip | ./minigzip -d || \
55 echo hello world | ./minigzip | ./minigzip -d 56 echo ' *** minigzip test FAILED ***' ; \
57 if ./example; then \
58 echo ' *** zlib test OK ***'; \
59 else \
60 echo ' *** zlib test FAILED ***'; \
61 fi
56 62
57libz.a: $(OBJS) 63libz.a: $(OBJS)
58 $(AR) $@ $(OBJS) 64 $(AR) $@ $(OBJS)
@@ -88,12 +94,16 @@ install: $(LIBS)
88# ldconfig is for Linux 94# ldconfig is for Linux
89 95
90uninstall: 96uninstall:
91 cd $(exec_prefix)/lib; rm -f $(LIBS); \ 97 cd $(prefix)/include; \
92 if test -f $(SHAREDLIB); then \ 98 v=$(VER); \
93 v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p'<$(prefix)/include/zlib.h`;\ 99 if test -f zlib.h; then \
94 rm -f $(SHAREDLIB).$$v $(SHAREDLIB); \ 100 v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
101 rm -f zlib.h zconf.h; \
102 fi; \
103 cd $(exec_prefix)/lib; rm -f libz.a; \
104 if test -f $(SHAREDLIB).$$v; then \
105 rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
95 fi 106 fi
96 cdz $(prefix)/include; rm -f zlib.h zconf.h
97 107
98clean: 108clean:
99 rm -f *.o *~ example minigzip libz.a libz.so* foo.gz 109 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
141inftrees.o: zutil.h zlib.h zconf.h inftrees.h 151inftrees.o: zutil.h zlib.h zconf.h inftrees.h
142infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h 152infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
143minigzip.o: zlib.h zconf.h 153minigzip.o: zlib.h zconf.h
144trees.o: deflate.h zutil.h zlib.h zconf.h 154trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
145uncompr.o: zlib.h zconf.h 155uncompr.o: zlib.h zconf.h
146zutil.o: zutil.h zlib.h zconf.h 156zutil.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 @@
1zlib 1.0.7 is a general purpose data compression library. All the code 1zlib 1.0.8 is a general purpose data compression library. All the code
2is reentrant (thread safe). The data format used by the zlib library 2is thread safe. The data format used by the zlib library
3is described by RFCs (Request for Comments) 1950 to 1952 in the files 3is described by RFCs (Request for Comments) 1950 to 1952 in the files
4ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate 4ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
5format) and rfc1952.txt (gzip format). These documents are also available in 5format) and rfc1952.txt (gzip format). These documents are also available in
6other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html 6other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
7 7
8All functions of the compression library are documented in the file 8All functions of the compression library are documented in the file zlib.h
9zlib.h. A usage example of the library is given in the file example.c 9(volunteer to write man pages welcome, contact jloup@gzip.org). A usage
10which also tests that the library is working correctly. Another 10example of the library is given in the file example.c which also tests that
11example is given in the file minigzip.c. The compression library itself 11the library is working correctly. Another example is given in the file
12is composed of all source files except example.c and minigzip.c. 12minigzip.c. The compression library itself is composed of all source files
13except example.c and minigzip.c.
13 14
14To compile all files and run the test program, follow the instructions 15To compile all files and run the test program, follow the instructions
15given at the top of Makefile. In short "make test; make install" 16given 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
24Dr. Dobb's Journal; a copy of the article is available in 25Dr. Dobb's Journal; a copy of the article is available in
25http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm 26http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
26 27
27The changes made in version 1.0.7 are documented in the file ChangeLog. 28The changes made in version 1.0.8 are documented in the file ChangeLog.
28The main changes since 1.0.6 are: 29The main changes since 1.0.7 are:
29 30
30- fix gzseek which was broken in write mode 31- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
31- return error for gzseek to negative absolute position 32- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
32- fix configure for Linux (Chun-Chung Chen) 33- added compress2() to allow setting the compression level
33- increase stack space for MSC (Tim Wegner) 34- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
34- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) 35- use constant arrays for the static trees in trees.c instead of computing
35- define EXPORTVA for gzprintf (Gilles Vollant) 36 them at run time (thanks to Ken Raeburn for this suggestion). To create
36- added mini man page zlib.3 (Rick Rodgers) [volunteers to write full 37 trees.h, compile with GEN_TREES_H and run "make test".
37 man pages from zlib.h most welcome. write to jloup@gzip.org] 38- check return code of example in "make test" and display result
38- for contrib/untgz, fix makedir() and improve Makefile 39- pass minigzip command line options to file_compress
39 40
40Unsupported third party contributions are provided in directory "contrib". 41Unsupported third party contributions are provided in directory "contrib".
41 42
@@ -64,6 +65,9 @@ Notes for some targets:
64 See contrib/visual-basic.txt for more information. 65 See contrib/visual-basic.txt for more information.
65 I don't know how to handle structures in Visual Basic, sorry. 66 I don't know how to handle structures in Visual Basic, sorry.
66 67
68- "make test" fails on Solaris 2.6 with gcc 2.8.0. It works with cc and
69 with gcc 2.7.2.1.
70
67- For 64-bit Irix, deflate.c must be compiled without any optimization. 71- For 64-bit Irix, deflate.c must be compiled without any optimization.
68 With -O, one libpng test fails. The test works in 32 bit mode (with 72 With -O, one libpng test fails. The test works in 32 bit mode (with
69 the -n32 compiler flag). The compiler bug has been reported to SGI. 73 the -n32 compiler flag). The compiler bug has been reported to SGI.
@@ -74,7 +78,10 @@ Notes for some targets:
74- zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not 78- zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not
75 accepting the -O option). It works with the other cc compiler. 79 accepting the -O option). It works with the other cc compiler.
76 80
77- gzdopen is not supported on RISCOS 81- For shared memory multiprocessors, the decompression code assumes that
82 writes to pointers are atomic.
83
84- gzdopen is not supported on RISCOS, BEOS and Mac
78 85
79- For Turbo C the small model is supported only with reduced performance to 86- For Turbo C the small model is supported only with reduced performance to
80 avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 87 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 @@
8#include "zlib.h" 8#include "zlib.h"
9 9
10/* =========================================================================== 10/* ===========================================================================
11 Compresses the source buffer into the destination buffer. sourceLen is 11 Compresses the source buffer into the destination buffer. The level
12 the byte length of the source buffer. Upon entry, destLen is the total 12 parameter has the same meaning as in deflateInit. sourceLen is the byte
13 size of the destination buffer, which must be at least 0.1% larger than 13 length of the source buffer. Upon entry, destLen is the total size of the
14 sourceLen plus 8 bytes. Upon exit, destLen is the actual size of the 14 destination buffer, which must be at least 0.1% larger than sourceLen plus
15 compressed buffer. 15 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
16 This function can be used to compress a whole file at once if the 16
17 input file is mmap'ed. 17 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
18 compress returns Z_OK if success, Z_MEM_ERROR if there was not 18 memory, Z_BUF_ERROR if there was not enough room in the output buffer,
19 enough memory, Z_BUF_ERROR if there was not enough room in the output 19 Z_STREAM_ERROR if the level parameter is invalid.
20 buffer.
21*/ 20*/
22int EXPORT compress (dest, destLen, source, sourceLen) 21int EXPORT compress2 (dest, destLen, source, sourceLen, level)
23 Bytef *dest; 22 Bytef *dest;
24 uLongf *destLen; 23 uLongf *destLen;
25 const Bytef *source; 24 const Bytef *source;
26 uLong sourceLen; 25 uLong sourceLen;
26 int level;
27{ 27{
28 z_stream stream; 28 z_stream stream;
29 int err; 29 int err;
@@ -42,7 +42,7 @@ int EXPORT compress (dest, destLen, source, sourceLen)
42 stream.zfree = (free_func)0; 42 stream.zfree = (free_func)0;
43 stream.opaque = (voidpf)0; 43 stream.opaque = (voidpf)0;
44 44
45 err = deflateInit(&stream, Z_DEFAULT_COMPRESSION); 45 err = deflateInit(&stream, level);
46 if (err != Z_OK) return err; 46 if (err != Z_OK) return err;
47 47
48 err = deflate(&stream, Z_FINISH); 48 err = deflate(&stream, Z_FINISH);
@@ -55,3 +55,14 @@ int EXPORT compress (dest, destLen, source, sourceLen)
55 err = deflateEnd(&stream); 55 err = deflateEnd(&stream);
56 return err; 56 return err;
57} 57}
58
59/* ===========================================================================
60 */
61int EXPORT compress (dest, destLen, source, sourceLen)
62 Bytef *dest;
63 uLongf *destLen;
64 const Bytef *source;
65 uLong sourceLen;
66{
67 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
68}
diff --git a/configure b/configure
index 520d205..f0d01e8 100755
--- a/configure
+++ b/configure
@@ -29,15 +29,23 @@ case "$1" in
29 -h* | --h*) echo 'syntax: configure [ --shared ]'; exit 0;; 29 -h* | --h*) echo 'syntax: configure [ --shared ]'; exit 0;;
30esac 30esac
31 31
32test -z "$CC" && echo Checking for gcc...
33test=ztest$$ 32test=ztest$$
34cat > $test.c <<EOF 33cat > $test.c <<EOF
35int hello() { printf("hello\n"); } 34extern int getchar();
35int hello() {return getchar();}
36EOF 36EOF
37if test -z "$CC" -o "$CC" = "gcc" && (gcc -c -O3 $test.c) 2>/dev/null; then 37
38 CC=gcc 38test -z "$CC" && echo Checking for gcc...
39cc=${CC-gcc}
40cflags=${CFLAGS-"-O3"}
41case "$cc" in
42 *gcc*) gcc=1;;
43esac
44
45if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
46 CC="$cc"
39 SFLAGS=${CFLAGS-"-fPIC -O3"} 47 SFLAGS=${CFLAGS-"-fPIC -O3"}
40 CFLAGS=${CFLAGS-"-O3"} 48 CFLAGS="$cflags"
41 case `(uname -s || echo unknown) 2>/dev/null` in 49 case `(uname -s || echo unknown) 2>/dev/null` in
42 Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};; 50 Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
43 *) LDSHARED=${LDSHARED-"gcc -shared"};; 51 *) LDSHARED=${LDSHARED-"gcc -shared"};;
@@ -65,7 +73,8 @@ else
65 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; 73 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
66 HP-UX*) SFLAGS=${CFLAGS-"-O +z"} 74 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
67 CFLAGS=${CFLAGS-"-O"} 75 CFLAGS=${CFLAGS-"-O"}
68 LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} 76# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
77 LDSHARED=${LDSHARED-"ld -b"}
69 shared_ext='.sl' 78 shared_ext='.sl'
70 SHAREDLIB='libz.sl';; 79 SHAREDLIB='libz.sl';;
71 UNIX_System_V\ 4.2.0) 80 UNIX_System_V\ 4.2.0)
@@ -108,14 +117,14 @@ fi
108 117
109# udpate Makefile 118# udpate Makefile
110sed < Makefile.in " 119sed < Makefile.in "
111/^CC *=/s,=.*,=$CC, 120/^CC *=/s%=.*%=$CC%
112/^CFLAGS *=/s/=.*/=$CFLAGS/ 121/^CFLAGS *=/s%=.*%=$CFLAGS%
113/^LDSHARED *=/s%=.*%=$LDSHARED% 122/^LDSHARED *=/s%=.*%=$LDSHARED%
114/^LIBS *=/s,=.*,=$LIBS, 123/^LIBS *=/s%=.*%=$LIBS%
115/^SHAREDLIB *=/s,=.*,=$SHAREDLIB, 124/^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
116/^AR *=/s,=.*,=$AR, 125/^AR *=/s%=.*%=$AR%
117/^RANLIB *=/s,=.*,=$RANLIB, 126/^RANLIB *=/s%=.*%=$RANLIB%
118/^VER *=/s/=.*/=$VER/ 127/^VER *=/s%=.*%=$VER%
119/^prefix *=/s,=.*,=$prefix, 128/^prefix *=/s%=.*%=$prefix%
120/^exec_prefix *=/s,=.*,=$exec_prefix, 129/^exec_prefix *=/s%=.*%=$exec_prefix%
121" > Makefile 130" > 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.
5 5
6 6
7asm386/ by Gilles Vollant <info@winimage.com> 7asm386/ by Gilles Vollant <info@winimage.com>
8 386 asm code replacing longest_match(). This code may be slower 8 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c
9 than the C code if you have a good compiler.
10 9
11iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> 10iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
12 A C++ I/O streams interface to the zlib gz* functions 11 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 @@
53@lmtype TYPEDEF PROTO C :PTR , :SDWORD 53@lmtype TYPEDEF PROTO C :PTR , :SDWORD
54longest_match_c PROTO @lmtype 54longest_match_c PROTO @lmtype
55 55
56 dep_max_chain_length equ 70h 56 ; all the +4 offsets are due to the addition of pending_buf_size
57 dep_window equ 2ch 57 ; in the deflate_state structure since the asm code was first written
58 dep_strstart equ 60h 58 dep_chain_length equ 70h+4
59 dep_prev_length equ 6ch 59 dep_window equ 2ch+4
60 dep_nice_match equ 84h 60 dep_strstart equ 60h+4
61 dep_w_size equ 20h 61 dep_prev_length equ 6ch+4
62 dep_prev equ 34h 62 dep_nice_match equ 84h+4
63 dep_w_mask equ 28h 63 dep_w_size equ 20h+4
64 dep_good_match equ 80h 64 dep_prev equ 34h+4
65 dep_match_start equ 64h 65 dep_w_mask equ 28h+4
66 dep_lookahead equ 68h 66 dep_good_match equ 80h+4
67 dep_match_start equ 64h+4
68 dep_lookahead equ 68h+4
67 69
68 70
69_TEXT segment 71_TEXT segment
@@ -461,4 +463,3 @@ _longest_match_asm7fff endp
461 463
462_TEXT ends 464_TEXT ends
463end 465end
464 \ 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()
45 int n, k; 45 int n, k;
46 uLong poly; /* polynomial exclusive-or pattern */ 46 uLong poly; /* polynomial exclusive-or pattern */
47 /* terms of polynomial defining this crc (except x^32): */ 47 /* terms of polynomial defining this crc (except x^32): */
48 static Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; 48 static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
49 49
50 /* make exclusive-or pattern from polynomial (0xedb88320L) */ 50 /* make exclusive-or pattern from polynomial (0xedb88320L) */
51 poly = 0L; 51 poly = 0L;
@@ -65,7 +65,7 @@ local void make_crc_table()
65/* ======================================================================== 65/* ========================================================================
66 * Table of CRC-32's of all single-byte values (made by make_crc_table) 66 * Table of CRC-32's of all single-byte values (made by make_crc_table)
67 */ 67 */
68local uLongf crc_table[256] = { 68local const uLongf crc_table[256] = {
69 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 69 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
70 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 70 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
71 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 71 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
@@ -124,12 +124,12 @@ local uLongf crc_table[256] = {
124/* ========================================================================= 124/* =========================================================================
125 * This function can be used by asm versions of crc32() 125 * This function can be used by asm versions of crc32()
126 */ 126 */
127uLongf * EXPORT get_crc_table() 127const uLongf * EXPORT get_crc_table()
128{ 128{
129#ifdef DYNAMIC_CRC_TABLE 129#ifdef DYNAMIC_CRC_TABLE
130 if (crc_table_empty) make_crc_table(); 130 if (crc_table_empty) make_crc_table();
131#endif 131#endif
132 return (uLongf *)crc_table; 132 return (const uLongf *)crc_table;
133} 133}
134 134
135/* ========================================================================= */ 135/* ========================================================================= */
diff --git a/deflate.c b/deflate.c
index acbdc08..16d6a1d 100644
--- a/deflate.c
+++ b/deflate.c
@@ -52,7 +52,7 @@
52#include "deflate.h" 52#include "deflate.h"
53 53
54const char deflate_copyright[] = 54const char deflate_copyright[] =
55 " deflate 1.0.7 Copyright 1995-1998 Jean-loup Gailly "; 55 " deflate 1.0.8 Copyright 1995-1998 Jean-loup Gailly ";
56/* 56/*
57 If you use the zlib library in a product, an acknowledgment is welcome 57 If you use the zlib library in a product, an acknowledgment is welcome
58 in the documentation of your product. If for some reason you cannot 58 in the documentation of your product. If for some reason you cannot
@@ -842,7 +842,7 @@ local uInt longest_match(s, cur_match)
842 } while ((cur_match = prev[cur_match & wmask]) > limit 842 } while ((cur_match = prev[cur_match & wmask]) > limit
843 && --chain_length != 0); 843 && --chain_length != 0);
844 844
845 if ((uInt)best_len <= s->lookahead) return best_len; 845 if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
846 return s->lookahead; 846 return s->lookahead;
847} 847}
848#endif /* ASMV */ 848#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,
41 Byte *uncompr, uLong uncomprLen)); 41 Byte *uncompr, uLong uncomprLen));
42void test_large_inflate OF((Byte *compr, uLong comprLen, 42void test_large_inflate OF((Byte *compr, uLong comprLen,
43 Byte *uncompr, uLong uncomprLen)); 43 Byte *uncompr, uLong uncomprLen));
44void test_flush OF((Byte *compr, uLong comprLen)); 44void test_flush OF((Byte *compr, uLong *comprLen));
45void test_sync OF((Byte *compr, uLong comprLen, 45void test_sync OF((Byte *compr, uLong comprLen,
46 Byte *uncompr, uLong uncomprLen)); 46 Byte *uncompr, uLong uncomprLen));
47void test_dict_deflate OF((Byte *compr, uLong comprLen)); 47void test_dict_deflate OF((Byte *compr, uLong comprLen));
@@ -69,6 +69,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
69 69
70 if (strcmp((char*)uncompr, hello)) { 70 if (strcmp((char*)uncompr, hello)) {
71 fprintf(stderr, "bad uncompress\n"); 71 fprintf(stderr, "bad uncompress\n");
72 exit(1);
72 } else { 73 } else {
73 printf("uncompress(): %s\n", uncompr); 74 printf("uncompress(): %s\n", uncompr);
74 } 75 }
@@ -93,8 +94,10 @@ void test_gzio(out, in, uncompr, uncomprLen)
93 fprintf(stderr, "gzopen error\n"); 94 fprintf(stderr, "gzopen error\n");
94 exit(1); 95 exit(1);
95 } 96 }
96 if (gzprintf(file, "%s, %s!", "hello", "hello") != len-1) { 97 gzputc(file, 'h');
98 if (gzprintf(file, "%s, %s!", "ello", "hello") != len-2) {
97 fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); 99 fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
100 exit(1);
98 } 101 }
99 gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ 102 gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
100 gzclose(file); 103 gzclose(file);
@@ -108,24 +111,35 @@ void test_gzio(out, in, uncompr, uncomprLen)
108 uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); 111 uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen);
109 if (uncomprLen != len) { 112 if (uncomprLen != len) {
110 fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); 113 fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
114 exit(1);
111 } 115 }
112 if (strcmp((char*)uncompr, hello)) { 116 if (strcmp((char*)uncompr, hello)) {
113 fprintf(stderr, "bad gzread\n"); 117 fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
118 exit(1);
114 } else { 119 } else {
115 printf("gzread(): %s\n", uncompr); 120 printf("gzread(): %s\n", uncompr);
116 } 121 }
117 122
118 pos = gzseek(file, -7L, SEEK_CUR); 123 pos = gzseek(file, -8L, SEEK_CUR);
119 if (pos != 7 || gztell(file) != pos) { 124 if (pos != 6 || gztell(file) != pos) {
120 fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", 125 fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
121 pos, gztell(file)); 126 pos, gztell(file));
127 exit(1);
122 } 128 }
129
130 if (gzgetc(file) != ' ') {
131 fprintf(stderr, "gzgetc error\n");
132 exit(1);
133 }
134
123 uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); 135 uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen);
124 if (uncomprLen != 7) { 136 if (uncomprLen != 7) {
125 fprintf(stderr, "gzread err after gzseek: %s\n", gzerror(file, &err)); 137 fprintf(stderr, "gzread err after gzseek: %s\n", gzerror(file, &err));
138 exit(1);
126 } 139 }
127 if (strcmp((char*)uncompr, hello+7)) { 140 if (strcmp((char*)uncompr, hello+7)) {
128 fprintf(stderr, "bad gzread after gzseek\n"); 141 fprintf(stderr, "bad gzread after gzseek\n");
142 exit(1);
129 } else { 143 } else {
130 printf("gzread() after gzseek: %s\n", uncompr); 144 printf("gzread() after gzseek: %s\n", uncompr);
131 } 145 }
@@ -206,6 +220,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
206 220
207 if (strcmp((char*)uncompr, hello)) { 221 if (strcmp((char*)uncompr, hello)) {
208 fprintf(stderr, "bad inflate\n"); 222 fprintf(stderr, "bad inflate\n");
223 exit(1);
209 } else { 224 } else {
210 printf("inflate(): %s\n", uncompr); 225 printf("inflate(): %s\n", uncompr);
211 } 226 }
@@ -240,6 +255,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
240 CHECK_ERR(err, "deflate"); 255 CHECK_ERR(err, "deflate");
241 if (c_stream.avail_in != 0) { 256 if (c_stream.avail_in != 0) {
242 fprintf(stderr, "deflate not greedy\n"); 257 fprintf(stderr, "deflate not greedy\n");
258 exit(1);
243 } 259 }
244 260
245 /* Feed in already compressed data and switch to no compression: */ 261 /* Feed in already compressed data and switch to no compression: */
@@ -259,6 +275,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
259 err = deflate(&c_stream, Z_FINISH); 275 err = deflate(&c_stream, Z_FINISH);
260 if (err != Z_STREAM_END) { 276 if (err != Z_STREAM_END) {
261 fprintf(stderr, "deflate should report Z_STREAM_END\n"); 277 fprintf(stderr, "deflate should report Z_STREAM_END\n");
278 exit(1);
262 } 279 }
263 err = deflateEnd(&c_stream); 280 err = deflateEnd(&c_stream);
264 CHECK_ERR(err, "deflateEnd"); 281 CHECK_ERR(err, "deflateEnd");
@@ -299,6 +316,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
299 316
300 if (d_stream.total_out != 2*uncomprLen + comprLen/2) { 317 if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
301 fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); 318 fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
319 exit(1);
302 } else { 320 } else {
303 printf("large_inflate(): OK\n"); 321 printf("large_inflate(): OK\n");
304 } 322 }
@@ -309,7 +327,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
309 */ 327 */
310void test_flush(compr, comprLen) 328void test_flush(compr, comprLen)
311 Byte *compr; 329 Byte *compr;
312 uLong comprLen; 330 uLong *comprLen;
313{ 331{
314 z_stream c_stream; /* compression stream */ 332 z_stream c_stream; /* compression stream */
315 int err; 333 int err;
@@ -325,7 +343,7 @@ void test_flush(compr, comprLen)
325 c_stream.next_in = (Bytef*)hello; 343 c_stream.next_in = (Bytef*)hello;
326 c_stream.next_out = compr; 344 c_stream.next_out = compr;
327 c_stream.avail_in = 3; 345 c_stream.avail_in = 3;
328 c_stream.avail_out = (uInt)comprLen; 346 c_stream.avail_out = (uInt)*comprLen;
329 err = deflate(&c_stream, Z_FULL_FLUSH); 347 err = deflate(&c_stream, Z_FULL_FLUSH);
330 CHECK_ERR(err, "deflate"); 348 CHECK_ERR(err, "deflate");
331 349
@@ -338,6 +356,8 @@ void test_flush(compr, comprLen)
338 } 356 }
339 err = deflateEnd(&c_stream); 357 err = deflateEnd(&c_stream);
340 CHECK_ERR(err, "deflateEnd"); 358 CHECK_ERR(err, "deflateEnd");
359
360 *comprLen = c_stream.total_out;
341} 361}
342 362
343/* =========================================================================== 363/* ===========================================================================
@@ -376,6 +396,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
376 if (err != Z_DATA_ERROR) { 396 if (err != Z_DATA_ERROR) {
377 fprintf(stderr, "inflate should report DATA_ERROR\n"); 397 fprintf(stderr, "inflate should report DATA_ERROR\n");
378 /* Because of incorrect adler32 */ 398 /* Because of incorrect adler32 */
399 exit(1);
379 } 400 }
380 err = inflateEnd(&d_stream); 401 err = inflateEnd(&d_stream);
381 CHECK_ERR(err, "inflateEnd"); 402 CHECK_ERR(err, "inflateEnd");
@@ -414,6 +435,7 @@ void test_dict_deflate(compr, comprLen)
414 err = deflate(&c_stream, Z_FINISH); 435 err = deflate(&c_stream, Z_FINISH);
415 if (err != Z_STREAM_END) { 436 if (err != Z_STREAM_END) {
416 fprintf(stderr, "deflate should report Z_STREAM_END\n"); 437 fprintf(stderr, "deflate should report Z_STREAM_END\n");
438 exit(1);
417 } 439 }
418 err = deflateEnd(&c_stream); 440 err = deflateEnd(&c_stream);
419 CHECK_ERR(err, "deflateEnd"); 441 CHECK_ERR(err, "deflateEnd");
@@ -463,6 +485,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
463 485
464 if (strcmp((char*)uncompr, hello)) { 486 if (strcmp((char*)uncompr, hello)) {
465 fprintf(stderr, "bad inflate with dict\n"); 487 fprintf(stderr, "bad inflate with dict\n");
488 exit(1);
466 } else { 489 } else {
467 printf("inflate with dictionary: %s\n", uncompr); 490 printf("inflate with dictionary: %s\n", uncompr);
468 } 491 }
@@ -510,8 +533,9 @@ int main(argc, argv)
510 test_large_deflate(compr, comprLen, uncompr, uncomprLen); 533 test_large_deflate(compr, comprLen, uncompr, uncomprLen);
511 test_large_inflate(compr, comprLen, uncompr, uncomprLen); 534 test_large_inflate(compr, comprLen, uncompr, uncomprLen);
512 535
513 test_flush(compr, comprLen); 536 test_flush(compr, &comprLen);
514 test_sync(compr, comprLen, uncompr, uncomprLen); 537 test_sync(compr, comprLen, uncompr, uncomprLen);
538 comprLen = uncomprLen;
515 539
516 test_dict_deflate(compr, comprLen); 540 test_dict_deflate(compr, comprLen);
517 test_dict_inflate(compr, comprLen, uncompr, uncomprLen); 541 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)
150 */ 150 */
151 fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], 151 fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
152 Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); 152 Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
153 s->startpos = ftell(s->file); 153 s->startpos = 10L;
154 /* We use 10L instead of ftell(s->file) to because ftell causes an
155 * fflush on some systems. This version of the library doesn't use
156 * startpos anyway in write mode, so this initialization is not
157 * necessary.
158 */
154 } else { 159 } else {
155 check_header(s); /* skip the .gz header */ 160 check_header(s); /* skip the .gz header */
156 s->startpos = (ftell(s->file) - s->stream.avail_in); 161 s->startpos = (ftell(s->file) - s->stream.avail_in);
@@ -423,7 +428,7 @@ int EXPORT gzread (file, buf, len)
423int EXPORT gzgetc(file) 428int EXPORT gzgetc(file)
424 gzFile file; 429 gzFile file;
425{ 430{
426 int c; 431 unsigned char c;
427 432
428 return gzread(file, &c, 1) == 1 ? c : -1; 433 return gzread(file, &c, 1) == 1 ? c : -1;
429} 434}
@@ -524,7 +529,9 @@ int EXPORT gzputc(file, c)
524 gzFile file; 529 gzFile file;
525 int c; 530 int c;
526{ 531{
527 return gzwrite(file, &c, 1) == 1 ? c : -1; 532 unsigned char cc = (unsigned char) c; /* required for big endian systems */
533
534 return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
528} 535}
529 536
530 537
@@ -627,7 +634,7 @@ z_off_t EXPORT gzseek (file, offset, whence)
627 634
628 offset -= size; 635 offset -= size;
629 } 636 }
630 return s->stream.total_in; 637 return (z_off_t)s->stream.total_in;
631#endif 638#endif
632 } 639 }
633 /* Rest of function is for reading only */ 640 /* Rest of function is for reading only */
@@ -667,7 +674,7 @@ z_off_t EXPORT gzseek (file, offset, whence)
667 if (size <= 0) return -1L; 674 if (size <= 0) return -1L;
668 offset -= size; 675 offset -= size;
669 } 676 }
670 return s->stream.total_out; 677 return (z_off_t)s->stream.total_out;
671} 678}
672 679
673/* =========================================================================== 680/* ===========================================================================
diff --git a/infblock.c b/infblock.c
index 4d81d72..7e9c7af 100644
--- a/infblock.c
+++ b/infblock.c
@@ -82,7 +82,7 @@ uLongf *c;
82 s->read = s->write = s->window; 82 s->read = s->write = s->window;
83 if (s->checkfn != Z_NULL) 83 if (s->checkfn != Z_NULL)
84 z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); 84 z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
85 Trace((stderr, "inflate: blocks reset\n")); 85 Tracev((stderr, "inflate: blocks reset\n"));
86} 86}
87 87
88 88
@@ -104,7 +104,7 @@ uInt w;
104 s->end = s->window + w; 104 s->end = s->window + w;
105 s->checkfn = c; 105 s->checkfn = c;
106 s->mode = TYPE; 106 s->mode = TYPE;
107 Trace((stderr, "inflate: blocks allocated\n")); 107 Tracev((stderr, "inflate: blocks allocated\n"));
108 inflate_blocks_reset(s, z, Z_NULL); 108 inflate_blocks_reset(s, z, Z_NULL);
109 return s; 109 return s;
110} 110}
@@ -139,7 +139,7 @@ int r;
139 switch (t >> 1) 139 switch (t >> 1)
140 { 140 {
141 case 0: /* stored */ 141 case 0: /* stored */
142 Trace((stderr, "inflate: stored block%s\n", 142 Tracev((stderr, "inflate: stored block%s\n",
143 s->last ? " (last)" : "")); 143 s->last ? " (last)" : ""));
144 DUMPBITS(3) 144 DUMPBITS(3)
145 t = k & 7; /* go to byte boundary */ 145 t = k & 7; /* go to byte boundary */
@@ -147,7 +147,7 @@ int r;
147 s->mode = LENS; /* get length of stored block */ 147 s->mode = LENS; /* get length of stored block */
148 break; 148 break;
149 case 1: /* fixed */ 149 case 1: /* fixed */
150 Trace((stderr, "inflate: fixed codes block%s\n", 150 Tracev((stderr, "inflate: fixed codes block%s\n",
151 s->last ? " (last)" : "")); 151 s->last ? " (last)" : ""));
152 { 152 {
153 uInt bl, bd; 153 uInt bl, bd;
@@ -167,7 +167,7 @@ int r;
167 s->mode = CODES; 167 s->mode = CODES;
168 break; 168 break;
169 case 2: /* dynamic */ 169 case 2: /* dynamic */
170 Trace((stderr, "inflate: dynamic codes block%s\n", 170 Tracev((stderr, "inflate: dynamic codes block%s\n",
171 s->last ? " (last)" : "")); 171 s->last ? " (last)" : ""));
172 DUMPBITS(3) 172 DUMPBITS(3)
173 s->mode = TABLE; 173 s->mode = TABLE;
@@ -387,7 +387,7 @@ z_streamp z;
387 inflate_blocks_reset(s, z, Z_NULL); 387 inflate_blocks_reset(s, z, Z_NULL);
388 ZFREE(z, s->window); 388 ZFREE(z, s->window);
389 ZFREE(z, s); 389 ZFREE(z, s);
390 Trace((stderr, "inflate: blocks freed\n")); 390 Tracev((stderr, "inflate: blocks freed\n"));
391 return Z_OK; 391 return Z_OK;
392} 392}
393 393
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;
321 /* search */ 321 /* search */
322 while (n && m < 4) 322 while (n && m < 4)
323 { 323 {
324 if (*p == (Byte)(m < 2 ? 0 : 0xff)) 324 static const Byte mark[4] = {0, 0, 0xff, 0xff};
325 if (*p == mark[m])
325 m++; 326 m++;
326 else if (*p) 327 else if (*p)
327 m = 0; 328 m = 0;
diff --git a/inftrees.c b/inftrees.c
index bdd3a98..3c2facf 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -7,7 +7,7 @@
7#include "inftrees.h" 7#include "inftrees.h"
8 8
9const char inflate_copyright[] = 9const char inflate_copyright[] =
10 " inflate 1.0.7 Copyright 1995-1998 Mark Adler "; 10 " inflate 1.0.8 Copyright 1995-1998 Mark Adler ";
11/* 11/*
12 If you use the zlib library in a product, an acknowledgment is welcome 12 If you use the zlib library in a product, an acknowledgment is welcome
13 in the documentation of your product. If for some reason you cannot 13 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;
66void error OF((const char *msg)); 66void error OF((const char *msg));
67void gz_compress OF((FILE *in, gzFile out)); 67void gz_compress OF((FILE *in, gzFile out));
68void gz_uncompress OF((gzFile in, FILE *out)); 68void gz_uncompress OF((gzFile in, FILE *out));
69void file_compress OF((char *file)); 69void file_compress OF((char *file, char *mode));
70void file_uncompress OF((char *file)); 70void file_uncompress OF((char *file));
71int main OF((int argc, char *argv[])); 71int main OF((int argc, char *argv[]));
72 72
@@ -135,8 +135,9 @@ void gz_uncompress(in, out)
135 * Compress the given file: create a corresponding .gz file and remove the 135 * Compress the given file: create a corresponding .gz file and remove the
136 * original. 136 * original.
137 */ 137 */
138void file_compress(file) 138void file_compress(file, mode)
139 char *file; 139 char *file;
140 char *mode;
140{ 141{
141 local char outfile[MAX_NAME_LEN]; 142 local char outfile[MAX_NAME_LEN];
142 FILE *in; 143 FILE *in;
@@ -150,7 +151,7 @@ void file_compress(file)
150 perror(file); 151 perror(file);
151 exit(1); 152 exit(1);
152 } 153 }
153 out = gzopen(outfile, "wb"); /* use "wb9" for maximal compression */ 154 out = gzopen(outfile, mode);
154 if (out == NULL) { 155 if (out == NULL) {
155 fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); 156 fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
156 exit(1); 157 exit(1);
@@ -253,7 +254,7 @@ int main(argc, argv)
253 if (uncompr) { 254 if (uncompr) {
254 file_uncompress(*argv); 255 file_uncompress(*argv);
255 } else { 256 } else {
256 file_compress(*argv); 257 file_compress(*argv, outmode);
257 } 258 }
258 } while (argv++, --argc); 259 } while (argv++, --argc);
259 } 260 }
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
8 8
9STUB 'WINSTUB.EXE' 9STUB 'WINSTUB.EXE'
10 10
11VERSION 1.07 11VERSION 1.08
12 12
13CODE EXECUTE READ 13CODE EXECUTE READ
14 14
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 @@
2 2
3#define IDR_VERSION1 1 3#define IDR_VERSION1 1
4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
5 FILEVERSION 1,0,7,0 5 FILEVERSION 1,0,8,0
6 PRODUCTVERSION 1,0,7,0 6 PRODUCTVERSION 1,0,8,0
7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 FILEFLAGS 0 8 FILEFLAGS 0
9 FILEOS VOS_DOS_WINDOWS32 9 FILEOS VOS_DOS_WINDOWS32
@@ -17,9 +17,9 @@ BEGIN
17 17
18 BEGIN 18 BEGIN
19 VALUE "FileDescription", "zlib data compression library\0" 19 VALUE "FileDescription", "zlib data compression library\0"
20 VALUE "FileVersion", "1.0.7\0" 20 VALUE "FileVersion", "1.0.8\0"
21 VALUE "InternalName", "zlib\0" 21 VALUE "InternalName", "zlib\0"
22 VALUE "OriginalFilename", "zlib.lib\0" 22 VALUE "OriginalFilename", "zlib.dll\0"
23 VALUE "ProductName", "ZLib.DLL\0" 23 VALUE "ProductName", "ZLib.DLL\0"
24 VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 24 VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
25 VALUE "LegalCopyright", "(C) 1995-1998 Jean-loup Gailly & Mark Adler\0" 25 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 @@
1extern int getchar();
2int 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 @@
31 31
32/* @(#) $Id$ */ 32/* @(#) $Id$ */
33 33
34/* #define GEN_TREES_H */
35
34#include "deflate.h" 36#include "deflate.h"
35 37
36#ifdef DEBUG 38#ifdef DEBUG
@@ -80,6 +82,11 @@ local const uch bl_order[BL_CODES]
80 * Local data. These are initialized only once. 82 * Local data. These are initialized only once.
81 */ 83 */
82 84
85#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
86
87#if defined(GEN_TREES_H) || !defined(STDC)
88/* non ANSI compilers may not accept trees.h */
89
83local ct_data static_ltree[L_CODES+2]; 90local ct_data static_ltree[L_CODES+2];
84/* The static literal tree. Since the bit lengths are imposed, there is no 91/* The static literal tree. Since the bit lengths are imposed, there is no
85 * need for the L_CODES extra codes used during heap construction. However 92 * need for the L_CODES extra codes used during heap construction. However
@@ -92,8 +99,8 @@ local ct_data static_dtree[D_CODES];
92 * 5 bits.) 99 * 5 bits.)
93 */ 100 */
94 101
95local uch dist_code[512]; 102local uch dist_code[DIST_CODE_LEN];
96/* distance codes. The first 256 values correspond to the distances 103/* Distance codes. The first 256 values correspond to the distances
97 * 3 .. 258, the last 256 values correspond to the top 8 bits of 104 * 3 .. 258, the last 256 values correspond to the top 8 bits of
98 * the 15 bit distances. 105 * the 15 bit distances.
99 */ 106 */
@@ -107,8 +114,12 @@ local int base_length[LENGTH_CODES];
107local int base_dist[D_CODES]; 114local int base_dist[D_CODES];
108/* First normalized distance for each code (0 = distance of 1) */ 115/* First normalized distance for each code (0 = distance of 1) */
109 116
117#else
118# include "trees.h"
119#endif /* GEN_TREES_H */
120
110struct static_tree_desc_s { 121struct static_tree_desc_s {
111 ct_data *static_tree; /* static tree or NULL */ 122 const ct_data *static_tree; /* static tree or NULL */
112 const intf *extra_bits; /* extra bits for each code or NULL */ 123 const intf *extra_bits; /* extra bits for each code or NULL */
113 int extra_base; /* base index for extra_bits */ 124 int extra_base; /* base index for extra_bits */
114 int elems; /* max number of elements in the tree */ 125 int elems; /* max number of elements in the tree */
@@ -122,7 +133,7 @@ local static_tree_desc static_d_desc =
122{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; 133{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
123 134
124local static_tree_desc static_bl_desc = 135local static_tree_desc static_bl_desc =
125{(ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; 136{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
126 137
127/* =========================================================================== 138/* ===========================================================================
128 * Local (static) routines in this file. 139 * Local (static) routines in this file.
@@ -148,6 +159,10 @@ local void bi_flush OF((deflate_state *s));
148local void copy_block OF((deflate_state *s, charf *buf, unsigned len, 159local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
149 int header)); 160 int header));
150 161
162#ifdef GEN_TREES_H
163local void gen_trees_header OF((void));
164#endif
165
151#ifndef DEBUG 166#ifndef DEBUG
152# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) 167# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
153 /* Send a code of the given tree. c and tree must not have side effects */ 168 /* 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)
226/* the arguments must not have side effects */ 241/* the arguments must not have side effects */
227 242
228/* =========================================================================== 243/* ===========================================================================
229 * Initialize the various 'constant' tables. In a multi-threaded environment, 244 * Initialize the various 'constant' tables.
230 * this function may be called by two threads concurrently, but this is
231 * harmless since both invocations do exactly the same thing.
232 */ 245 */
233local void tr_static_init() 246local void tr_static_init()
234{ 247{
248#if defined(GEN_TREES_H) || !defined(STDC)
235 static int static_init_done = 0; 249 static int static_init_done = 0;
236 int n; /* iterates over tree elements */ 250 int n; /* iterates over tree elements */
237 int bits; /* bit counter */ 251 int bits; /* bit counter */
@@ -295,7 +309,73 @@ local void tr_static_init()
295 static_dtree[n].Code = bi_reverse((unsigned)n, 5); 309 static_dtree[n].Code = bi_reverse((unsigned)n, 5);
296 } 310 }
297 static_init_done = 1; 311 static_init_done = 1;
312
313# ifdef GEN_TREES_H
314 gen_trees_header();
315# endif
316#endif /* defined(GEN_TREES_H) || !defined(STDC) */
317}
318
319/* ===========================================================================
320 * Genererate the file trees.h describing the static trees.
321 */
322#ifdef GEN_TREES_H
323# ifndef DEBUG
324# include <stdio.h>
325# endif
326
327# define SEPARATOR(i, last, width) \
328 ((i) == (last)? "\n};\n\n" : \
329 ((i) % (width) == (width)-1 ? ",\n" : ", "))
330
331void gen_trees_header()
332{
333 FILE *header = fopen("trees.h", "w");
334 int i;
335
336 Assert (header != NULL, "Can't open trees.h");
337 fprintf(header,
338 "/* header created automatically with -DGEN_TREES_H */\n\n");
339
340 fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
341 for (i = 0; i < L_CODES+2; i++) {
342 fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
343 static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
344 }
345
346 fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
347 for (i = 0; i < D_CODES; i++) {
348 fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
349 static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
350 }
351
352 fprintf(header, "local const uch dist_code[DIST_CODE_LEN] = {\n");
353 for (i = 0; i < DIST_CODE_LEN; i++) {
354 fprintf(header, "%2u%s", dist_code[i],
355 SEPARATOR(i, DIST_CODE_LEN-1, 20));
356 }
357
358 fprintf(header, "local const uch length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
359 for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
360 fprintf(header, "%2u%s", length_code[i],
361 SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
362 }
363
364 fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
365 for (i = 0; i < LENGTH_CODES; i++) {
366 fprintf(header, "%1u%s", base_length[i],
367 SEPARATOR(i, LENGTH_CODES-1, 20));
368 }
369
370 fprintf(header, "local const int base_dist[D_CODES] = {\n");
371 for (i = 0; i < D_CODES; i++) {
372 fprintf(header, "%5u%s", base_dist[i],
373 SEPARATOR(i, D_CODES-1, 10));
374 }
375
376 fclose(header);
298} 377}
378#endif /* GEN_TREES_H */
299 379
300/* =========================================================================== 380/* ===========================================================================
301 * Initialize the tree data structures for a new zlib stream. 381 * Initialize the tree data structures for a new zlib stream.
@@ -413,12 +493,12 @@ local void gen_bitlen(s, desc)
413 deflate_state *s; 493 deflate_state *s;
414 tree_desc *desc; /* the tree descriptor */ 494 tree_desc *desc; /* the tree descriptor */
415{ 495{
416 ct_data *tree = desc->dyn_tree; 496 ct_data *tree = desc->dyn_tree;
417 int max_code = desc->max_code; 497 int max_code = desc->max_code;
418 ct_data *stree = desc->stat_desc->static_tree; 498 const ct_data *stree = desc->stat_desc->static_tree;
419 const intf *extra = desc->stat_desc->extra_bits; 499 const intf *extra = desc->stat_desc->extra_bits;
420 int base = desc->stat_desc->extra_base; 500 int base = desc->stat_desc->extra_base;
421 int max_length = desc->stat_desc->max_length; 501 int max_length = desc->stat_desc->max_length;
422 int h; /* heap index */ 502 int h; /* heap index */
423 int n, m; /* iterate over the tree elements */ 503 int n, m; /* iterate over the tree elements */
424 int bits; /* bit length */ 504 int bits; /* bit length */
@@ -542,9 +622,9 @@ local void build_tree(s, desc)
542 deflate_state *s; 622 deflate_state *s;
543 tree_desc *desc; /* the tree descriptor */ 623 tree_desc *desc; /* the tree descriptor */
544{ 624{
545 ct_data *tree = desc->dyn_tree; 625 ct_data *tree = desc->dyn_tree;
546 ct_data *stree = desc->stat_desc->static_tree; 626 const ct_data *stree = desc->stat_desc->static_tree;
547 int elems = desc->stat_desc->elems; 627 int elems = desc->stat_desc->elems;
548 int n, m; /* iterate over heap elements */ 628 int n, m; /* iterate over heap elements */
549 int max_code = -1; /* largest code with non zero frequency */ 629 int max_code = -1; /* largest code with non zero frequency */
550 int node; /* new node being created */ 630 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 @@
1/* header created automatically with -DGEN_TREES_H */
2
3local const ct_data static_ltree[L_CODES+2] = {
4{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
5{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
6{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
7{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
8{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
9{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
10{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
11{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
12{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
13{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
14{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
15{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
16{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
17{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
18{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
19{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
20{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
21{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
22{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
23{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
24{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
25{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
26{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
27{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
28{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
29{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
30{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
31{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
32{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
33{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
34{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
35{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
36{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
37{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
38{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
39{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
40{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
41{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
42{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
43{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
44{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
45{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
46{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
47{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
48{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
49{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
50{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
51{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
52{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
53{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
54{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
55{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
56{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
57{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
58{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
59{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
60{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
61{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
62};
63
64local const ct_data static_dtree[D_CODES] = {
65{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
66{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
67{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
68{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
69{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
70{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
71};
72
73local const uch dist_code[DIST_CODE_LEN] = {
74 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
75 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
7610, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
7711, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
7812, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
7913, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
8013, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8114, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8214, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8314, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
8415, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
8515, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
8615, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
8718, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
8823, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8924, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
9026, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
9126, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
9227, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
9327, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
9428, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
9528, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
9628, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
9729, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
9829, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
9929, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
100};
101
102local const uch length_code[MAX_MATCH-MIN_MATCH+1]= {
103 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
10413, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
10517, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
10619, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
10721, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
10822, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
10923, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
11024, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
11125, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
11225, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
11326, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
11426, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
11527, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
116};
117
118local const int base_length[LENGTH_CODES] = {
1190, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
12064, 80, 96, 112, 128, 160, 192, 224, 0
121};
122
123local const int base_dist[D_CODES] = {
124 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
125 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
126 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
127};
128
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;
186#endif 186#endif
187 187
188#ifdef HAVE_UNISTD_H 188#ifdef HAVE_UNISTD_H
189# include <unistd.h> /* for SEEK_* and off_t */ 189# include <sys/types.h> /* for off_t */
190# include <unistd.h> /* for SEEK_* and off_t */
190# define z_off_t off_t 191# define z_off_t off_t
191#endif 192#endif
192#ifndef SEEK_SET 193#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 @@
1.TH ZLIB 3 "20 January 1998" 1.TH ZLIB 3 "26 January 1998"
2.SH NAME 2.SH NAME
3zlib \- compression/decompression library 3zlib \- compression/decompression library
4.SH SYNOPSIS 4.SH SYNOPSIS
@@ -9,7 +9,7 @@ for full descripton]
9The 9The
10.I zlib 10.I zlib
11library is a general purpose data compression library. 11library is a general purpose data compression library.
12The code is reentrant (thread safe). 12The code is thread safe.
13It provides in-memory compression and decompression functions, 13It provides in-memory compression and decompression functions,
14including integrity checks of the uncompressed data. 14including integrity checks of the uncompressed data.
15This version of the library supports only one compression method (deflation) 15This version of the library supports only one compression method (deflation)
@@ -66,7 +66,7 @@ zlib@quest.jpl.nasa.gov
66or, if this fails, to the author addresses given below. 66or, if this fails, to the author addresses given below.
67The zlib home page is: 67The zlib home page is:
68.IP 68.IP
69http://www.cdrom.com/infozip/zlib/ 69http://www.cdrom.com/pub/infozip/zlib/
70.LP 70.LP
71The data format used by the zlib library is described by RFC 71The data format used by the zlib library is described by RFC
72(Request for Comments) 1950 to 1952 in the files: 72(Request for Comments) 1950 to 1952 in the files:
@@ -81,7 +81,7 @@ These documents are also available in other formats from:
81.IP 81.IP
82ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html 82ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
83.SH AUTHORS 83.SH AUTHORS
84Version 1.0.7. 84Version 1.0.8.
85Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org) 85Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org)
86and Mark Adler (madler@alumni.caltech.edu). 86and Mark Adler (madler@alumni.caltech.edu).
87.LP 87.LP
diff --git a/zlib.h b/zlib.h
index cc1b423..2319835 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
1/* zlib.h -- interface of the 'zlib' general purpose compression library 1/* zlib.h -- interface of the 'zlib' general purpose compression library
2 version 1.0.7, Jan 20th, 1998 2 version 1.0.8, Jan 27th, 1998
3 3
4 Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler 4 Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
5 5
@@ -37,7 +37,7 @@ extern "C" {
37 37
38#include "zconf.h" 38#include "zconf.h"
39 39
40#define ZLIB_VERSION "1.0.7" 40#define ZLIB_VERSION "1.0.8"
41 41
42/* 42/*
43 The 'zlib' compression library provides in-memory compression and 43 The 'zlib' compression library provides in-memory compression and
@@ -614,6 +614,21 @@ extern int EXPORT compress OF((Bytef *dest, uLongf *destLen,
614 buffer. 614 buffer.
615*/ 615*/
616 616
617extern int EXPORT compress2 OF((Bytef *dest, uLongf *destLen,
618 const Bytef *source, uLong sourceLen,
619 int level));
620/*
621 Compresses the source buffer into the destination buffer. The level
622 parameter has the same meaning as in deflateInit. sourceLen is the byte
623 length of the source buffer. Upon entry, destLen is the total size of the
624 destination buffer, which must be at least 0.1% larger than sourceLen plus
625 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
626
627 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
628 memory, Z_BUF_ERROR if there was not enough room in the output buffer,
629 Z_STREAM_ERROR if the level parameter is invalid.
630*/
631
617extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen, 632extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen,
618 const Bytef *source, uLong sourceLen)); 633 const Bytef *source, uLong sourceLen));
619/* 634/*
@@ -842,9 +857,9 @@ extern int EXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
842 struct internal_state {int dummy;}; /* hack for buggy compilers */ 857 struct internal_state {int dummy;}; /* hack for buggy compilers */
843#endif 858#endif
844 859
845extern const char * EXPORT zError OF((int err)); 860extern const char * EXPORT zError OF((int err));
846extern int EXPORT inflateSyncPoint OF((z_streamp z)); 861extern int EXPORT inflateSyncPoint OF((z_streamp z));
847extern uLongf * EXPORT get_crc_table OF((void)); 862extern const uLongf * EXPORT get_crc_table OF((void));
848 863
849#ifdef __cplusplus 864#ifdef __cplusplus
850} 865}
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 @@
5 5
6/* @(#) $Id$ */ 6/* @(#) $Id$ */
7 7
8#include <stdio.h>
9
10#include "zutil.h" 8#include "zutil.h"
11 9
12struct internal_state {int dummy;}; /* for buggy compilers */ 10struct 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 */
110# define OS_CODE 0x05 110# define OS_CODE 0x05
111#endif 111#endif
112 112
113#ifdef MACOS 113#if defined(MACOS) || defined(TARGET_OS_MAC)
114# define OS_CODE 0x07 114# define OS_CODE 0x07
115# ifndef fdopen
116# define fdopen(fd,mode) NULL /* No fdopen() */
117# endif
118#endif
119#if defined(__MWERKS__) && !defined(fdopen)
120# if __dest_os != __be_os && __dest_os != __win32_os
121# define fdopen(fd,mode) NULL
122# endif
115#endif 123#endif
116 124
117#ifdef __50SERIES /* Prime/PRIMOS */ 125#ifdef __50SERIES /* Prime/PRIMOS */