summaryrefslogtreecommitdiffstats
path: root/lzip.h
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:00:02 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:00:02 +0000
commit87ecf0660c0e11efa9eab93b8b20cf251de08d21 (patch)
tree83b393486d489834d8831512a00322fff50ade33 /lzip.h
parentAdding debian version 1.15~pre3-1. (diff)
downloadlzip-87ecf0660c0e11efa9eab93b8b20cf251de08d21.tar.xz
lzip-87ecf0660c0e11efa9eab93b8b20cf251de08d21.zip
Merging upstream version 1.15~rc1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'lzip.h')
-rw-r--r--lzip.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/lzip.h b/lzip.h
index 20912cf..b563833 100644
--- a/lzip.h
+++ b/lzip.h
@@ -30,10 +30,11 @@ public:
static const int next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
st = next[st];
}
-
- void set_match() { st = ( ( st < 7 ) ? 7 : 10 ); }
- void set_rep() { st = ( ( st < 7 ) ? 8 : 11 ); }
- void set_short_rep() { st = ( ( st < 7 ) ? 9 : 11 ); }
+ void set_char1() { st -= ( st < 4 ) ? st : 3; } // for st < 7
+ void set_char2() { st -= ( st < 10 ) ? 3 : 6; } // for st >= 7
+ void set_match() { st = ( st < 7 ) ? 7 : 10; }
+ void set_rep() { st = ( st < 7 ) ? 8 : 11; }
+ void set_short_rep() { st = ( st < 7 ) ? 9 : 11; }
};
@@ -147,10 +148,11 @@ public:
uint32_t operator[]( const uint8_t byte ) const { return data[byte]; }
- void update( uint32_t & crc, const uint8_t byte ) const
+ void update_byte( uint32_t & crc, const uint8_t byte ) const
{ crc = data[(crc^byte)&0xFF] ^ ( crc >> 8 ); }
- 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 );
@@ -192,15 +194,15 @@ struct File_header
return sz;
}
- bool dictionary_size( const int sz )
+ bool dictionary_size( const unsigned sz )
{
if( sz >= min_dictionary_size && sz <= max_dictionary_size )
{
data[5] = real_bits( sz - 1 );
if( sz > min_dictionary_size )
{
- const int base_size = 1 << data[5];
- const int wedge = base_size / 16;
+ const unsigned base_size = 1 << data[5];
+ const unsigned wedge = base_size / 16;
for( int i = 7; i >= 1; --i )
if( base_size - ( i * wedge ) >= sz )
{ data[5] |= ( i << 5 ); break; }