Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02b6cf579f | ||
|
|
965fe72aed |
19
ChangeLog
19
ChangeLog
@@ -1,6 +1,25 @@
|
|||||||
|
|
||||||
ChangeLog file for zlib
|
ChangeLog file for zlib
|
||||||
|
|
||||||
|
Changes in 1.1.1 (27 Feb 98)
|
||||||
|
- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
|
||||||
|
- remove block truncation heuristic which had very marginal effect for zlib
|
||||||
|
(smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
|
||||||
|
compression ratio on some files. This also allows inlining _tr_tally for
|
||||||
|
matches in deflate_slow.
|
||||||
|
- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
|
||||||
|
|
||||||
|
Changes in 1.1.0 (24 Feb 98)
|
||||||
|
- do not return STREAM_END prematurely in inflate (John Bowler)
|
||||||
|
- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
|
||||||
|
- compile with -DFASTEST to get compression code optimized for speed only
|
||||||
|
- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
|
||||||
|
- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
|
||||||
|
on Sun but significant on HP)
|
||||||
|
|
||||||
|
- add a pointer to experimental unzip library in README (Gilles Vollant)
|
||||||
|
- initialize variable gcc in configure (Chris Herborth)
|
||||||
|
|
||||||
Changes in 1.0.9 (17 Feb 1998)
|
Changes in 1.0.9 (17 Feb 1998)
|
||||||
- added gzputs and gzgets functions
|
- added gzputs and gzgets functions
|
||||||
- do not clear eof flag in gzseek (Mark Diekhans)
|
- do not clear eof flag in gzseek (Mark Diekhans)
|
||||||
|
|||||||
1
INDEX
1
INDEX
@@ -13,6 +13,7 @@ descrip.mms makefile for Vax/VMS
|
|||||||
zlib.3 mini man page for zlib (volunteers to write full
|
zlib.3 mini man page for zlib (volunteers to write full
|
||||||
man pages from zlib.h welcome. write to jloup@gzip.org)
|
man pages from zlib.h welcome. write to jloup@gzip.org)
|
||||||
|
|
||||||
|
msdos/Makefile.w32 makefile for Microsoft Visual C++ 32-bit
|
||||||
msdos/Makefile.b32 makefile for Borland C++ 32-bit
|
msdos/Makefile.b32 makefile for Borland C++ 32-bit
|
||||||
msdos/Makefile.bor makefile for Borland C/C++ 16-bit
|
msdos/Makefile.bor makefile for Borland C/C++ 16-bit
|
||||||
msdos/Makefile.dj2 makefile for DJGPP 2.x
|
msdos/Makefile.dj2 makefile for DJGPP 2.x
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -23,7 +23,7 @@ CFLAGS=-O
|
|||||||
LDFLAGS=-L. -lz
|
LDFLAGS=-L. -lz
|
||||||
LDSHARED=$(CC)
|
LDSHARED=$(CC)
|
||||||
|
|
||||||
VER=1.0.9
|
VER=1.1.1
|
||||||
LIBS=libz.a
|
LIBS=libz.a
|
||||||
SHAREDLIB=libz.so
|
SHAREDLIB=libz.so
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ CFLAGS=-O
|
|||||||
LDFLAGS=-L. -lz
|
LDFLAGS=-L. -lz
|
||||||
LDSHARED=$(CC)
|
LDSHARED=$(CC)
|
||||||
|
|
||||||
VER=1.0.9
|
VER=1.1.1
|
||||||
LIBS=libz.a
|
LIBS=libz.a
|
||||||
SHAREDLIB=libz.so
|
SHAREDLIB=libz.so
|
||||||
|
|
||||||
|
|||||||
30
README
30
README
@@ -1,4 +1,4 @@
|
|||||||
zlib 1.0.9 is a general purpose data compression library. All the code
|
zlib 1.1.1 is a general purpose data compression library. All the code
|
||||||
is thread safe. The data format used by the zlib library
|
is thread safe. The data format used by the zlib library
|
||||||
is described by RFCs (Request for Comments) 1950 to 1952 in the files
|
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
|
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||||
@@ -25,21 +25,14 @@ 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
|
Dr. Dobb's Journal; a copy of the article is available in
|
||||||
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
|
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
|
||||||
|
|
||||||
The changes made in version 1.0.9 are documented in the file ChangeLog.
|
The changes made in version 1.1.1 are documented in the file ChangeLog.
|
||||||
The main changes since 1.0.8 are:
|
The main changes since 1.1.0 are:
|
||||||
|
|
||||||
- added gzputs and gzgets functions
|
- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
|
||||||
- do not clear eof flag in gzseek (Mark Diekhans)
|
- remove block truncation heuristic which had very marginal effect for zlib
|
||||||
- fix gzseek for files in transparent mode (Mark Diekhans)
|
(smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
|
||||||
- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
|
compression ratio on some files. This also allows inlining _tr_tally for
|
||||||
- replace EXPORT with ZEXPORT to avoid conflict with other programs
|
matches in deflate_slow.
|
||||||
- added compress2 in zconf.h, zlib.def, zlib.dnt
|
|
||||||
- new asm code from Gilles Vollant in contrib/asm386
|
|
||||||
- simplify the inflate code (Mark):
|
|
||||||
. Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
|
|
||||||
. ZALLOC the length list in inflate_trees_fixed() instead of using stack
|
|
||||||
. ZALLOC the value area for huft_build() instead of using stack
|
|
||||||
. Simplify Z_FINISH check in inflate()
|
|
||||||
|
|
||||||
|
|
||||||
Unsupported third party contributions are provided in directory "contrib".
|
Unsupported third party contributions are provided in directory "contrib".
|
||||||
@@ -56,6 +49,11 @@ A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
|
|||||||
is available from the Python Software Association sites, such as:
|
is available from the Python Software Association sites, such as:
|
||||||
ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz
|
ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz
|
||||||
|
|
||||||
|
An experimental package to read files in .zip format, written on top of
|
||||||
|
zlib by Gilles Vollant <info@winimage.com>, is available at
|
||||||
|
http://www.winimage.com/zLibDll/unzip.html
|
||||||
|
|
||||||
|
|
||||||
Notes for some targets:
|
Notes for some targets:
|
||||||
|
|
||||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||||
@@ -83,7 +81,7 @@ Notes for some targets:
|
|||||||
writes to pointers are atomic. Also the functions zalloc and zfree passed
|
writes to pointers are atomic. Also the functions zalloc and zfree passed
|
||||||
to deflateInit must be multi-threaded in this case.
|
to deflateInit must be multi-threaded in this case.
|
||||||
|
|
||||||
- gzdopen is not supported on RISCOS, BEOS and Mac
|
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||||
|
|
||||||
- For Turbo C the small model is supported only with reduced performance to
|
- 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
|
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
|
||||||
|
|||||||
19
configure
vendored
19
configure
vendored
@@ -27,6 +27,7 @@ prefix=${prefix-/usr/local}
|
|||||||
exec_prefix=${exec_prefix-$prefix}
|
exec_prefix=${exec_prefix-$prefix}
|
||||||
shared_ext='.so'
|
shared_ext='.so'
|
||||||
shared=0
|
shared=0
|
||||||
|
gcc=0
|
||||||
old_cc="$CC"
|
old_cc="$CC"
|
||||||
old_cflags="$CFLAGS"
|
old_cflags="$CFLAGS"
|
||||||
|
|
||||||
@@ -114,7 +115,6 @@ if test $shared -eq 0; then
|
|||||||
LDSHARED="$CC"
|
LDSHARED="$CC"
|
||||||
echo Building static library $LIBS version $VER with $CC.
|
echo Building static library $LIBS version $VER with $CC.
|
||||||
fi
|
fi
|
||||||
rm -f $test.[co] $test$shared_ext
|
|
||||||
|
|
||||||
if test -f /usr/include/unistd.h; then
|
if test -f /usr/include/unistd.h; then
|
||||||
CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
|
CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
|
||||||
@@ -124,6 +124,23 @@ if test ! -f /usr/include/errno.h; then
|
|||||||
CFLAGS="$CFLAGS -DNO_ERRNO_H"
|
CFLAGS="$CFLAGS -DNO_ERRNO_H"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat > $test.c <<EOF
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
caddr_t hello() {
|
||||||
|
return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
||||||
|
CFLAGS="$CFLAGS -DUSE_MMAP"
|
||||||
|
echo Checking for mmap support... Yes.
|
||||||
|
else
|
||||||
|
echo Checking for mmap support... No.
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f $test.[co] $test$shared_ext
|
||||||
|
|
||||||
# udpate Makefile
|
# udpate Makefile
|
||||||
sed < Makefile.in "
|
sed < Makefile.in "
|
||||||
/^CC *=/s%=.*%=$CC%
|
/^CC *=/s%=.*%=$CC%
|
||||||
|
|||||||
95
deflate.c
95
deflate.c
@@ -52,7 +52,7 @@
|
|||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.0.9 Copyright 1995-1998 Jean-loup Gailly ";
|
" deflate 1.1.1 Copyright 1995-1998 Jean-loup Gailly ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
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
|
in the documentation of your product. If for some reason you cannot
|
||||||
@@ -160,14 +160,23 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
|||||||
* Insert string str in the dictionary and set match_head to the previous head
|
* Insert string str in the dictionary and set match_head to the previous head
|
||||||
* of the hash chain (the most recent string with same hash key). Return
|
* of the hash chain (the most recent string with same hash key). Return
|
||||||
* the previous length of the hash chain.
|
* the previous length of the hash chain.
|
||||||
|
* If this file is compiled with -DFASTEST, the compression level is forced
|
||||||
|
* to 1, and no hash chains are maintained.
|
||||||
* IN assertion: all calls to to INSERT_STRING are made with consecutive
|
* IN assertion: all calls to to INSERT_STRING are made with consecutive
|
||||||
* input characters and the first MIN_MATCH bytes of str are valid
|
* input characters and the first MIN_MATCH bytes of str are valid
|
||||||
* (except for the last MIN_MATCH-1 bytes of the input file).
|
* (except for the last MIN_MATCH-1 bytes of the input file).
|
||||||
*/
|
*/
|
||||||
|
#ifdef FASTEST
|
||||||
|
#define INSERT_STRING(s, str, match_head) \
|
||||||
|
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
||||||
|
match_head = s->head[s->ins_h], \
|
||||||
|
s->head[s->ins_h] = (Pos)(str))
|
||||||
|
#else
|
||||||
#define INSERT_STRING(s, str, match_head) \
|
#define INSERT_STRING(s, str, match_head) \
|
||||||
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
||||||
s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \
|
s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \
|
||||||
s->head[s->ins_h] = (Pos)(str))
|
s->head[s->ins_h] = (Pos)(str))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
|
* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
|
||||||
@@ -224,6 +233,9 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|||||||
if (strm->zfree == Z_NULL) strm->zfree = zcfree;
|
if (strm->zfree == Z_NULL) strm->zfree = zcfree;
|
||||||
|
|
||||||
if (level == Z_DEFAULT_COMPRESSION) level = 6;
|
if (level == Z_DEFAULT_COMPRESSION) level = 6;
|
||||||
|
#ifdef FASTEST
|
||||||
|
level = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (windowBits < 0) { /* undocumented feature: suppress zlib header */
|
if (windowBits < 0) { /* undocumented feature: suppress zlib header */
|
||||||
noheader = 1;
|
noheader = 1;
|
||||||
@@ -708,6 +720,7 @@ local void lm_init (s)
|
|||||||
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
||||||
* match.S. The code will be functionally equivalent.
|
* match.S. The code will be functionally equivalent.
|
||||||
*/
|
*/
|
||||||
|
#ifndef FASTEST
|
||||||
local uInt longest_match(s, cur_match)
|
local uInt longest_match(s, cur_match)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
IPos cur_match; /* current match */
|
IPos cur_match; /* current match */
|
||||||
@@ -845,6 +858,64 @@ local uInt longest_match(s, cur_match)
|
|||||||
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
|
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
|
||||||
return s->lookahead;
|
return s->lookahead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* FASTEST */
|
||||||
|
/* ---------------------------------------------------------------------------
|
||||||
|
* Optimized version for level == 1 only
|
||||||
|
*/
|
||||||
|
local uInt longest_match(s, cur_match)
|
||||||
|
deflate_state *s;
|
||||||
|
IPos cur_match; /* current match */
|
||||||
|
{
|
||||||
|
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||||
|
register Bytef *match; /* matched string */
|
||||||
|
register int len; /* length of current match */
|
||||||
|
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
|
||||||
|
|
||||||
|
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
|
||||||
|
* It is easy to get rid of this optimization if necessary.
|
||||||
|
*/
|
||||||
|
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
||||||
|
|
||||||
|
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
||||||
|
|
||||||
|
Assert(cur_match < s->strstart, "no future");
|
||||||
|
|
||||||
|
match = s->window + cur_match;
|
||||||
|
|
||||||
|
/* Return failure if the match length is less than 2:
|
||||||
|
*/
|
||||||
|
if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
|
||||||
|
|
||||||
|
/* The check at best_len-1 can be removed because it will be made
|
||||||
|
* again later. (This heuristic is not always a win.)
|
||||||
|
* It is not necessary to compare scan[2] and match[2] since they
|
||||||
|
* are always equal when the other bytes match, given that
|
||||||
|
* the hash keys are equal and that HASH_BITS >= 8.
|
||||||
|
*/
|
||||||
|
scan += 2, match += 2;
|
||||||
|
Assert(*scan == *match, "match[2]?");
|
||||||
|
|
||||||
|
/* We check for insufficient lookahead only every 8th comparison;
|
||||||
|
* the 256th check will be made at strstart+258.
|
||||||
|
*/
|
||||||
|
do {
|
||||||
|
} while (*++scan == *++match && *++scan == *++match &&
|
||||||
|
*++scan == *++match && *++scan == *++match &&
|
||||||
|
*++scan == *++match && *++scan == *++match &&
|
||||||
|
*++scan == *++match && *++scan == *++match &&
|
||||||
|
scan < strend);
|
||||||
|
|
||||||
|
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
||||||
|
|
||||||
|
len = MAX_MATCH - (int)(strend - scan);
|
||||||
|
|
||||||
|
if (len < MIN_MATCH) return MIN_MATCH - 1;
|
||||||
|
|
||||||
|
s->match_start = cur_match;
|
||||||
|
return len <= s->lookahead ? len : s->lookahead;
|
||||||
|
}
|
||||||
|
#endif /* FASTEST */
|
||||||
#endif /* ASMV */
|
#endif /* ASMV */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -930,6 +1001,7 @@ local void fill_window(s)
|
|||||||
} while (--n);
|
} while (--n);
|
||||||
|
|
||||||
n = wsize;
|
n = wsize;
|
||||||
|
#ifndef FASTEST
|
||||||
p = &s->prev[n];
|
p = &s->prev[n];
|
||||||
do {
|
do {
|
||||||
m = *--p;
|
m = *--p;
|
||||||
@@ -938,6 +1010,7 @@ local void fill_window(s)
|
|||||||
* its value will never be used.
|
* its value will never be used.
|
||||||
*/
|
*/
|
||||||
} while (--n);
|
} while (--n);
|
||||||
|
#endif
|
||||||
more += wsize;
|
more += wsize;
|
||||||
}
|
}
|
||||||
if (s->strm->avail_in == 0) return;
|
if (s->strm->avail_in == 0) return;
|
||||||
@@ -1105,14 +1178,15 @@ local block_state deflate_fast(s, flush)
|
|||||||
if (s->match_length >= MIN_MATCH) {
|
if (s->match_length >= MIN_MATCH) {
|
||||||
check_match(s, s->strstart, s->match_start, s->match_length);
|
check_match(s, s->strstart, s->match_start, s->match_length);
|
||||||
|
|
||||||
bflush = _tr_tally(s, s->strstart - s->match_start,
|
_tr_tally_dist(s, s->strstart - s->match_start,
|
||||||
s->match_length - MIN_MATCH);
|
s->match_length - MIN_MATCH, bflush);
|
||||||
|
|
||||||
s->lookahead -= s->match_length;
|
s->lookahead -= s->match_length;
|
||||||
|
|
||||||
/* Insert new strings in the hash table only if the match length
|
/* Insert new strings in the hash table only if the match length
|
||||||
* is not too large. This saves time but degrades compression.
|
* is not too large. This saves time but degrades compression.
|
||||||
*/
|
*/
|
||||||
|
#ifndef FASTEST
|
||||||
if (s->match_length <= s->max_insert_length &&
|
if (s->match_length <= s->max_insert_length &&
|
||||||
s->lookahead >= MIN_MATCH) {
|
s->lookahead >= MIN_MATCH) {
|
||||||
s->match_length--; /* string at strstart already in hash table */
|
s->match_length--; /* string at strstart already in hash table */
|
||||||
@@ -1124,7 +1198,9 @@ local block_state deflate_fast(s, flush)
|
|||||||
*/
|
*/
|
||||||
} while (--s->match_length != 0);
|
} while (--s->match_length != 0);
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
s->strstart += s->match_length;
|
s->strstart += s->match_length;
|
||||||
s->match_length = 0;
|
s->match_length = 0;
|
||||||
s->ins_h = s->window[s->strstart];
|
s->ins_h = s->window[s->strstart];
|
||||||
@@ -1139,7 +1215,7 @@ local block_state deflate_fast(s, flush)
|
|||||||
} else {
|
} else {
|
||||||
/* No match, output a literal byte */
|
/* No match, output a literal byte */
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||||
bflush = _tr_tally (s, 0, s->window[s->strstart]);
|
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
||||||
s->lookahead--;
|
s->lookahead--;
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
}
|
}
|
||||||
@@ -1218,8 +1294,8 @@ local block_state deflate_slow(s, flush)
|
|||||||
|
|
||||||
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
|
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
|
||||||
|
|
||||||
bflush = _tr_tally(s, s->strstart -1 - s->prev_match,
|
_tr_tally_dist(s, s->strstart -1 - s->prev_match,
|
||||||
s->prev_length - MIN_MATCH);
|
s->prev_length - MIN_MATCH, bflush);
|
||||||
|
|
||||||
/* Insert in hash table all strings up to the end of the match.
|
/* Insert in hash table all strings up to the end of the match.
|
||||||
* strstart-1 and strstart are already inserted. If there is not
|
* strstart-1 and strstart are already inserted. If there is not
|
||||||
@@ -1245,7 +1321,8 @@ local block_state deflate_slow(s, flush)
|
|||||||
* is longer, truncate the previous match to a single literal.
|
* is longer, truncate the previous match to a single literal.
|
||||||
*/
|
*/
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
||||||
if (_tr_tally (s, 0, s->window[s->strstart-1])) {
|
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
||||||
|
if (bflush) {
|
||||||
FLUSH_BLOCK_ONLY(s, 0);
|
FLUSH_BLOCK_ONLY(s, 0);
|
||||||
}
|
}
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
@@ -1263,7 +1340,7 @@ local block_state deflate_slow(s, flush)
|
|||||||
Assert (flush != Z_NO_FLUSH, "no flush?");
|
Assert (flush != Z_NO_FLUSH, "no flush?");
|
||||||
if (s->match_available) {
|
if (s->match_available) {
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
||||||
_tr_tally (s, 0, s->window[s->strstart-1]);
|
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
||||||
s->match_available = 0;
|
s->match_available = 0;
|
||||||
}
|
}
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
FLUSH_BLOCK(s, flush == Z_FINISH);
|
||||||
|
|||||||
42
deflate.h
42
deflate.h
@@ -273,4 +273,46 @@ ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
|||||||
void _tr_align OF((deflate_state *s));
|
void _tr_align OF((deflate_state *s));
|
||||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||||
int eof));
|
int eof));
|
||||||
|
|
||||||
|
#define d_code(dist) \
|
||||||
|
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||||
|
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||||
|
* must not have side effects. _dist_code[256] and _dist_code[257] are never
|
||||||
|
* used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
/* Inline versions of _tr_tally for speed: */
|
||||||
|
|
||||||
|
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||||
|
extern uch _length_code[];
|
||||||
|
extern uch _dist_code[];
|
||||||
|
#else
|
||||||
|
extern const uch _length_code[];
|
||||||
|
extern const uch _dist_code[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
|
{ uch cc = (c); \
|
||||||
|
s->d_buf[s->last_lit] = 0; \
|
||||||
|
s->l_buf[s->last_lit++] = cc; \
|
||||||
|
s->dyn_ltree[cc].Freq++; \
|
||||||
|
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||||
|
}
|
||||||
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
|
{ uch len = (length); \
|
||||||
|
ush dist = (distance); \
|
||||||
|
s->d_buf[s->last_lit] = dist; \
|
||||||
|
s->l_buf[s->last_lit++] = len; \
|
||||||
|
dist--; \
|
||||||
|
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||||
|
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||||
|
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||||
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
|
flush = _tr_tally(s, distance, length)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
7
gzio.c
7
gzio.c
@@ -13,7 +13,8 @@
|
|||||||
|
|
||||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||||
|
|
||||||
#define Z_BUFSIZE 4096
|
#define Z_BUFSIZE 16384
|
||||||
|
#define Z_PRINTF_BUFSIZE 4096
|
||||||
|
|
||||||
#define ALLOC(size) malloc(size)
|
#define ALLOC(size) malloc(size)
|
||||||
#define TRYFREE(p) {if (p) free(p);}
|
#define TRYFREE(p) {if (p) free(p);}
|
||||||
@@ -506,7 +507,7 @@ int ZEXPORT gzwrite (file, buf, len)
|
|||||||
|
|
||||||
int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
|
int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
|
||||||
{
|
{
|
||||||
char buf[Z_BUFSIZE];
|
char buf[Z_PRINTF_BUFSIZE];
|
||||||
va_list va;
|
va_list va;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@@ -531,7 +532,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
|||||||
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
||||||
{
|
{
|
||||||
char buf[Z_BUFSIZE];
|
char buf[Z_PRINTF_BUFSIZE];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
#ifdef HAS_snprintf
|
#ifdef HAS_snprintf
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ int f;
|
|||||||
r = f;
|
r = f;
|
||||||
if (r != Z_STREAM_END)
|
if (r != Z_STREAM_END)
|
||||||
return r;
|
return r;
|
||||||
|
r = f;
|
||||||
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
|
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
|
||||||
if (z->state->nowrap)
|
if (z->state->nowrap)
|
||||||
{
|
{
|
||||||
@@ -322,7 +323,8 @@ z_streamp z;
|
|||||||
/* search */
|
/* search */
|
||||||
while (n && m < 4)
|
while (n && m < 4)
|
||||||
{
|
{
|
||||||
if (*p == (Byte)(m < 2 ? 0 : (Byte)0xff))
|
static const Byte mark[4] = {0, 0, 0xff, 0xff};
|
||||||
|
if (*p == mark[m])
|
||||||
m++;
|
m++;
|
||||||
else if (*p)
|
else if (*p)
|
||||||
m = 0;
|
m = 0;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "inftrees.h"
|
#include "inftrees.h"
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.0.9 Copyright 1995-1998 Mark Adler ";
|
" inflate 1.1.1 Copyright 1995-1998 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
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
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
|||||||
66
minigzip.c
66
minigzip.c
@@ -25,6 +25,11 @@
|
|||||||
extern void exit OF((int));
|
extern void exit OF((int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/mman.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32)
|
#if defined(MSDOS) || defined(OS2) || defined(WIN32)
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
@@ -53,7 +58,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
|
#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
|
||||||
|
|
||||||
#define BUFLEN 4096
|
#define BUFLEN 16384
|
||||||
#define MAX_NAME_LEN 1024
|
#define MAX_NAME_LEN 1024
|
||||||
|
|
||||||
#ifdef MAXSEG_64K
|
#ifdef MAXSEG_64K
|
||||||
@@ -65,12 +70,15 @@
|
|||||||
|
|
||||||
char *prog;
|
char *prog;
|
||||||
|
|
||||||
void error OF((const char *msg));
|
void error OF((const char *msg));
|
||||||
void gz_compress OF((FILE *in, gzFile out));
|
void gz_compress OF((FILE *in, gzFile out));
|
||||||
void gz_uncompress OF((gzFile in, FILE *out));
|
#ifdef USE_MMAP
|
||||||
void file_compress OF((char *file, char *mode));
|
int gz_compress_mmap OF((FILE *in, gzFile out));
|
||||||
void file_uncompress OF((char *file));
|
#endif
|
||||||
int main OF((int argc, char *argv[]));
|
void gz_uncompress OF((gzFile in, FILE *out));
|
||||||
|
void file_compress OF((char *file, char *mode));
|
||||||
|
void file_uncompress OF((char *file));
|
||||||
|
int main OF((int argc, char *argv[]));
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Display error message and exit
|
* Display error message and exit
|
||||||
@@ -85,6 +93,7 @@ void error(msg)
|
|||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Compress input to output then close both files.
|
* Compress input to output then close both files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void gz_compress(in, out)
|
void gz_compress(in, out)
|
||||||
FILE *in;
|
FILE *in;
|
||||||
gzFile out;
|
gzFile out;
|
||||||
@@ -93,6 +102,12 @@ void gz_compress(in, out)
|
|||||||
int len;
|
int len;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
/* Try first compressing with mmap. If mmap fails (minigzip used in a
|
||||||
|
* pipe), use the normal fread loop.
|
||||||
|
*/
|
||||||
|
if (gz_compress_mmap(in, out) == Z_OK) return;
|
||||||
|
#endif
|
||||||
for (;;) {
|
for (;;) {
|
||||||
len = fread(buf, 1, sizeof(buf), in);
|
len = fread(buf, 1, sizeof(buf), in);
|
||||||
if (ferror(in)) {
|
if (ferror(in)) {
|
||||||
@@ -107,6 +122,43 @@ void gz_compress(in, out)
|
|||||||
if (gzclose(out) != Z_OK) error("failed gzclose");
|
if (gzclose(out) != Z_OK) error("failed gzclose");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
|
||||||
|
|
||||||
|
/* Try compressing the input file at once using mmap. Return Z_OK if
|
||||||
|
* if success, Z_ERRNO otherwise.
|
||||||
|
*/
|
||||||
|
int gz_compress_mmap(in, out)
|
||||||
|
FILE *in;
|
||||||
|
gzFile out;
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
int err;
|
||||||
|
int ifd = fileno(in);
|
||||||
|
caddr_t buf; /* mmap'ed buffer for the entire input file */
|
||||||
|
off_t buf_len; /* length of the input file */
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
/* Determine the size of the file, needed for mmap: */
|
||||||
|
if (fstat(ifd, &sb) < 0) return Z_ERRNO;
|
||||||
|
buf_len = sb.st_size;
|
||||||
|
if (buf_len <= 0) return Z_ERRNO;
|
||||||
|
|
||||||
|
/* Now do the actual mmap: */
|
||||||
|
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
|
||||||
|
if (buf == (caddr_t)(-1)) return Z_ERRNO;
|
||||||
|
|
||||||
|
/* Compress the whole file at once: */
|
||||||
|
len = gzwrite(out, (char *)buf, (unsigned)buf_len);
|
||||||
|
|
||||||
|
if (len != (int)buf_len) error(gzerror(out, &err));
|
||||||
|
|
||||||
|
munmap(buf, buf_len);
|
||||||
|
fclose(in);
|
||||||
|
if (gzclose(out) != Z_OK) error("failed gzclose");
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
#endif /* USE_MMAP */
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Uncompress input to output then close both files.
|
* Uncompress input to output then close both files.
|
||||||
*/
|
*/
|
||||||
|
|||||||
97
msdos/Makefile.w32
Normal file
97
msdos/Makefile.w32
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
# Makefile for zlib
|
||||||
|
# Microsoft 32-bit Visual C++ 4.0 or later (may work on earlier versions)
|
||||||
|
|
||||||
|
# To use, do "nmake /f makefile.w32"
|
||||||
|
|
||||||
|
# If you wish to reduce the memory requirements (default 256K for big
|
||||||
|
# objects plus a few K), you can add to CFLAGS below:
|
||||||
|
# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
|
||||||
|
# See zconf.h for details about the memory requirements.
|
||||||
|
|
||||||
|
# ------------- Microsoft Visual C++ 4.0 and later -------------
|
||||||
|
MODEL=
|
||||||
|
CFLAGS=-Ox -GA3s -nologo -W3
|
||||||
|
CC=cl
|
||||||
|
LD=link
|
||||||
|
LDFLAGS=
|
||||||
|
O=.obj
|
||||||
|
|
||||||
|
# variables
|
||||||
|
OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \
|
||||||
|
trees$(O)
|
||||||
|
OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\
|
||||||
|
trees$(O)
|
||||||
|
OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \
|
||||||
|
infutil$(O) inffast$(O)
|
||||||
|
OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
|
||||||
|
infutil$(O)+inffast$(O)
|
||||||
|
|
||||||
|
all: zlib.lib example.exe minigzip.exe
|
||||||
|
|
||||||
|
adler32.obj: adler32.c zutil.h zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
compress.obj: compress.c zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
crc32.obj: crc32.c zutil.h zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
gzio.obj: gzio.c zutil.h zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\
|
||||||
|
infcodes.h infutil.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\
|
||||||
|
infcodes.h inffast.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
uncompr.obj: uncompr.c zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
zutil.obj: zutil.c zutil.h zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
example.obj: example.c zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
minigzip.obj: minigzip.c zlib.h zconf.h
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
zlib.lib: $(OBJ1) $(OBJ2)
|
||||||
|
if exist zlib.lib del zlib.lib
|
||||||
|
lib /OUT:zlib.lib $(OBJ1) $(OBJ2)
|
||||||
|
|
||||||
|
example.exe: example.obj zlib.lib
|
||||||
|
$(LD) $(LDFLAGS) example.obj zlib.lib /OUT:example.exe /SUBSYSTEM:CONSOLE
|
||||||
|
|
||||||
|
minigzip.exe: minigzip.obj zlib.lib
|
||||||
|
$(LD) $(LDFLAGS) minigzip.obj zlib.lib /OUT:minigzip.exe /SUBSYSTEM:CONSOLE
|
||||||
|
|
||||||
|
test: example.exe minigzip.exe
|
||||||
|
example
|
||||||
|
echo hello world | minigzip | minigzip -d
|
||||||
|
|
||||||
|
#clean:
|
||||||
|
# del *.obj
|
||||||
|
# del *.exe
|
||||||
@@ -8,7 +8,7 @@ SUBSYSTEM WINDOWS
|
|||||||
|
|
||||||
STUB 'WINSTUB.EXE'
|
STUB 'WINSTUB.EXE'
|
||||||
|
|
||||||
VERSION 1.09
|
VERSION 1.11
|
||||||
|
|
||||||
CODE EXECUTE READ
|
CODE EXECUTE READ
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1,0,9,0
|
FILEVERSION 1,1,1,0
|
||||||
PRODUCTVERSION 1,0,9,0
|
PRODUCTVERSION 1,1,1,0
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
@@ -17,7 +17,7 @@ BEGIN
|
|||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression library\0"
|
VALUE "FileDescription", "zlib data compression library\0"
|
||||||
VALUE "FileVersion", "1.0.9\0"
|
VALUE "FileVersion", "1.1.1\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlib.dll\0"
|
VALUE "OriginalFilename", "zlib.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
|
|||||||
35
trees.c
35
trees.c
@@ -99,13 +99,13 @@ local ct_data static_dtree[D_CODES];
|
|||||||
* 5 bits.)
|
* 5 bits.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
local uch dist_code[DIST_CODE_LEN];
|
uch _dist_code[DIST_CODE_LEN];
|
||||||
/* Distance codes. The first 256 values correspond to the distances
|
/* Distance codes. The first 256 values correspond to the distances
|
||||||
* 3 .. 258, the last 256 values correspond to the top 8 bits of
|
* 3 .. 258, the last 256 values correspond to the top 8 bits of
|
||||||
* the 15 bit distances.
|
* the 15 bit distances.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
local uch length_code[MAX_MATCH-MIN_MATCH+1];
|
uch _length_code[MAX_MATCH-MIN_MATCH+1];
|
||||||
/* length code for each normalized match length (0 == MIN_MATCH) */
|
/* length code for each normalized match length (0 == MIN_MATCH) */
|
||||||
|
|
||||||
local int base_length[LENGTH_CODES];
|
local int base_length[LENGTH_CODES];
|
||||||
@@ -173,13 +173,6 @@ local void gen_trees_header OF((void));
|
|||||||
send_bits(s, tree[c].Code, tree[c].Len); }
|
send_bits(s, tree[c].Code, tree[c].Len); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define d_code(dist) \
|
|
||||||
((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
|
|
||||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
|
||||||
* must not have side effects. dist_code[256] and dist_code[257] are never
|
|
||||||
* used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Output a short LSB first on the stream.
|
* Output a short LSB first on the stream.
|
||||||
* IN assertion: there is enough room in pendingBuf.
|
* IN assertion: there is enough room in pendingBuf.
|
||||||
@@ -262,7 +255,7 @@ local void tr_static_init()
|
|||||||
for (code = 0; code < LENGTH_CODES-1; code++) {
|
for (code = 0; code < LENGTH_CODES-1; code++) {
|
||||||
base_length[code] = length;
|
base_length[code] = length;
|
||||||
for (n = 0; n < (1<<extra_lbits[code]); n++) {
|
for (n = 0; n < (1<<extra_lbits[code]); n++) {
|
||||||
length_code[length++] = (uch)code;
|
_length_code[length++] = (uch)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert (length == 256, "tr_static_init: length != 256");
|
Assert (length == 256, "tr_static_init: length != 256");
|
||||||
@@ -270,14 +263,14 @@ local void tr_static_init()
|
|||||||
* in two different ways: code 284 + 5 bits or code 285, so we
|
* in two different ways: code 284 + 5 bits or code 285, so we
|
||||||
* overwrite length_code[255] to use the best encoding:
|
* overwrite length_code[255] to use the best encoding:
|
||||||
*/
|
*/
|
||||||
length_code[length-1] = (uch)code;
|
_length_code[length-1] = (uch)code;
|
||||||
|
|
||||||
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
||||||
dist = 0;
|
dist = 0;
|
||||||
for (code = 0 ; code < 16; code++) {
|
for (code = 0 ; code < 16; code++) {
|
||||||
base_dist[code] = dist;
|
base_dist[code] = dist;
|
||||||
for (n = 0; n < (1<<extra_dbits[code]); n++) {
|
for (n = 0; n < (1<<extra_dbits[code]); n++) {
|
||||||
dist_code[dist++] = (uch)code;
|
_dist_code[dist++] = (uch)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert (dist == 256, "tr_static_init: dist != 256");
|
Assert (dist == 256, "tr_static_init: dist != 256");
|
||||||
@@ -285,7 +278,7 @@ local void tr_static_init()
|
|||||||
for ( ; code < D_CODES; code++) {
|
for ( ; code < D_CODES; code++) {
|
||||||
base_dist[code] = dist << 7;
|
base_dist[code] = dist << 7;
|
||||||
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
|
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
|
||||||
dist_code[256 + dist++] = (uch)code;
|
_dist_code[256 + dist++] = (uch)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert (dist == 256, "tr_static_init: 256+dist != 512");
|
Assert (dist == 256, "tr_static_init: 256+dist != 512");
|
||||||
@@ -349,15 +342,15 @@ void gen_trees_header()
|
|||||||
static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
|
static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(header, "local const uch dist_code[DIST_CODE_LEN] = {\n");
|
fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
|
||||||
for (i = 0; i < DIST_CODE_LEN; i++) {
|
for (i = 0; i < DIST_CODE_LEN; i++) {
|
||||||
fprintf(header, "%2u%s", dist_code[i],
|
fprintf(header, "%2u%s", _dist_code[i],
|
||||||
SEPARATOR(i, DIST_CODE_LEN-1, 20));
|
SEPARATOR(i, DIST_CODE_LEN-1, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(header, "local const uch length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
|
fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
|
||||||
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
|
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
|
||||||
fprintf(header, "%2u%s", length_code[i],
|
fprintf(header, "%2u%s", _length_code[i],
|
||||||
SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
|
SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1045,12 +1038,13 @@ int _tr_tally (s, dist, lc)
|
|||||||
(ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
|
(ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
|
||||||
(ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
|
(ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
|
||||||
|
|
||||||
s->dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
|
s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
|
||||||
s->dyn_dtree[d_code(dist)].Freq++;
|
s->dyn_dtree[d_code(dist)].Freq++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TRUNCATE_BLOCK
|
||||||
/* Try to guess if it is profitable to stop the current block here */
|
/* Try to guess if it is profitable to stop the current block here */
|
||||||
if (s->level > 2 && (s->last_lit & 0xfff) == 0) {
|
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
|
||||||
/* Compute an upper bound for the compressed length */
|
/* Compute an upper bound for the compressed length */
|
||||||
ulg out_length = (ulg)s->last_lit*8L;
|
ulg out_length = (ulg)s->last_lit*8L;
|
||||||
ulg in_length = (ulg)((long)s->strstart - s->block_start);
|
ulg in_length = (ulg)((long)s->strstart - s->block_start);
|
||||||
@@ -1065,6 +1059,7 @@ int _tr_tally (s, dist, lc)
|
|||||||
100L - out_length*100L/in_length));
|
100L - out_length*100L/in_length));
|
||||||
if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
|
if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return (s->last_lit == s->lit_bufsize-1);
|
return (s->last_lit == s->lit_bufsize-1);
|
||||||
/* We avoid equality with lit_bufsize because of wraparound at 64K
|
/* We avoid equality with lit_bufsize because of wraparound at 64K
|
||||||
* on 16 bit machines and because stored blocks are restricted to
|
* on 16 bit machines and because stored blocks are restricted to
|
||||||
@@ -1094,7 +1089,7 @@ local void compress_block(s, ltree, dtree)
|
|||||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||||
} else {
|
} else {
|
||||||
/* Here, lc is the match length - MIN_MATCH */
|
/* Here, lc is the match length - MIN_MATCH */
|
||||||
code = length_code[lc];
|
code = _length_code[lc];
|
||||||
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
||||||
extra = extra_lbits[code];
|
extra = extra_lbits[code];
|
||||||
if (extra != 0) {
|
if (extra != 0) {
|
||||||
|
|||||||
4
trees.h
4
trees.h
@@ -70,7 +70,7 @@ local const ct_data static_dtree[D_CODES] = {
|
|||||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||||
};
|
};
|
||||||
|
|
||||||
local const uch dist_code[DIST_CODE_LEN] = {
|
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,
|
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,
|
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,
|
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||||
@@ -99,7 +99,7 @@ local const uch dist_code[DIST_CODE_LEN] = {
|
|||||||
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]= {
|
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,
|
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,
|
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,
|
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||||
|
|||||||
4
zlib.3
4
zlib.3
@@ -1,4 +1,4 @@
|
|||||||
.TH ZLIB 3 "16 February 1998"
|
.TH ZLIB 3 "27 February 1998"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
zlib \- compression/decompression library
|
zlib \- compression/decompression library
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -81,7 +81,7 @@ These documents are also available in other formats from:
|
|||||||
.IP
|
.IP
|
||||||
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
Version 1.0.9.
|
Version 1.1.1
|
||||||
Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org)
|
Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org)
|
||||||
and Mark Adler (madler@alumni.caltech.edu).
|
and Mark Adler (madler@alumni.caltech.edu).
|
||||||
.LP
|
.LP
|
||||||
|
|||||||
4
zlib.h
4
zlib.h
@@ -1,5 +1,5 @@
|
|||||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
version 1.0.9, Feb 16th, 1998
|
version 1.1.1, Feb 27th, 1998
|
||||||
|
|
||||||
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "zconf.h"
|
#include "zconf.h"
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.0.9"
|
#define ZLIB_VERSION "1.1.1"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The 'zlib' compression library provides in-memory compression and
|
The 'zlib' compression library provides in-memory compression and
|
||||||
|
|||||||
Reference in New Issue
Block a user