Fix regression in Zlib which was introduced while refactoring the code. See #255

This commit is contained in:
norman 2012-04-11 10:26:29 +02:00
parent 97561315fd
commit 05204025cc

View File

@ -124,15 +124,16 @@ final class InfBlocks {
int m; // bytes to end of window or read pointer int m; // bytes to end of window or read pointer
// copy input/output information to locals (UPDATE macro restores) // copy input/output information to locals (UPDATE macro restores)
{
p = z.next_in_index; p = z.next_in_index;
n = z.avail_in; n = z.avail_in;
b = bitb; b = bitb;
k = bitk; k = bitk;
}
{
q = write; q = write;
m = q < read? read - q - 1 : end - q; m = q < read? read - q - 1 : end - q;
}
// process input based on current state // process input based on current state
while (true) { while (true) {
@ -160,17 +161,20 @@ final class InfBlocks {
switch (t >>> 1) { switch (t >>> 1) {
case 0: // stored case 0: // stored
{
b >>>= 3; b >>>= 3;
k -= 3; k -= 3;
}
t = k & 7; // go to byte boundary t = k & 7; // go to byte boundary
{
b >>>= t; b >>>= t;
k -= t; k -= t;
}
mode = LENS; // get length of stored block mode = LENS; // get length of stored block
break; break;
case 1: // fixed case 1: // fixed
{
int[] bl = new int[1]; int[] bl = new int[1];
int[] bd = new int[1]; int[] bd = new int[1];
int[][] tl = new int[1][]; int[][] tl = new int[1][];
@ -178,24 +182,30 @@ final class InfBlocks {
InfTree.inflate_trees_fixed(bl, bd, tl, td); InfTree.inflate_trees_fixed(bl, bd, tl, td);
codes.init(bl[0], bd[0], tl[0], 0, td[0], 0); codes.init(bl[0], bd[0], tl[0], 0, td[0], 0);
}
{
b >>>= 3; b >>>= 3;
k -= 3; k -= 3;
}
mode = CODES; mode = CODES;
break; break;
case 2: // dynamic case 2: // dynamic
{
b >>>= 3; b >>>= 3;
k -= 3; k -= 3;
}
mode = TABLE; mode = TABLE;
break; break;
case 3: // illegal case 3: // illegal
{
b >>>= 3; b >>>= 3;
k -= 3; k -= 3;
}
mode = BAD; mode = BAD;
z.msg = "invalid block type"; z.msg = "invalid block type";
r = JZlib.Z_DATA_ERROR; r = JZlib.Z_DATA_ERROR;
@ -342,9 +352,10 @@ final class InfBlocks {
} }
} }
{
b >>>= 14; b >>>= 14;
k -= 14; k -= 14;
}
index = 0; index = 0;
mode = BTREE; mode = BTREE;
@ -369,9 +380,10 @@ final class InfBlocks {
blens[border[index ++]] = b & 7; blens[border[index ++]] = b & 7;
{
b >>>= 3; b >>>= 3;
k -= 3; k -= 3;
}
} }
while (index < 19) { while (index < 19) {
@ -493,7 +505,7 @@ final class InfBlocks {
} }
tb[0] = -1; tb[0] = -1;
{
int[] bl = new int[1]; int[] bl = new int[1];
int[] bd = new int[1]; int[] bd = new int[1];
int[] tl = new int[1]; int[] tl = new int[1];
@ -522,7 +534,7 @@ final class InfBlocks {
return inflate_flush(z, r); return inflate_flush(z, r);
} }
codes.init(bl[0], bd[0], hufts, tl[0], hufts, td[0]); codes.init(bl[0], bd[0], hufts, tl[0], hufts, td[0]);
}
mode = CODES; mode = CODES;
case CODES: case CODES:
bitb = b; bitb = b;