38 # define PUP(a) *(a)++
41 # define PUP(a) *++(a)
83 unsigned char FAR *in;
84 unsigned char FAR *
last;
85 unsigned char FAR *out;
86 unsigned char FAR *beg;
87 unsigned char FAR *end;
97 code const FAR *lcode;
98 code const FAR *dcode;
106 unsigned char FAR *from;
110 in = strm->next_in -
OFF;
111 last = in + (strm->avail_in - 5);
112 out = strm->next_out -
OFF;
113 beg = out - (start - strm->avail_out);
114 end = out + (strm->avail_out - 257);
115 #ifdef INFLATE_STRICT
118 wsize = state->
wsize;
119 whave = state->
whave;
120 wnext = state->
wnext;
126 lmask = (1U << state->
lenbits) - 1;
127 dmask = (1U << state->
distbits) - 1;
133 hold += (
unsigned long)(
PUP(in)) << bits;
135 hold += (
unsigned long)(
PUP(in)) << bits;
138 here = lcode[hold & lmask];
140 op = (unsigned)(here.
bits);
143 op = (unsigned)(here.
op);
146 "inflate: literal '%c'\n" :
147 "inflate: literal 0x%02x\n", here.
val));
148 PUP(out) = (
unsigned char)(here.
val);
151 len = (unsigned)(here.
val);
155 hold += (
unsigned long)(
PUP(in)) << bits;
158 len += (unsigned)hold & ((1U << op) - 1);
162 Tracevv((stderr,
"inflate: length %u\n", len));
164 hold += (
unsigned long)(
PUP(in)) << bits;
166 hold += (
unsigned long)(
PUP(in)) << bits;
169 here = dcode[hold & dmask];
171 op = (unsigned)(here.
bits);
174 op = (unsigned)(here.
op);
176 dist = (unsigned)(here.
val);
179 hold += (
unsigned long)(
PUP(in)) << bits;
182 hold += (
unsigned long)(
PUP(in)) << bits;
186 dist += (unsigned)hold & ((1U << op) - 1);
187 #ifdef INFLATE_STRICT
189 strm->msg = (
char *)
"invalid distance too far back";
196 Tracevv((stderr,
"inflate: distance %u\n", dist));
197 op = (unsigned)(out - beg);
203 (
char *)
"invalid distance too far back";
207 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
208 if (len <= op - whave) {
217 }
while (--op > whave);
238 else if (wnext < op) {
239 from += wsize + wnext - op;
294 else if ((op & 64) == 0) {
295 here = dcode[here.
val + (hold & ((1U << op) - 1))];
299 strm->msg = (
char *)
"invalid distance code";
304 else if ((op & 64) == 0) {
305 here = lcode[here.
val + (hold & ((1U << op) - 1))];
309 Tracevv((stderr,
"inflate: end of block\n"));
314 strm->msg = (
char *)
"invalid literal/length code";
318 }
while (in < last && out < end);
324 hold &= (1U <<
bits) - 1;
327 strm->next_in = in +
OFF;
328 strm->next_out = out +
OFF;
329 strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in -
last));
330 strm->avail_out = (unsigned)(out < end ?
331 257 + (end - out) : 257 - (out - end));