diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:03:29 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:03:29 +0000 |
commit | e82f995206b96db9cee9c83e21d1cac07e411154 (patch) | |
tree | b02fe3a48ed6a4a28830cfa3df3730be3f0f833a /decoder.c | |
parent | Adding upstream version 1.4~rc1. (diff) | |
download | lunzip-e82f995206b96db9cee9c83e21d1cac07e411154.tar.xz lunzip-e82f995206b96db9cee9c83e21d1cac07e411154.zip |
Adding upstream version 1.4.upstream/1.4
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.c')
-rw-r--r-- | decoder.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -104,9 +104,9 @@ bool Rd_read_block( struct Range_decoder * const rdec ) void LZd_flush_data( struct LZ_decoder * const decoder ) { - const int size = decoder->pos - decoder->stream_pos; - if( size > 0 ) + if( decoder->pos > decoder->stream_pos ) { + const int size = decoder->pos - decoder->stream_pos; CRC32_update_buf( &decoder->crc, decoder->buffer + decoder->stream_pos, size ); if( decoder->outfd >= 0 && writeblock( decoder->outfd, decoder->buffer + decoder->stream_pos, size ) != size ) @@ -223,15 +223,9 @@ int LZd_decode_member( struct LZ_decoder * const decoder, else { int len; - if( Rd_decode_bit( rdec, &decoder->bm_rep[state] ) == 1 ) /* 2nd bit */ + if( Rd_decode_bit( rdec, &decoder->bm_rep[state] ) != 0 ) /* 2nd bit */ { - if( Rd_decode_bit( rdec, &decoder->bm_rep0[state] ) == 0 ) /* 3rd bit */ - { - if( Rd_decode_bit( rdec, &decoder->bm_len[state][pos_state] ) == 0 ) /* 4th bit */ - { state = St_set_short_rep( state ); - LZd_put_byte( decoder, LZd_get_byte( decoder, rep0 ) ); continue; } - } - else + if( Rd_decode_bit( rdec, &decoder->bm_rep0[state] ) != 0 ) /* 3rd bit */ { unsigned distance; if( Rd_decode_bit( rdec, &decoder->bm_rep1[state] ) == 0 ) /* 4th bit */ @@ -247,6 +241,12 @@ int LZd_decode_member( struct LZ_decoder * const decoder, rep1 = rep0; rep0 = distance; } + else + { + if( Rd_decode_bit( rdec, &decoder->bm_len[state][pos_state] ) == 0 ) /* 4th bit */ + { state = St_set_short_rep( state ); + LZd_put_byte( decoder, LZd_get_byte( decoder, rep0 ) ); continue; } + } state = St_set_rep( state ); len = min_match_len + Rd_decode_len( rdec, &decoder->rep_len_model, pos_state ); } @@ -255,7 +255,7 @@ int LZd_decode_member( struct LZ_decoder * const decoder, int dis_slot; const unsigned rep0_saved = rep0; len = min_match_len + Rd_decode_len( rdec, &decoder->match_len_model, pos_state ); - dis_slot = Rd_decode_tree6( rdec, decoder->bm_dis_slot[get_dis_state(len)] ); + dis_slot = Rd_decode_tree6( rdec, decoder->bm_dis_slot[get_len_state(len)] ); if( dis_slot < start_dis_model ) rep0 = dis_slot; else { |