pull/2/head v0.92
Mark Adler 13 years ago
parent 1c71d8b13b
commit bdde4e09d2
  1. 9
      ChangeLog
  2. 11
      Makefile
  3. 9
      README
  4. 2
      adler32.c
  5. 2
      compress.c
  6. 51
      deflate.c
  7. 2
      deflate.h
  8. 2
      example.c
  9. 2
      gzio.c
  10. 16
      infblock.c
  11. 69
      inftest.c
  12. 12
      inftrees.c
  13. 10
      inftrees.h
  14. 2
      minigzip.c
  15. 2
      trees.c
  16. 2
      uncompr.c
  17. 2
      zconf.h
  18. 4
      zlib.h
  19. 2
      zutil.c
  20. 13
      zutil.h

@ -1,5 +1,14 @@
ChangeLog file for zlib
Changes in 0.92 (3 May 95)
- don't assume that char is signed (problem on SGI)
- Clear bit buffer when starting a stored block
- no memcpy on Pyramid
- suppressed inftest.c
- optimized fill_window, put longest_match inline for gcc
- optimized inflate on stored blocks.
- untabify all sources to simplify patches
Changes in 0.91 (2 May 95)
- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
- Document the memory requirements in zconf.h

@ -4,6 +4,7 @@
CC=cc
CFLAGS=-O
#use -O3 for gcc to take advantage of inlining
#CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
#CFLAGS=-g -DDEBUG
LDFLAGS=-L. -lgz
@ -15,9 +16,9 @@ prefix=/usr/local
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
TEST_OBJS = example.o minigzip.o inftest.o
TEST_OBJS = example.o minigzip.o
all: example minigzip inftest
all: example minigzip
test: all
./example
@ -41,11 +42,8 @@ example: example.o libgz.a
minigzip: minigzip.o libgz.a
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
inftest: inftest.o libgz.a
$(CC) $(CFLAGS) -o $@ inftest.o $(LDFLAGS)
clean:
rm -f *.o example minigzip inftest libgz.a foo.gz
rm -f *.o example minigzip libgz.a foo.gz
zip:
zip -ul9 zlib README ChangeLog Makefile Makefile.??? Makefile.?? *.[ch]
@ -66,7 +64,6 @@ infblock.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
infcodes.o: zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h
inflate.o: zutil.h zlib.h zconf.h infblock.h
inftest.o: zutil.h zlib.h zconf.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
infutil.o: zutil.h zlib.h zconf.h inftrees.h infutil.h
minigzip.o: zlib.h zconf.h

@ -1,4 +1,4 @@
zlib 0.91 is a beta version of a general purpose compression library.
zlib 0.92 is a beta version of a general purpose compression library.
The data format used by the zlib library is described in the
files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
@ -14,12 +14,15 @@ To install the zlib library (libgz.a) in /usr/local/lib, type: make install
To install in a different directory, use for example: make install prefix=$HOME
This will install in $HOME/lib instead of /usr/local/lib.
The changes made in version 0.91 are documented in the file ChangeLog.
The changes made in version 0.92 are documented in the file ChangeLog.
The main changes since 0.9 are:
- don't assume that char is signed (problem on SGI)
- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
- Document the memory requirements in zconf.h
- added "make install"
- added support for DJGPP
- added support for DJGPP and Pyramid
- fix an inflate bug for stored blocks.
- various speedups
On MSDOS, this version works in both large and small model. However
small model compression works only for small values of MAX_MEM_LEVEL

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: adler32.c,v 1.5 1995/04/14 14:49:51 jloup Exp $ */
/* $Id: adler32.c,v 1.6 1995/05/03 17:27:08 jloup Exp $ */
#include "zutil.h"

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: compress.c,v 1.5 1995/04/29 17:18:43 jloup Exp $ */
/* $Id: compress.c,v 1.6 1995/05/03 17:27:08 jloup Exp $ */
#include "zlib.h"

