26 # define PUP(a) *(a)++
29 # define PUP(a) *++(a)
67 void inflate_fast(strm, start)
72 unsigned char FAR *in;
73 unsigned char FAR *last;
74 unsigned char FAR *out;
75 unsigned char FAR *beg;
76 unsigned char FAR *end;
83 unsigned char FAR *window;
86 code const FAR *lcode;
87 code const FAR *dcode;
95 unsigned char FAR *from;
99 in = strm->next_in - OFF;
100 last = in + (strm->avail_in - 5);
101 out = strm->next_out - OFF;
102 beg = out - (start - strm->avail_out);
103 end = out + (strm->avail_out - 257);
104 #ifdef INFLATE_STRICT
107 wsize = state->wsize;
108 whave = state->whave;
109 write = state->write;
110 window = state->window;
113 lcode = state->lencode;
114 dcode = state->distcode;
115 lmask = (1
U << state->lenbits) - 1;
116 dmask = (1
U << state->distbits) - 1;
122 hold += (
unsigned long)(PUP(in)) << bits;
124 hold += (
unsigned long)(PUP(in)) << bits;
127 this = lcode[hold & lmask];
129 op = (unsigned)(this.bits);
132 op = (unsigned)(this.op);
134 Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
135 "inflate: literal '%c'\n" :
136 "inflate: literal 0x%02x\n", this.val));
137 PUP(out) = (
unsigned char)(this.val);
140 len = (unsigned)(this.val);
144 hold += (
unsigned long)(PUP(in)) << bits;
147 len += (unsigned)hold & ((1
U << op) - 1);
151 Tracevv((stderr,
"inflate: length %u\n", len));
153 hold += (
unsigned long)(PUP(in)) << bits;
155 hold += (
unsigned long)(PUP(in)) << bits;
158 this = dcode[hold & dmask];
160 op = (unsigned)(this.bits);
163 op = (unsigned)(this.op);
165 dist = (unsigned)(this.val);
168 hold += (
unsigned long)(PUP(in)) << bits;
171 hold += (
unsigned long)(PUP(in)) << bits;
175 dist += (unsigned)hold & ((1
U << op) - 1);
176 #ifdef INFLATE_STRICT
178 strm->msg = (
char *)
"invalid distance too far back";
185 Tracevv((stderr,
"inflate: distance %u\n", dist));
186 op = (unsigned)(out - beg);
190 strm->msg = (
char *)
"invalid distance too far back";
200 PUP(out) = PUP(from);
205 else if (write < op) {
206 from += wsize + write - op;
211 PUP(out) = PUP(from);
218 PUP(out) = PUP(from);
229 PUP(out) = PUP(from);
235 PUP(out) = PUP(from);
236 PUP(out) = PUP(from);
237 PUP(out) = PUP(from);
241 PUP(out) = PUP(from);
243 PUP(out) = PUP(from);
249 PUP(out) = PUP(from);
250 PUP(out) = PUP(from);
251 PUP(out) = PUP(from);
255 PUP(out) = PUP(from);
257 PUP(out) = PUP(from);
261 else if ((op & 64) == 0) {
262 this = dcode[this.val + (hold & ((1
U << op) - 1))];
266 strm->msg = (
char *)
"invalid distance code";
271 else if ((op & 64) == 0) {
272 this = lcode[this.val + (hold & ((1
U << op) - 1))];
276 Tracevv((stderr,
"inflate: end of block\n"));
281 strm->msg = (
char *)
"invalid literal/length code";
285 }
while (in < last && out < end);
291 hold &= (1
U << bits) - 1;
294 strm->next_in = in + OFF;
295 strm->next_out = out + OFF;
296 strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
297 strm->avail_out = (unsigned)(out < end ?
298 257 + (end - out) : 257 - (out - end));