summaryrefslogtreecommitdiffstats
path: root/decoder.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:00:31 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:00:31 +0000
commit3f2a7dc31b4309fbd1a946b0fc3317764f0eb905 (patch)
tree382b32f3f4cd342b2858c258e7beca901e5ca506 /decoder.cc
parentAdding upstream version 1.15~rc1. (diff)
downloadlzip-3f2a7dc31b4309fbd1a946b0fc3317764f0eb905.tar.xz
lzip-3f2a7dc31b4309fbd1a946b0fc3317764f0eb905.zip
Adding upstream version 1.15.upstream/1.15
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.cc')
-rw-r--r--decoder.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/decoder.cc b/decoder.cc
index b23daa2..06d334b 100644
--- a/decoder.cc
+++ b/decoder.cc
@@ -51,9 +51,9 @@ void Pretty_print::operator()( const char * const msg ) const
}
-// Returns the number of bytes really read.
-// If (returned value < size) and (errno == 0), means EOF was reached.
-//
+/* Returns the number of bytes really read.
+ If (returned value < size) and (errno == 0), means EOF was reached.
+*/
int readblock( const int fd, uint8_t * const buf, const int size )
{
int rest = size;
@@ -70,9 +70,9 @@ int readblock( const int fd, uint8_t * const buf, const int size )
}
-// Returns the number of bytes really written.
-// If (returned value < size), it is always an error.
-//
+/* Returns the number of bytes really written.
+ If (returned value < size), it is always an error.
+*/
int writeblock( const int fd, const uint8_t * const buf, const int size )
{
int rest = size;
@@ -104,9 +104,9 @@ bool Range_decoder::read_block()
void LZ_decoder::flush_data()
{
- const int size = pos - stream_pos;
- if( size > 0 )
+ if( pos > stream_pos )
{
+ const int size = pos - stream_pos;
crc32.update_buf( crc_, buffer + stream_pos, size );
if( outfd >= 0 &&
writeblock( outfd, buffer + stream_pos, size ) != size )
@@ -187,8 +187,8 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp ) const
}
-// Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF,
-// 3 = trailer error, 4 = unknown marker found.
+/* Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF,
+ 3 = trailer error, 4 = unknown marker found. */
int LZ_decoder::decode_member( const Pretty_print & pp )
{
Bit_model bm_literal[1<<literal_context_bits][0x300];
@@ -198,7 +198,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp )
Bit_model bm_rep1[State::states];
Bit_model bm_rep2[State::states];
Bit_model bm_len[State::states][pos_states];
- Bit_model bm_dis_slot[max_dis_states][1<<dis_slot_bits];
+ Bit_model bm_dis_slot[len_states][1<<dis_slot_bits];
Bit_model bm_dis[modeled_distances-end_dis_model];
Bit_model bm_align[dis_align_size];
Len_model match_len_model;
@@ -231,9 +231,9 @@ int LZ_decoder::decode_member( const Pretty_print & pp )
else
{
int len;
- if( rdec.decode_bit( bm_rep[state()] ) == 1 ) // 2nd bit
+ if( rdec.decode_bit( bm_rep[state()] ) != 0 ) // 2nd bit
{
- if( rdec.decode_bit( bm_rep0[state()] ) == 1 ) // 3rd bit
+ if( rdec.decode_bit( bm_rep0[state()] ) != 0 ) // 3rd bit
{
unsigned distance;
if( rdec.decode_bit( bm_rep1[state()] ) == 0 ) // 4th bit
@@ -261,7 +261,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp )
{
const unsigned rep0_saved = rep0;
len = min_match_len + rdec.decode_len( match_len_model, pos_state );
- const int dis_slot = rdec.decode_tree6( bm_dis_slot[get_dis_state(len)] );
+ const int dis_slot = rdec.decode_tree6( bm_dis_slot[get_len_state(len)] );
if( dis_slot < start_dis_model ) rep0 = dis_slot;
else
{