Simplify incomplete code table filling in inflate_table().

Due to earlier changes in the error checking in inflate_table(), the
code to fill in a table for an incomplete code handled cases that can
never actually occur.  This simplifies that code to handle the only
possible case, which is a single empty table entry for a code with
a single symbol with a length of one bit.
This commit is contained in:
Mark Adler 2011-11-06 15:02:02 -08:00
parent 1b57de3aef
commit 383d2cdab7

View File

@ -289,38 +289,14 @@ unsigned short FAR *work;
} }
} }
/* /* fill in remaining table entry if code is incomplete (guaranteed to have
Fill in rest of table for incomplete codes. This loop is similar to the at most one remaining entry, since if the code is incomplete, the
loop above in incrementing huff for table indices. It is assumed that maximum code length that was allowed to get this far is one bit) */
len is equal to curr + drop, so there is no loop needed to increment if (huff != 0) {
through high index bits. When the current sub-table is filled, the loop here.op = (unsigned char)64; /* invalid code marker */
drops back to the root table to fill in any remaining entries there. here.bits = (unsigned char)(len - drop);
*/ here.val = (unsigned short)0;
here.op = (unsigned char)64; /* invalid code marker */ next[huff] = here;
here.bits = (unsigned char)(len - drop);
here.val = (unsigned short)0;
while (huff != 0) {
/* when done with sub-table, drop back to root table */
if (drop != 0 && (huff & mask) != low) {
drop = 0;
len = root;
next = *table;
here.bits = (unsigned char)len;
}
/* put invalid code marker in table */
next[huff >> drop] = here;
/* backwards increment the len-bit code huff */
incr = 1U << (len - 1);
while (huff & incr)
incr >>= 1;
if (incr != 0) {
huff &= incr - 1;
huff += incr;
}
else
huff = 0;
} }
/* set return parameters */ /* set return parameters */