Skip to content

Commit

Permalink
zlib 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
madler committed Sep 10, 2011
1 parent 7850e4e commit 6759211
Show file tree
Hide file tree
Showing 27 changed files with 482 additions and 144 deletions.
27 changes: 26 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
28 changes: 19 additions & 9 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
45 changes: 26 additions & 19 deletions README
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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".

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
35 changes: 23 additions & 12 deletions compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
}
39 changes: 24 additions & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
int hello() { printf("hello\n"); }
extern int getchar();
int hello() {return getchar();}
EOF
if test -z "$CC" -o "$CC" = "gcc" && (gcc -c -O3 $test.c) 2>/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"};;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions contrib/README.contrib
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ for help about these, not the zlib authors. Thanks.


asm386/ by Gilles Vollant <info@winimage.com>
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 <kevin@rodin.wustl.edu>
A C++ I/O streams interface to the zlib gz* functions
Expand Down
Loading

0 comments on commit 6759211

Please sign in to comment.