Sync with files in "src/lib/libz".

This commit is contained in:
tron 1998-11-03 15:49:39 +00:00
parent e091e64548
commit 873f0be1cd
3 changed files with 26 additions and 16 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: infcodes.c,v 1.2 1997/05/20 14:41:57 gwr Exp $ */
/* $NetBSD: infcodes.c,v 1.3 1998/11/03 15:49:39 tron Exp $ */
/* infcodes.c -- process literals and length/distance pairs
* Copyright (C) 1995-1996 Mark Adler
* Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@ -13,16 +13,10 @@
#include "inffast.h"
/* simplify the use of the inflate_huft type with some defines */
#define base more.Base
#define next more.Next
#define exop word.what.Exop
#define bits word.what.Bits
/* inflate codes private state */
struct inflate_codes_state {
/* mode */
enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
START, /* x: set up for LEN */
LEN, /* i: get length/literal/eob next */
LENEXT, /* i: getting length extra (have base) */
@ -33,7 +27,13 @@ struct inflate_codes_state {
WASH, /* o: got eob, possibly still output waiting */
END, /* x: got eob and all data flushed */
BADCODE} /* x: got error */
mode; /* current inflate_codes mode */
inflate_codes_mode;
/* inflate codes private state */
struct inflate_codes_state {
/* mode */
inflate_codes_mode mode; /* current inflate_codes mode */
/* mode dependent information */
uInt len;
@ -145,7 +145,7 @@ int r;
if ((e & 64) == 0) /* next table */
{
c->sub.code.need = e;
c->sub.code.tree = t->next;
c->sub.code.tree = t + t->base;
break;
}
if (e & 32) /* end of block */
@ -183,7 +183,7 @@ int r;
if ((e & 64) == 0) /* next table */
{
c->sub.code.need = e;
c->sub.code.tree = t->next;
c->sub.code.tree = t + t->base;
break;
}
c->mode = BADCODE; /* invalid code */
@ -223,6 +223,13 @@ int r;
c->mode = START;
break;
case WASH: /* o: got eob, possibly more output */
if (k > 7) /* return unused byte, if any */
{
Assert(k < 16, "inflate_codes grabbed too many bytes")
k -= 8;
n++;
p--; /* can always return one */
}
FLUSH
if (s->read != s->write)
LEAVE
@ -237,6 +244,9 @@ int r;
r = Z_STREAM_ERROR;
LEAVE
}
#ifdef NEED_DUMMY_RETURN
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
#endif
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: infcodes.h,v 1.2 1997/05/20 14:41:58 gwr Exp $ */
/* $NetBSD: infcodes.h,v 1.3 1998/11/03 15:49:39 tron Exp $ */
/* infcodes.h -- header to use infcodes.c
* Copyright (C) 1995-1996 Mark Adler
* Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,7 +1,7 @@
/* $NetBSD: inffast.h,v 1.2 1997/05/20 14:42:00 gwr Exp $ */
/* $NetBSD: inffast.h,v 1.3 1998/11/03 15:49:39 tron Exp $ */
/* inffast.h -- header to use inffast.c
* Copyright (C) 1995-1996 Mark Adler
* Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/