@ -47,7 +47,7 @@
*
*/
/* $Id: deflate.c,v 1.7 1995/05/02 13:28:18 jloup Exp $ */
/* $Id: deflate.c,v 1.8 1995/05/03 17:27:08 jloup Exp $ */
#include "deflate.h"
@ -488,7 +488,7 @@ local void lm_init (s)
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
* match.S. The code will be functionally equivalent.
*/
local int longest_match(s, cur_match)
local INLINE int longest_match(s, cur_match)
deflate_state *s;
IPos cur_match; /* current match */
{
@ -502,6 +502,8 @@ local int longest_match(s, cur_match)
/* Stop when cur_match becomes <= limit. To simplify the code,
* we prevent matches with the string of window index 0.
*/
Pos *prev = s->prev;
uInt wmask = s->w_mask;
#ifdef UNALIGNED_OK
/* Compare two bytes at a time. Note: this is not always beneficial.
@ -609,7 +611,7 @@ local int longest_match(s, cur_match)
scan_end = scan[best_len];
#endif
}
} while ((cur_match = s->prev[cur_match & s->w_mask]) > limit
} while ((cur_match = prev[cur_match & wmask]) > limit
&& --chain_length != 0);
return best_len;
@ -656,14 +658,16 @@ local void fill_window(s)
deflate_state *s;
{
register unsigned n, m;
register Pos *p;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
do {
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
/* Deal with !@#$% 64K limit: */
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
more = s->w_size;
more = wsize;
} else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if strstart == 0
* and lookahead == 1 (input done one byte at time)
@ -673,30 +677,39 @@ local void fill_window(s)
/* If the window is almost full and there is insufficient lookahead,
* move the upper half to the lower one to make room in the upper half.
*/
} else if (s->strstart >= s->w_size+MAX_DIST(s)) {
} else if (s->strstart >= wsize+MAX_DIST(s)) {
/* By the IN assertion, the window is not empty so we can't confuse
* more == 0 with more == 64K on a 16 bit machine.
*/
memcpy((char*)s->window, (char*)s->window+s->w_size,
(unsigned)s->w_size);
s->match_start -= s->w_size;
s->strstart -= s->w_size; /* we now have strstart >= MAX_DIST */
zmemcpy((char*)s->window, (char*)s->window+wsize,
(unsigned)wsize);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) s->w_size;
s->block_start -= (long) wsize;
for (n = 0; n < s->hash_size; n++) {
m = s->head[n];
s->head[n] = (Pos)(m >= s->w_size ? m-s->w_size : NIL);
}
for (n = 0; n < s->w_size; n++) {
m = s->prev[n];
s->prev[n] = (Pos)(m >= s->w_size ? m-s->w_size : NIL);
/* Slide the hash table (could be avoided with 32 bit values
at the expense of memory usage):
*/
n = s->hash_size;
p = &s->head[n-1];
do {
m = *p;
*p-- = (Pos)(m >= wsize ? m-wsize : NIL);
} while (--n);
n = wsize;
p = &s->prev[n-1];
do {
m = *p;
*p-- = (Pos)(m >= wsize ? m-wsize : NIL);
/* If n is not on any hash chain, prev[n] is garbage but
* its value will never be used.
*/
}
more += s->w_size;
} while (--n);
more += wsize;
}
if (s->strm->avail_in == 0) return;

@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
/* $Id: deflate.h,v 1.4 1995/05/01 15:08:45 jloup Exp $ */
/* $Id: deflate.h,v 1.5 1995/05/03 17:27:09 jloup Exp $ */
#include "zutil.h"

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: example.c,v 1.8 1995/05/02 15:52:32 jloup Exp $ */
/* $Id: example.c,v 1.9 1995/05/03 17:27:09 jloup Exp $ */
#include <stdio.h>
#include "zlib.h"

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: gzio.c,v 1.7 1995/05/02 12:22:08 jloup Exp $ */
/* $Id: gzio.c,v 1.8 1995/05/03 17:27:09 jloup Exp $ */
#include <stdio.h>

@ -180,17 +180,23 @@ int r;
r = Z_DATA_ERROR;
LEAVE
}
k = 0; /* dump bits */
s->sub.left = (uInt)b & 0xffff;
k = b = 0; /* dump bits */
Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
s->mode = s->sub.left ? STORED : TYPE;
break;
case STORED:
do {
NEEDBYTE
if (n == 0)
LEAVE
NEEDOUT
OUTBYTE(NEXTBYTE)
} while (--s->sub.left);
t = s->sub.left;
if (t > n) t = n;
if (t > m) t = m;
zmemcpy(q, p, t);
p += t; n -= t;
q += t; m -= t;
if ((s->sub.left -= t) != 0)
break;
Tracev((stderr, "inflate: stored end, %lu total out\n",
z->total_out + (q >= s->read ? q - s->read :
(s->end - s->read) + (q - s->window))));

@ -1,69 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include "zutil.h"
void main __P((void));
/* This test is in honor of Ed Hamrick who suggested that the interface
to inflate be a byte at a time--this implements that, and is, of course,
monumentally slow. It has the virtue though of stressing the push-pull
interface for testing purposes. */
void main()
{
int a, r;
char c;
z_stream z;
z.zalloc = Z_NULL;
z.zfree = Z_NULL;
r = inflateInit(&z);
if (r != Z_OK)
fprintf(stderr, "init error: %s\n", z_errmsg[1 - r]);
while ((a = getchar()) != EOF)
{
/* feed one byte of input */
z.avail_out = 0;
c = (char)a;
z.next_in = (Byte*)&c;
z.avail_in = 1;
r = inflate(&z, 0);
if (r == Z_STREAM_END)
break;
if (r != Z_OK)
{
fprintf(stderr, "inflate error: %s\n", z_errmsg[1 - r]);
break;
}
if (z.avail_in != 0)
{
fprintf(stderr, "inflate didn't eat byte and didn't say buf err!\n");
break;
}
/* empty output one byte at a time */
while (1)
{
z.next_out = (Byte*)&c;
z.avail_out = 1;
r = inflate(&z, 0);
if (r == Z_STREAM_END)
break;
if (r != Z_OK && r != Z_BUF_ERROR)
{
fprintf(stderr, "inflate error: %s\n", z_errmsg[1 - r]);
break;
}
if (z.avail_out == 0)
putchar(c);
else
break;
}
if (r != Z_OK && r != Z_BUF_ERROR)
break;
}
inflateEnd(&z);
fprintf(stderr, "%ld bytes in, %ld bytes out\n", z.total_in, z.total_out);
if (z.msg != NULL)
fprintf(stderr, "msg is <%s>\n", z.msg);
}

