From f7940f8b485f7251cf7abeac93793d44dd18b42e Mon Sep 17 00:00:00 2001 From: Stephane Bailliez Date: Tue, 8 Jan 2002 20:47:54 +0000 Subject: [PATCH] Fallback to 1.2. Come back later for this one. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270634 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/bzip2/CBZip2InputStream.java | 109 ++++++------------ 1 file changed, 38 insertions(+), 71 deletions(-) diff --git a/src/main/org/apache/tools/bzip2/CBZip2InputStream.java b/src/main/org/apache/tools/bzip2/CBZip2InputStream.java index cd9fa3725..fbf1f173b 100644 --- a/src/main/org/apache/tools/bzip2/CBZip2InputStream.java +++ b/src/main/org/apache/tools/bzip2/CBZip2InputStream.java @@ -89,13 +89,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { private void makeMaps() { int i; nInUse = 0; - for (i = 0; i < 256; i++) { + for (i = 0; i < 256; i++) if (inUse[i]) { seqToUnseq[nInUse] = (char)i; unseqToSeq[i] = (char)nInUse; nInUse++; } - } } /* @@ -250,11 +249,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { storedBlockCRC = bsGetInt32(); - if (bsR(1) == 1) { + if (bsR(1) == 1) blockRandomised = true; - } else { + else blockRandomised = false; - } // currBlockNo++; getAndMoveToFrontDecode(); @@ -266,9 +264,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { private void endBlock() { computedBlockCRC = mCrc.getFinalCRC(); /* A bad CRC is considered a fatal error. */ - if (storedBlockCRC != computedBlockCRC) { + if (storedBlockCRC != computedBlockCRC) crcError(); - } computedCombinedCRC = (computedCombinedCRC << 1) | (computedCombinedCRC >>> 31); @@ -277,9 +274,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { private void complete() { storedCombinedCRC = bsGetInt32(); - if (storedCombinedCRC != computedCombinedCRC) { + if (storedCombinedCRC != computedCombinedCRC) crcError(); - } bsFinishedWithStream(); streamEnd = true; @@ -361,28 +357,23 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { int pp, i, j, vec; pp = 0; - for(i = minLen; i <= maxLen; i++) { - for(j = 0; j < alphaSize; j++) { + for(i = minLen; i <= maxLen; i++) + for(j = 0; j < alphaSize; j++) if (length[j] == i) { perm[pp] = j; pp++; - } - } - }; + }; - for(i = 0; i < MAX_CODE_LEN; i++) { + for(i = 0; i < MAX_CODE_LEN; i++) base[i] = 0; - } - for(i = 0; i < alphaSize; i++) { + for(i = 0; i < alphaSize; i++) base[length[i]+1]++; - } for(i = 1; i < MAX_CODE_LEN; i++) base[i] += base[i-1]; - for (i = 0; i < MAX_CODE_LEN; i++) { + for (i = 0; i < MAX_CODE_LEN; i++) limit[i] = 0; - } vec = 0; for (i = minLen; i <= maxLen; i++) { @@ -390,9 +381,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { limit[i] = vec-1; vec <<= 1; } - for (i = minLen + 1; i <= maxLen; i++) { + for (i = minLen + 1; i <= maxLen; i++) base[i] = ((limit[i-1] + 1) << 1) - base[i]; - } } private void recvDecodingTables() { @@ -402,27 +392,20 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { boolean inUse16[] = new boolean[16]; /* Receive the mapping table */ - for (i = 0; i < 16; i++) { - if (bsR(1) == 1) { + for (i = 0; i < 16; i++) + if (bsR(1) == 1) inUse16[i] = true; - } else { + else inUse16[i] = false; - } - } - for (i = 0; i < 256; i++) { + for (i = 0; i < 256; i++) inUse[i] = false; - } - for (i = 0; i < 16; i++) { - if (inUse16[i]) { - for (j = 0; j < 16; j++) { - if (bsR(1) == 1) { + for (i = 0; i < 16; i++) + if (inUse16[i]) + for (j = 0; j < 16; j++) + if (bsR(1) == 1) inUse[i * 16 + j] = true; - } - } - } - } makeMaps(); alphaSize = nInUse+2; @@ -432,9 +415,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { nSelectors = bsR(15); for (i = 0; i < nSelectors; i++) { j = 0; - while (bsR(1) == 1) { + while (bsR(1) == 1) j++; - } selectorMtf[i] = (char)j; } @@ -442,9 +424,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { { char pos[] = new char[N_GROUPS]; char tmp, v; - for (v = 0; v < nGroups; v++) { + for (v = 0; v < nGroups; v++) pos[v] = v; - } for (i = 0; i < nSelectors; i++) { v = selectorMtf[i]; @@ -463,11 +444,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { int curr = bsR ( 5 ); for (i = 0; i < alphaSize; i++) { while (bsR(1) == 1) { - if (bsR(1) == 0) { + if (bsR(1) == 0) curr++; - } else { + else curr--; - } } len[t][i] = (char)curr; } @@ -478,12 +458,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { minLen = 32; maxLen = 0; for (i = 0; i < alphaSize; i++) { - if (len[t][i] > maxLen) { + if (len[t][i] > maxLen) maxLen = len[t][i]; - } - if (len[t][i] < minLen) { + if (len[t][i] < minLen) minLen = len[t][i]; - } } hbCreateDecodeTables(limit[t], base[t], perm[t], len[t], minLen, maxLen, alphaSize); @@ -510,13 +488,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { in a separate pass, and so saves a block's worth of cache misses. */ - for (i = 0; i <= 255; i++) { + for (i = 0; i <= 255; i++) unzftab[i] = 0; - } - for (i = 0; i <= 255; i++) { + for (i = 0; i <= 255; i++) yy[i] = (char) i; - } last = -1; @@ -560,20 +536,18 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { while(true) { - if (nextSym == EOB) { + if (nextSym == EOB) break; - } if (nextSym == RUNA || nextSym == RUNB) { char ch; int s = -1; int N = 1; do { - if (nextSym == RUNA) { + if (nextSym == RUNA) s = s + (0+1) * N; - } else if (nextSym == RUNB) { + else if (nextSym == RUNB) s = s + (1+1) * N; - } N = N * 2; { int zt, zn, zvec, zj; @@ -624,16 +598,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { s--; }; - if (last >= limitLast) { + if (last >= limitLast) blockOverrun(); - } continue; } else { char tmp; last++; - if (last >= limitLast) { + if (last >= limitLast) blockOverrun(); - } tmp = yy[nextSym-1]; unzftab[seqToUnseq[tmp]]++; @@ -653,9 +625,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { yy[j-2] = yy[j-3]; yy[j-3] = yy[j-4]; } - for (; j > 0; j--) { + for (; j > 0; j--) yy[j] = yy[j-1]; - } yy[0] = tmp; { @@ -702,12 +673,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { char ch; cftab[0] = 0; - for (i = 1; i <= 256; i++) { + for (i = 1; i <= 256; i++) cftab[i] = unzftab[i-1]; - } - for (i = 1; i <= 256; i++) { + for (i = 1; i <= 256; i++) cftab[i] += cftab[i-1]; - } for (i = 0; i <= last; i++) { ch = (char)ll8[i]; @@ -786,9 +755,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { if (rNToGo == 0) { rNToGo = rNums[rTPos]; rTPos++; - if(rTPos == 512) { + if(rTPos == 512) rTPos = 0; - } } rNToGo--; z ^= ((rNToGo == 1) ? 1 : 0); @@ -856,9 +824,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { blockSize100k = newSize100k; - if(newSize100k == 0) { + if(newSize100k == 0) return; - } int n = baseBlockSize * newSize100k; ll8 = new char[n];