summaryrefslogtreecommitdiff
path: root/infcodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'infcodes.c')
-rw-r--r--infcodes.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/infcodes.c b/infcodes.c
index 4305290..22ce856 100644
--- a/infcodes.c
+++ b/infcodes.c
@@ -5,9 +5,10 @@
5 5
6#include "zutil.h" 6#include "zutil.h"
7#include "inftrees.h" 7#include "inftrees.h"
8#include "infblock.h"
9#include "infcodes.h"
8#include "infutil.h" 10#include "infutil.h"
9#include "inffast.h" 11#include "inffast.h"
10#include "infcodes.h"
11 12
12/* simplify the use of the inflate_huft type with some defines */ 13/* simplify the use of the inflate_huft type with some defines */
13#define base more.Base 14#define base more.Base
@@ -55,14 +56,14 @@ struct inflate_codes_state {
55}; 56};
56 57
57 58
58struct inflate_codes_state *inflate_codes_new(bl, bd, tl, td, z) 59inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
59uInt bl, bd; 60uInt bl, bd;
60inflate_huft *tl, *td; 61inflate_huft *tl, *td;
61z_stream *z; 62z_stream *z;
62{ 63{
63 struct inflate_codes_state *c; 64 inflate_codes_statef *c;
64 65
65 if ((c = (struct inflate_codes_state *) 66 if ((c = (inflate_codes_statef *)
66 ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) 67 ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
67 { 68 {
68 c->mode = START; 69 c->mode = START;
@@ -77,7 +78,7 @@ z_stream *z;
77 78
78 79
79int inflate_codes(s, z, r) 80int inflate_codes(s, z, r)
80struct inflate_blocks_state *s; 81inflate_blocks_statef *s;
81z_stream *z; 82z_stream *z;
82int r; 83int r;
83{ 84{
@@ -86,12 +87,12 @@ int r;
86 uInt e; /* extra bits or operation */ 87 uInt e; /* extra bits or operation */
87 uLong b; /* bit buffer */ 88 uLong b; /* bit buffer */
88 uInt k; /* bits in bit buffer */ 89 uInt k; /* bits in bit buffer */
89 Byte *p; /* input data pointer */ 90 Bytef *p; /* input data pointer */
90 uInt n; /* bytes available there */ 91 uInt n; /* bytes available there */
91 Byte *q; /* output window write pointer */ 92 Bytef *q; /* output window write pointer */
92 uInt m; /* bytes to end of window or read pointer */ 93 uInt m; /* bytes to end of window or read pointer */
93 Byte *f; /* pointer to copy strings from */ 94 Bytef *f; /* pointer to copy strings from */
94 struct inflate_codes_state *c = s->sub.decode.codes; /* codes state */ 95 inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
95 96
96 /* copy input/output information to locals (UPDATE macro restores) */ 97 /* copy input/output information to locals (UPDATE macro restores) */
97 LOAD 98 LOAD
@@ -194,9 +195,15 @@ int r;
194 Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); 195 Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
195 c->mode = COPY; 196 c->mode = COPY;
196 case COPY: /* o: copying bytes in window, waiting for space */ 197 case COPY: /* o: copying bytes in window, waiting for space */
198#ifndef __TURBOC__ /* Turbo C bug for following expression */
197 f = (uInt)(q - s->window) < c->sub.copy.dist ? 199 f = (uInt)(q - s->window) < c->sub.copy.dist ?
198 s->end - (c->sub.copy.dist - (q - s->window)) : 200 s->end - (c->sub.copy.dist - (q - s->window)) :
199 q - c->sub.copy.dist; 201 q - c->sub.copy.dist;
202#else
203 f = q - c->sub.copy.dist;
204 if ((uInt)(q - s->window) < c->sub.copy.dist)
205 f = s->end - (c->sub.copy.dist - (q - s->window));
206#endif
200 while (c->len) 207 while (c->len)
201 { 208 {
202 NEEDOUT 209 NEEDOUT
@@ -231,7 +238,7 @@ int r;
231 238
232 239
233void inflate_codes_free(c, z) 240void inflate_codes_free(c, z)
234struct inflate_codes_state *c; 241inflate_codes_statef *c;
235z_stream *z; 242z_stream *z;
236{ 243{
237 ZFREE(z, c); 244 ZFREE(z, c);