- unsigned curpos;
- unsigned huffsym;
- int ret;
- int match_len;
-
- curpos = 0;
- while (curpos < uncompressed_len) {
- ret = read_huffsym(istream, decode_table, lens,
- XPRESS_NUM_SYMBOLS, XPRESS_TABLEBITS,
- &huffsym, XPRESS_MAX_CODEWORD_LEN);
- if (ret)
- return ret;
-
- if (huffsym < XPRESS_NUM_CHARS) {
- uncompressed_data[curpos++] = huffsym;
+ input_idx_t curpos;
+ unsigned match_len;
+
+ for (curpos = 0; curpos < uncompressed_len; curpos += match_len) {
+ unsigned sym;
+ int ret;
+
+ bitstream_ensure_bits(istream, 16);
+
+ sym = read_huffsym(istream, decode_table,
+ XPRESS_TABLEBITS, XPRESS_MAX_CODEWORD_LEN);
+ if (sym < XPRESS_NUM_CHARS) {
+ /* Literal */
+ uncompressed_data[curpos] = sym;
+ match_len = 1;