diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:32:10 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:32:10 +0000 |
commit | 48f82c742fbb20fd624a466f0f3dcbc9a9679768 (patch) | |
tree | 694e61fe55b10051d97cd89a73cd70de544d85c5 /lzip.h | |
parent | Adding debian version 1.13~rc2-1. (diff) | |
download | lzip-48f82c742fbb20fd624a466f0f3dcbc9a9679768.tar.xz lzip-48f82c742fbb20fd624a466f0f3dcbc9a9679768.zip |
Merging upstream version 1.13.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'lzip.h')
-rw-r--r-- | lzip.h | 78 |
1 files changed, 38 insertions, 40 deletions
@@ -21,32 +21,32 @@ class State public: enum { states = 12 }; - State() throw() : st( 0 ) {} - unsigned char operator()() const throw() { return st; } - bool is_char() const throw() { return st < 7; } + State() : st( 0 ) {} + unsigned char operator()() const { return st; } + bool is_char() const { return st < 7; } - void set_char() throw() + void set_char() { static const unsigned char next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 }; st = next[st]; } - void set_match() throw() + void set_match() { static const unsigned char next[states] = { 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10 }; st = next[st]; } - void set_rep() throw() + void set_rep() { static const unsigned char next[states] = { 8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11 }; st = next[st]; } - void set_short_rep() throw() + void set_short_rep() { static const unsigned char next[states] = { 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11 }; @@ -86,7 +86,7 @@ enum { max_dis_states = 4 }; -inline int get_dis_state( int len ) throw() +inline int get_dis_state( int len ) { len -= min_match_len; if( len >= max_dis_states ) len = max_dis_states - 1; @@ -101,7 +101,7 @@ enum { bit_model_move_bits = 5, struct Bit_model { unsigned int probability; - Bit_model() throw() : probability( bit_model_total / 2 ) {} + Bit_model() : probability( bit_model_total / 2 ) {} }; @@ -135,10 +135,10 @@ public: first_post = true; } - void reset() const throw() { if( name_.size() ) first_post = true; } - const char * name() const throw() { return name_.c_str(); } - int verbosity() const throw() { return verbosity_; } - void operator()( const char * const msg = 0 ) const throw(); + void reset() const { if( name_.size() ) first_post = true; } + const char * name() const { return name_.c_str(); } + int verbosity() const { return verbosity_; } + void operator()( const char * const msg = 0 ) const; }; @@ -158,10 +158,10 @@ public: } } - uint32_t operator[]( const uint8_t byte ) const throw() { return data[byte]; } - void update( uint32_t & crc, const uint8_t byte ) const throw() + uint32_t operator[]( const uint8_t byte ) const { return data[byte]; } + void update( 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 throw() + void update( 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 ); @@ -171,11 +171,11 @@ public: extern const CRC32 crc32; -inline int real_bits( const int value ) throw() +inline int real_bits( const unsigned int value ) { - int bits = 0; - for( int i = 1, mask = 1; mask > 0; ++i, mask <<= 1 ) - if( value & mask ) bits = i; + int bits = 0, i = 1; + unsigned int mask = 1; + for( ; mask > 0; ++i, mask <<= 1 ) if( value & mask ) bits = i; return bits; } @@ -189,24 +189,22 @@ struct File_header // 5 coded_dict_size enum { size = 6 }; - void set_magic() throw() - { std::memcpy( data, magic_string, 4 ); data[4] = 1; } - - bool verify_magic() const throw() + void set_magic() { std::memcpy( data, magic_string, 4 ); data[4] = 1; } + bool verify_magic() const { return ( std::memcmp( data, magic_string, 4 ) == 0 ); } - uint8_t version() const throw() { return data[4]; } - bool verify_version() const throw() { return ( data[4] <= 1 ); } + uint8_t version() const { return data[4]; } + bool verify_version() const { return ( data[4] <= 1 ); } - int dictionary_size() const throw() + int dictionary_size() const { int sz = ( 1 << ( data[5] & 0x1F ) ); if( sz > min_dictionary_size && sz <= max_dictionary_size ) - sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 0x07 ); + sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 ); return sz; } - bool dictionary_size( const int sz ) throw() + bool dictionary_size( const int sz ) { if( sz >= min_dictionary_size && sz <= max_dictionary_size ) { @@ -235,36 +233,36 @@ struct File_trailer static int size( const int version = 1 ) { return ( ( version >= 1 ) ? 20 : 12 ); } - uint32_t data_crc() const throw() + uint32_t data_crc() const { uint32_t tmp = 0; for( int i = 3; i >= 0; --i ) { tmp <<= 8; tmp += data[i]; } return tmp; } - void data_crc( uint32_t crc ) throw() + void data_crc( uint32_t crc ) { for( int i = 0; i <= 3; ++i ) { data[i] = (uint8_t)crc; crc >>= 8; } } - long long data_size() const throw() + long long data_size() const { long long tmp = 0; for( int i = 11; i >= 4; --i ) { tmp <<= 8; tmp += data[i]; } return tmp; } - void data_size( long long sz ) throw() + void data_size( long long sz ) { for( int i = 4; i <= 11; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } } - long long member_size() const throw() + long long member_size() const { long long tmp = 0; for( int i = 19; i >= 12; --i ) { tmp <<= 8; tmp += data[i]; } return tmp; } - void member_size( long long sz ) throw() + void member_size( long long sz ) { for( int i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } } @@ -274,15 +272,15 @@ struct File_trailer struct Error { const char * const msg; - explicit Error( const char * const s ) throw() : msg( s ) {} + explicit Error( const char * const s ) : msg( s ) {} }; // defined in main.cc void show_error( const char * const msg, const int errcode = 0, - const bool help = false ) throw(); -void internal_error( const char * const msg ) throw(); + const bool help = false ); +void internal_error( const char * const msg ); // defined in decoder.cc -int readblock( const int fd, uint8_t * const buf, const int size ) throw(); -int writeblock( const int fd, const uint8_t * const buf, const int size ) throw(); +int readblock( const int fd, uint8_t * const buf, const int size ); +int writeblock( const int fd, const uint8_t * const buf, const int size ); |