Workaround for codes that fail to include (required) final TERMINATOR mode indicator

git-svn-id: https://zxing.googlecode.com/svn/trunk@351 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-04-07 22:05:40 +00:00
parent 19dbe047fd
commit 1c9b906442

View file

@ -60,7 +60,12 @@ final class DecodedBitStreamParser {
Mode mode; Mode mode;
do { do {
// While still another segment to read... // While still another segment to read...
mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits if (bits.available() == 0) {
// OK, assume we're done. Really, a TERMINATOR mode should have been recorded here
mode = Mode.TERMINATOR;
} else {
mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits
}
if (!mode.equals(Mode.TERMINATOR)) { if (!mode.equals(Mode.TERMINATOR)) {
// How many characters will follow, encoded in this mode? // How many characters will follow, encoded in this mode?
int count = bits.readBits(mode.getCharacterCountBits(version)); int count = bits.readBits(mode.getCharacterCountBits(version));