whitespace
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/b8939bea Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/b8939bea Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/b8939bea Branch: refs/heads/master Commit: b8939bea39a1a3dd379986ff2c6cf33a5535c499 Parents: a3620e0 Author: Stefan Bodewig <[email protected]> Authored: Tue Jan 17 21:45:54 2017 +0100 Committer: Stefan Bodewig <[email protected]> Committed: Tue Jan 17 21:45:54 2017 +0100 ---------------------------------------------------------------------- .../snappy/SnappyCompressorInputStream.java | 152 +++++++++---------- 1 file changed, 76 insertions(+), 76 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b8939bea/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java index 39b484f..28bd514 100644 --- a/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java @@ -127,84 +127,84 @@ public class SnappyCompressorInputStream extends AbstractLZ77CompressorInputStre return; } - int b = readOneByte(); + int b = readOneByte(); + if (b == -1) { + throw new IOException("Premature end of stream reading block start"); + } + int length = 0; + int offset = 0; + + switch (b & TAG_MASK) { + + case 0x00: + + length = readLiteralLength(b); + uncompressedBytesRemaining -= length; + startLiteral(length); + state = State.IN_LITERAL; + break; + + case 0x01: + + /* + * These elements can encode lengths between [4..11] bytes and + * offsets between [0..2047] bytes. (len-4) occupies three bits + * and is stored in bits [2..4] of the tag byte. The offset + * occupies 11 bits, of which the upper three are stored in the + * upper three bits ([5..7]) of the tag byte, and the lower + * eight are stored in a byte following the tag byte. + */ + + length = 4 + ((b >> 2) & 0x07); + uncompressedBytesRemaining -= length; + offset = (b & 0xE0) << 3; + b = readOneByte(); if (b == -1) { - throw new IOException("Premature end of stream reading block start"); - } - int length = 0; - int offset = 0; - - switch (b & TAG_MASK) { - - case 0x00: - - length = readLiteralLength(b); - uncompressedBytesRemaining -= length; - startLiteral(length); - state = State.IN_LITERAL; - break; - - case 0x01: - - /* - * These elements can encode lengths between [4..11] bytes and - * offsets between [0..2047] bytes. (len-4) occupies three bits - * and is stored in bits [2..4] of the tag byte. The offset - * occupies 11 bits, of which the upper three are stored in the - * upper three bits ([5..7]) of the tag byte, and the lower - * eight are stored in a byte following the tag byte. - */ - - length = 4 + ((b >> 2) & 0x07); - uncompressedBytesRemaining -= length; - offset = (b & 0xE0) << 3; - b = readOneByte(); - if (b == -1) { - throw new IOException("Premature end of stream reading copy length"); - } - offset |= b; - - startCopy(offset, length); - state = State.IN_COPY; - break; - - case 0x02: - - /* - * These elements can encode lengths between [1..64] and offsets - * from [0..65535]. (len-1) occupies six bits and is stored in - * the upper six bits ([2..7]) of the tag byte. The offset is - * stored as a little-endian 16-bit integer in the two bytes - * following the tag byte. - */ - - length = (b >> 2) + 1; - uncompressedBytesRemaining -= length; - - offset = (int) ByteUtils.fromLittleEndian(supplier, 2); - - startCopy(offset, length); - state = State.IN_COPY; - break; - - case 0x03: - - /* - * These are like the copies with 2-byte offsets (see previous - * subsection), except that the offset is stored as a 32-bit - * integer instead of a 16-bit integer (and thus will occupy - * four bytes). - */ - - length = (b >> 2) + 1; - uncompressedBytesRemaining -= length; - - offset = (int) ByteUtils.fromLittleEndian(supplier, 4) & 0x7fffffff; - - startCopy(offset, length); - state = State.IN_COPY; - break; + throw new IOException("Premature end of stream reading copy length"); } + offset |= b; + + startCopy(offset, length); + state = State.IN_COPY; + break; + + case 0x02: + + /* + * These elements can encode lengths between [1..64] and offsets + * from [0..65535]. (len-1) occupies six bits and is stored in + * the upper six bits ([2..7]) of the tag byte. The offset is + * stored as a little-endian 16-bit integer in the two bytes + * following the tag byte. + */ + + length = (b >> 2) + 1; + uncompressedBytesRemaining -= length; + + offset = (int) ByteUtils.fromLittleEndian(supplier, 2); + + startCopy(offset, length); + state = State.IN_COPY; + break; + + case 0x03: + + /* + * These are like the copies with 2-byte offsets (see previous + * subsection), except that the offset is stored as a 32-bit + * integer instead of a 16-bit integer (and thus will occupy + * four bytes). + */ + + length = (b >> 2) + 1; + uncompressedBytesRemaining -= length; + + offset = (int) ByteUtils.fromLittleEndian(supplier, 4) & 0x7fffffff; + + startCopy(offset, length); + state = State.IN_COPY; + break; + } } /*
