diff options
Diffstat (limited to 'decoder.cc')
-rw-r--r-- | decoder.cc | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1,5 +1,6 @@ /* Lzip - LZMA lossless data compressor - Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz. + Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014 + Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,7 +64,7 @@ int readblock( const int fd, uint8_t * const buf, const int size ) const int n = read( fd, buf + size - rest, rest ); if( n > 0 ) rest -= n; else if( n == 0 ) break; // EOF - else if( errno != EINTR && errno != EAGAIN ) break; + else if( errno != EINTR ) break; errno = 0; } return size - rest; @@ -81,7 +82,7 @@ int writeblock( const int fd, const uint8_t * const buf, const int size ) { const int n = write( fd, buf + size - rest, rest ); if( n > 0 ) rest -= n; - else if( n < 0 && errno != EINTR && errno != EAGAIN ) break; + else if( n < 0 && errno != EINTR ) break; errno = 0; } return size - rest; @@ -108,8 +109,7 @@ void LZ_decoder::flush_data() { const int size = pos - stream_pos; crc32.update_buf( crc_, buffer + stream_pos, size ); - if( outfd >= 0 && - writeblock( outfd, buffer + stream_pos, size ) != size ) + if( outfd >= 0 && writeblock( outfd, buffer + stream_pos, size ) != size ) throw Error( "Write error" ); if( pos >= buffer_size ) { partial_data_pos += pos; pos = 0; } stream_pos = pos; @@ -219,7 +219,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) if( state.is_char() ) { state.set_char1(); - put_byte( rdec.decode_tree( bm_literal[get_lit_state(prev_byte)], 8 ) ); + put_byte( rdec.decode_tree8( bm_literal[get_lit_state(prev_byte)] ) ); } else { @@ -298,8 +298,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) } rep3 = rep2; rep2 = rep1; rep1 = rep0_saved; state.set_match(); - if( rep0 >= (unsigned)dictionary_size || - ( rep0 >= (unsigned)pos && !partial_data_pos ) ) + if( rep0 >= dictionary_size || rep0 >= data_position() ) { flush_data(); return 1; } } copy_block( rep0, len ); |