From bf0ce1adc0ace9ce9468aaa5c4f17187736e012d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 07:46:28 +0100 Subject: Adding upstream version 0.4. Signed-off-by: Daniel Baumann --- lzd.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lzd.cc') diff --git a/lzd.cc b/lzd.cc index 0ac7b64..b5c5ac8 100644 --- a/lzd.cc +++ b/lzd.cc @@ -110,7 +110,8 @@ public: } } - void update( uint32_t & crc, const uint8_t * const buffer, const int size ) const + void update_buf( uint32_t & crc, const uint8_t * const buffer, + const int size ) const { for( int i = 0; i < size; ++i ) crc = data[(crc^buffer[i])&0xFF] ^ ( crc >> 8 ); @@ -278,7 +279,7 @@ void LZ_decoder::flush_data() if( pos > stream_pos ) { const unsigned size = pos - stream_pos; - crc32.update( crc_, buffer + stream_pos, size ); + crc32.update_buf( crc_, buffer + stream_pos, size ); errno = 0; if( std::fwrite( buffer + stream_pos, 1, size, stdout ) != size ) { std::fprintf( stderr, "Write error: %s\n", std::strerror( errno ) ); @@ -328,12 +329,7 @@ bool LZ_decoder::decode_member() // Returns false if error int len; if( rdec.decode_bit( bm_rep[state()] ) == 1 ) // 2nd bit { - if( rdec.decode_bit( bm_rep0[state()] ) == 0 ) // 3rd bit - { - if( rdec.decode_bit( bm_len[state()][pos_state] ) == 0 ) // 4th bit - { state.set_short_rep(); put_byte( get_byte( rep0 ) ); continue; } - } - else + if( rdec.decode_bit( bm_rep0[state()] ) == 1 ) // 3rd bit { unsigned distance; if( rdec.decode_bit( bm_rep1[state()] ) == 0 ) // 4th bit @@ -349,6 +345,11 @@ bool LZ_decoder::decode_member() // Returns false if error rep1 = rep0; rep0 = distance; } + else + { + if( rdec.decode_bit( bm_len[state()][pos_state] ) == 0 ) // 4th bit + { state.set_short_rep(); put_byte( get_byte( rep0 ) ); continue; } + } len = min_match_len + rdec.decode_len( rep_len_model, pos_state ); state.set_rep(); } @@ -405,7 +406,7 @@ int main( const int argc, const char * const argv[] ) "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n" "Report bugs to lzip-bug@nongnu.org\n" - "Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" ); + "Lzd home page: http://www.nongnu.org/lzip/lzd.html\n" ); return 0; } -- cgit v1.2.3