X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..cc402e6431b66a8eb7d567caa55a1bece42902b7:/src/zlib/infcodes.c diff --git a/src/zlib/infcodes.c b/src/zlib/infcodes.c index 1d3baa92eb..04788d51a9 100644 --- a/src/zlib/infcodes.c +++ b/src/zlib/infcodes.c @@ -1,6 +1,6 @@ /* infcodes.c -- process literals and length/distance pairs - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" @@ -55,12 +55,15 @@ struct inflate_codes_state { }; - +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +inflate_codes_statef* inflate_codes_new(uInt bl, uInt bd, inflate_huft* tl, inflate_huft* td, z_streamp z) +#else inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) uInt bl, bd; inflate_huft *tl; inflate_huft *td; /* need separate declaration for Borland C++ */ z_streamp z; +#endif { inflate_codes_statef *c; @@ -77,11 +80,14 @@ z_streamp z; return c; } - +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int inflate_codes(inflate_blocks_statef* s, z_streamp z, int r) +#else int inflate_codes(s, z, r) inflate_blocks_statef *s; z_streamp z; int r; +#endif { uInt j; /* temporary storage */ inflate_huft *t; /* temporary pointer */ @@ -196,15 +202,9 @@ int r; Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); c->mode = COPY; case COPY: /* o: copying bytes in window, waiting for space */ -#ifndef __TURBOC__ /* Turbo C bug for following expression */ - f = (uInt)(q - s->window) < c->sub.copy.dist ? - s->end - (c->sub.copy.dist - (q - s->window)) : - q - c->sub.copy.dist; -#else f = q - c->sub.copy.dist; - if ((uInt)(q - s->window) < c->sub.copy.dist) - f = s->end - (c->sub.copy.dist - (uInt)(q - s->window)); -#endif + while (f < s->window) /* modulo window size-"while" instead */ + f += s->end - s->window; /* of "if" handles invalid distances */ while (c->len) { NEEDOUT @@ -221,6 +221,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 @@ -240,10 +247,13 @@ int r; #endif } - +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +void inflate_codes_free(inflate_codes_statef* c, z_streamp z) +#else void inflate_codes_free(c, z) inflate_codes_statef *c; z_streamp z; +#endif { ZFREE(z, c); Tracev((stderr, "inflate: codes free\n"));