@ -245,8 +245,8 @@ z_stream *zs; /* for zalloc function */
if (h)
{
x[h] = i; /* save pattern for backing up */
r.bits = (char)l; /* bits to dump before this table */
r.exop = -(char)j; /* bits in this table */
r.bits = (Byte)l; /* bits to dump before this table */
r.exop = -(Char)j; /* bits in this table */
r.next = q; /* pointer to this table */
j = i >> (w - l); /* (get around Turbo C bug) */
u[h-1][j] = r; /* connect to last table */
@ -254,17 +254,17 @@ z_stream *zs; /* for zalloc function */
}
/* set up table entry in r */
r.bits = (char)(k - w);
r.bits = (Byte)(k - w);
if (p >= v + n)
r.exop = -128; /* out of values--invalid code */
r.exop = (Char)(-128); /* out of values--invalid code */
else if (*p < s)
{
r.exop = (char)(*p < 256 ? 16 : -64); /* 256 is end-of-block code */
r.exop = (Char)(*p < 256 ? 16 : -64); /* 256 is end-of-block code */
r.base = *p++; /* simple code is just the value */
}
else
{
r.exop = (char)e[*p - s]; /* non-simple--look up in lists */
r.exop = (Char)e[*p - s]; /* non-simple--look up in lists */
r.base = d[*p++ - s];
}

@ -16,12 +16,18 @@
indicates an unused code. If a code with exop == -128 is looked up,
this implies an error in the data. */
#if defined(STDC) || defined(sgi)
typedef signed char Char;
#else
typedef char Char; /* just hope that char is signed */
#endif
typedef struct inflate_huft_s inflate_huft;
struct inflate_huft_s {
union {
struct {
char Exop; /* number of extra bits or operation */
char Bits; /* number of bits in this code or subcode */
Char Exop; /* number of extra bits or operation */
Byte Bits; /* number of bits in this code or subcode */
} what;
Byte *pad; /* pad structure to a power of 2 (4 bytes for */
} word; /* 16-bit, 8 bytes for 32-bit machines) */

@ -13,7 +13,7 @@
* or in pipe mode.
*/
/* $Id: minigzip.c,v 1.4 1995/05/02 15:54:22 jloup Exp $ */
/* $Id: minigzip.c,v 1.5 1995/05/03 17:27:11 jloup Exp $ */
#include <stdio.h>
#include "zlib.h"

@ -29,7 +29,7 @@
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/
/* $Id: trees.c,v 1.4 1995/05/01 16:53:44 jloup Exp $ */
/* $Id: trees.c,v 1.5 1995/05/03 17:27:12 jloup Exp $ */
#include "deflate.h"

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: uncompr.c,v 1.4 1995/04/10 16:22:22 jloup Exp $ */
/* $Id: uncompr.c,v 1.5 1995/05/03 17:27:12 jloup Exp $ */
#include "zlib.h"

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: zconf.h,v 1.11 1995/05/02 13:07:21 jloup Exp $ */
/* $Id: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp $ */
#ifndef _ZCONF_H
#define _ZCONF_H

@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 0.91 May 2nd, 1995.
version 0.92 May 3rd, 1995.
Copyright (C) 1995 Jean-loup Gailly and Mark Adler
@ -28,7 +28,7 @@
#include "zconf.h"
#define ZLIB_VERSION "0.91"
#define ZLIB_VERSION "0.92"
/*
The 'zlib' compression library provides in-memory compression and

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: zutil.c,v 1.7 1995/05/02 15:54:47 jloup Exp $ */
/* $Id: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp $ */
#include <stdio.h>

@ -8,13 +8,19 @@
subject to change. Applications should only use zlib.h.
*/
/* $Id: zutil.h,v 1.8 1995/05/02 15:44:46 jloup Exp $ */
/* $Id: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp $ */
#ifndef _Z_UTIL_H
#define _Z_UTIL_H
#include "zlib.h"
#ifdef __GNUC__
# define INLINE inline
#else
# define INLINE
#endif
#ifdef MSDOS
# include <stddef.h>
# include <errno.h>
@ -126,7 +132,10 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
# define zstrerror(errnum) ""
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY)
#if defined(pyr) && !defined(NO_MEMCPY)
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY

Loading…
Cancel
Save