diff options
Diffstat (limited to 'decoder.cc')
-rw-r--r-- | decoder.cc | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -77,7 +77,7 @@ bool Range_decoder::read_block() { stream_pos = readblock( infd, buffer, buffer_size ); if( stream_pos != buffer_size && errno ) throw Error( read_error_msg ); - at_stream_end = ( stream_pos < buffer_size ); + at_stream_end = stream_pos < buffer_size; partial_member_pos += pos; pos = 0; show_dprogress(); @@ -99,7 +99,7 @@ void LZ_decoder::flush_data() const long long s = std::min( positive_diff( outend, sp ), (unsigned long long)size ) - i; if( s > 0 && writeblock( outfd, buffer + stream_pos + i, s ) != s ) - throw Error( "Write error" ); + throw Error( write_error_msg ); } if( pos >= dictionary_size ) { partial_data_pos += pos; pos = 0; pos_wrapped = true; } @@ -180,7 +180,8 @@ bool LZ_decoder::check_trailer( const Pretty_print & pp ) const /* Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF, 3 = trailer error, 4 = unknown marker found, 5 = nonzero first LZMA byte found. */ -int LZ_decoder::decode_member( const Pretty_print & pp, const bool ignore_nonzero ) +int LZ_decoder::decode_member( const Pretty_print & pp, + const bool ignore_nonzero ) { Bit_model bm_literal[1<<literal_context_bits][0x300]; Bit_model bm_match[State::states][pos_states]; @@ -244,22 +245,22 @@ int LZ_decoder::decode_member( const Pretty_print & pp, const bool ignore_nonzer } else // match { + rep3 = rep2; rep2 = rep1; rep1 = rep0; len = rdec.decode_len( match_len_model, pos_state ); - unsigned distance = rdec.decode_tree6( bm_dis_slot[get_len_state(len)] ); - if( distance >= start_dis_model ) + rep0 = rdec.decode_tree6( bm_dis_slot[get_len_state(len)] ); + if( rep0 >= start_dis_model ) { - const unsigned dis_slot = distance; + const unsigned dis_slot = rep0; const int direct_bits = ( dis_slot >> 1 ) - 1; - distance = ( 2 | ( dis_slot & 1 ) ) << direct_bits; + rep0 = ( 2 | ( dis_slot & 1 ) ) << direct_bits; if( dis_slot < end_dis_model ) - distance += rdec.decode_tree_reversed( - bm_dis + ( distance - dis_slot ), direct_bits ); + rep0 += rdec.decode_tree_reversed( bm_dis + ( rep0 - dis_slot ), + direct_bits ); else { - distance += - rdec.decode( direct_bits - dis_align_bits ) << dis_align_bits; - distance += rdec.decode_tree_reversed4( bm_align ); - if( distance == 0xFFFFFFFFU ) // marker found + rep0 += rdec.decode( direct_bits - dis_align_bits ) << dis_align_bits; + rep0 += rdec.decode_tree_reversed4( bm_align ); + if( rep0 == 0xFFFFFFFFU ) // marker found { rdec.normalize(); flush_data(); @@ -271,7 +272,6 @@ int LZ_decoder::decode_member( const Pretty_print & pp, const bool ignore_nonzer } } } - rep3 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance; state.set_match(); if( rep0 >= dictionary_size || ( rep0 >= pos && !pos_wrapped ) ) { flush_data(); return 1; } |