From 3f2a7dc31b4309fbd1a946b0fc3317764f0eb905 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 11:00:31 +0100 Subject: Adding upstream version 1.15. Signed-off-by: Daniel Baumann --- ChangeLog | 25 +++++-------------------- Makefile.in | 3 +-- README | 4 ++-- arg_parser.cc | 4 ++-- configure | 2 +- decoder.cc | 28 ++++++++++++++-------------- doc/lzip.1 | 4 ++-- doc/lzip.info | 46 +++++++++++++++++++++++----------------------- doc/lzip.texinfo | 34 +++++++++++++++++----------------- encoder.cc | 23 +++++++++++------------ encoder.h | 16 ++++++++-------- lzip.h | 11 +++++------ main.cc | 10 +++++----- 13 files changed, 96 insertions(+), 114 deletions(-) diff --git a/ChangeLog b/ChangeLog index edd72f5..94a8301 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,26 +1,11 @@ -2013-08-01 Antonio Diaz Diaz +2013-09-20 Antonio Diaz Diaz - * Version 1.15-rc1 released. - * main.cc (show_header): Do not show header version. - * Updated appendix 'Reference source code' to version 0.4 of lzd. - * Minor fixes. - -2013-07-15 Antonio Diaz Diaz - - * Version 1.15-pre3 released. + * Version 1.15 released. * Show progress of compression at verbosity level 2 (-vv). - -2013-05-11 Antonio Diaz Diaz - - * Version 1.15-pre2 released. - * configure: Options now accept a separate argument. - -2013-03-21 Antonio Diaz Diaz - - * Version 1.15-pre1 released. - * main.cc (show_header): Show header version if verbosity >= 4. + * main.cc (show_header): Do not show header version. * Ignore option '-n, --threads' for compatibility with plzip. - * Added chapter 'Stream Format' and appendix 'Reference source code' + * configure: Options now accept a separate argument. + * Added chapter 'Stream format' and appendix 'Reference source code' to the manual. 2013-02-17 Antonio Diaz Diaz diff --git a/Makefile.in b/Makefile.in index f6daaa1..c8f0ad9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -45,8 +45,7 @@ $(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texinfo man : $(VPATH)/doc/$(progname).1 $(VPATH)/doc/$(progname).1 : $(progname) - help2man -n 'reduces the size of files' \ - -o $@ ./$(progname) + help2man -n 'reduces the size of files' -o $@ ./$(progname) Makefile : $(VPATH)/configure $(VPATH)/Makefile.in ./config.status diff --git a/README b/README index a47dd17..16a8151 100644 --- a/README +++ b/README @@ -26,8 +26,8 @@ recovery capabilities, including error-checked merging of damaged copies of a file. Lzip uses the same well-defined exit status values used by bzip2, which -makes it safer when used in pipes or scripts than compressors returning -ambiguous warning values, like gzip. +makes it safer than compressors returning ambiguous warning values (like +gzip) when it is used as a back end for tar or zutils. Lzip replaces every file given in the command line with a compressed version of itself, with the name "original_name.lz". Each compressed diff --git a/arg_parser.cc b/arg_parser.cc index a28d2ba..5cb98a9 100644 --- a/arg_parser.cc +++ b/arg_parser.cc @@ -156,12 +156,12 @@ Arg_parser::Arg_parser( const int argc, const char * const argv[], while( argind < argc ) { const unsigned char ch1 = argv[argind][0]; - const unsigned char ch2 = ( ch1 ? argv[argind][1] : 0 ); + const unsigned char ch2 = ch1 ? argv[argind][1] : 0; if( ch1 == '-' && ch2 ) // we found an option { const char * const opt = argv[argind]; - const char * const arg = (argind + 1 < argc) ? argv[argind+1] : 0; + const char * const arg = ( argind + 1 < argc ) ? argv[argind+1] : 0; if( ch2 == '-' ) { if( !argv[argind][2] ) { ++argind; break; } // we found "--" diff --git a/configure b/configure index ae61b04..20a11a2 100755 --- a/configure +++ b/configure @@ -6,7 +6,7 @@ # to copy, distribute and modify it. pkgname=lzip -pkgversion=1.15-rc1 +pkgversion=1.15 progname=lzip srctrigger=doc/${pkgname}.texinfo 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< suppress all messages .TP \fB\-s\fR, \fB\-\-dictionary\-size=\fR -set dictionary size limit in bytes [8MiB] +set dictionary size limit in bytes [8 MiB] .TP \fB\-S\fR, \fB\-\-volume\-size=\fR set volume size limit in bytes diff --git a/doc/lzip.info b/doc/lzip.info index 4445d40..a1a2cbe 100644 --- a/doc/lzip.info +++ b/doc/lzip.info @@ -11,7 +11,7 @@ File: lzip.info, Node: Top, Next: Introduction, Up: (dir) Lzip Manual *********** -This manual is for Lzip (version 1.15-rc1, 1 August 2013). +This manual is for Lzip (version 1.15, 20 September 2013). * Menu: @@ -63,8 +63,8 @@ recovery capabilities, including error-checked merging of damaged copies of a file. Lzip uses the same well-defined exit status values used by bzip2, -which makes it safer when used in pipes or scripts than compressors -returning ambiguous warning values, like gzip. +which makes it safer than compressors returning ambiguous warning +values (like gzip) when it is used as a back end for tar or zutils. Lzip replaces every file given in the command line with a compressed version of itself, with the name "original_name.lz". Each compressed @@ -278,7 +278,7 @@ The format for running lzip is: `--verbose' Verbose mode. When compressing, show the compression ratio for each file - processed. A second -v shows the progress of compression. + processed. A second `-v' shows the progress of compression. When decompressing or testing, further -v's (up to 4) increase the verbosity level, showing status, compression ratio, dictionary size, trailer contents (CRC, data size, member size), and up to 6 @@ -520,8 +520,8 @@ integers representing the probability of the corresponding bit being 0. `literal_state' Value of the 3 most significant bits of the latest byte decoded. -`dis_state' - Coded value of length (real length - 2), with a maximum of 3. The +`len_state' + Coded value of length (length - 2), with a maximum of 3. The resulting value is in the range 0 to 3. @@ -561,7 +561,7 @@ bm_len state, pos_state after sequence 110 Name Indices Used when --------------------------------------------------------------------------- -bm_dis_slot dis_state, bit tree distance start +bm_dis_slot len_state, bit tree distance start bm_dis reverse bit tree after slots 4 to 13 bm_align reverse bit tree for distances >= 128, after fixed probability bits @@ -696,7 +696,7 @@ file with a member size of 32 MiB.  File: lzip.info, Node: Problems, Next: Reference source code, Prev: Examples, Up: Top -7 Reporting Bugs +7 Reporting bugs **************** There are probably bugs in lzip. There are certainly errors and @@ -768,6 +768,7 @@ enum { pos_states = 1 << pos_state_bits, pos_state_mask = pos_states - 1, + len_states = 4, dis_slot_bits = 6, start_dis_model = 4, end_dis_model = 14, @@ -784,7 +785,6 @@ enum { max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols, min_match_len = 2, // must be 2 - max_dis_states = 4, bit_model_move_bits = 5, bit_model_total_bits = 11, @@ -1011,7 +1011,7 @@ bool LZ_decoder::decode_member() // Returns false if error 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<= 128, after fixed probability bits @@ -765,7 +765,7 @@ lzip -b 32MiB -S 650MB big_db @node Problems -@chapter Reporting Bugs +@chapter Reporting bugs @cindex bugs @cindex getting help @@ -838,6 +838,7 @@ enum { pos_states = 1 << pos_state_bits, pos_state_mask = pos_states - 1, + len_states = 4, dis_slot_bits = 6, start_dis_model = 4, end_dis_model = 14, @@ -854,7 +855,6 @@ enum { max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols, min_match_len = 2, // must be 2 - max_dis_states = 4, bit_model_move_bits = 5, bit_model_total_bits = 11, @@ -1081,7 +1081,7 @@ bool LZ_decoder::decode_member() // Returns false if error 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< dictionary_size_) ? - pos - dictionary_size_ : 0; + const int min_pos = ( pos > dictionary_size_ ) ? pos - dictionary_size_ : 0; const uint8_t * const data = buffer + pos; unsigned tmp = crc32[data[0]] ^ data[1]; @@ -310,14 +309,14 @@ void LZ_encoder::fill_distance_prices() const int base = ( 2 | ( dis_slot & 1 ) ) << direct_bits; const int price = price_symbol_reversed( bm_dis + base - dis_slot - 1, dis - base, direct_bits ); - for( int dis_state = 0; dis_state < max_dis_states; ++dis_state ) - dis_prices[dis_state][dis] = price; + for( int len_state = 0; len_state < len_states; ++len_state ) + dis_prices[len_state][dis] = price; } - for( int dis_state = 0; dis_state < max_dis_states; ++dis_state ) + for( int len_state = 0; len_state < len_states; ++len_state ) { - int * const dsp = dis_slot_prices[dis_state]; - const Bit_model * const bmds = bm_dis_slot[dis_state]; + int * const dsp = dis_slot_prices[len_state]; + const Bit_model * const bmds = bm_dis_slot[len_state]; int slot = 0; for( ; slot < end_dis_model && slot < num_dis_slots; ++slot ) dsp[slot] = price_symbol( bmds, slot, dis_slot_bits ); @@ -325,7 +324,7 @@ void LZ_encoder::fill_distance_prices() dsp[slot] = price_symbol( bmds, slot, dis_slot_bits ) + (((( slot >> 1 ) - 1 ) - dis_align_bits ) << price_shift_bits ); - int * const dp = dis_prices[dis_state]; + int * const dp = dis_prices[len_state]; int dis = 0; for( ; dis < start_dis_model; ++dis ) dp[dis] = dsp[dis]; @@ -335,10 +334,10 @@ void LZ_encoder::fill_distance_prices() } -// Return value == number of bytes advanced (ahead). -// trials[0]..trials[ahead-1] contain the steps to encode. -// ( trials[0].dis == -1 && trials[0].price == 1 ) means literal. -// +/* Return value == number of bytes advanced (ahead). + trials[0]..trials[ahead-1] contain the steps to encode. + ( trials[0].dis == -1 && trials[0].price == 1 ) means literal. +*/ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances], const State state ) { diff --git a/encoder.h b/encoder.h index 577ceeb..725d0e8 100644 --- a/encoder.h +++ b/encoder.h @@ -427,7 +427,7 @@ protected: 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<= start_dis_model ) { @@ -560,8 +560,8 @@ class LZ_encoder : public LZ_encoder_base struct Pair pairs[max_match_len+1]; Trial trials[max_num_trials]; - int dis_slot_prices[max_dis_states][2*max_dictionary_bits]; - int dis_prices[max_dis_states][modeled_distances]; + int dis_slot_prices[len_states][2*max_dictionary_bits]; + int dis_prices[len_states][modeled_distances]; int align_prices[dis_align_size]; int align_price_count; @@ -594,19 +594,19 @@ class LZ_encoder : public LZ_encoder_base rep_len_encoder.price( len, pos_state ); } - int price_dis( const int dis, const int dis_state ) const + int price_dis( const int dis, const int len_state ) const { if( dis < modeled_distances ) - return dis_prices[dis_state][dis]; + return dis_prices[len_state][dis]; else - return dis_slot_prices[dis_state][get_slot( dis )] + + return dis_slot_prices[len_state][get_slot( dis )] + align_prices[dis & (dis_align_size - 1)]; } int price_pair( const int dis, const int len, const int pos_state ) const { return match_len_encoder.price( len, pos_state ) + - price_dis( dis, get_dis_state( len ) ); + price_dis( dis, get_len_state( len ) ); } int read_match_distances() diff --git a/lzip.h b/lzip.h index b563833..b4b51e2 100644 --- a/lzip.h +++ b/lzip.h @@ -48,6 +48,7 @@ enum { pos_states = 1 << pos_state_bits, pos_state_mask = pos_states - 1, + len_states = 4, dis_slot_bits = 6, start_dis_model = 4, end_dis_model = 14, @@ -65,12 +66,10 @@ enum { min_match_len = 2, // must be 2 max_match_len = min_match_len + max_len_symbols - 1, // 273 - min_match_len_limit = 5, + min_match_len_limit = 5 }; - max_dis_states = 4 }; - -inline int get_dis_state( const int len ) - { return std::min( len - min_match_len, max_dis_states - 1 ); } +inline int get_len_state( const int len ) + { return std::min( len - min_match_len, len_states - 1 ); } inline int get_lit_state( const uint8_t prev_byte ) { return ( prev_byte >> ( 8 - literal_context_bits ) ); } @@ -111,7 +110,7 @@ public: for( unsigned i = 0; i < filenames.size(); ++i ) { const std::string & s = filenames[i]; - const unsigned len = ( ( s == "-" ) ? stdin_name_len : s.size() ); + const unsigned len = ( s == "-" ) ? stdin_name_len : s.size(); if( len > longest_name ) longest_name = len; } if( longest_name == 0 ) longest_name = stdin_name_len; diff --git a/main.cc b/main.cc index bd5c8c9..eaa93fd 100644 --- a/main.cc +++ b/main.cc @@ -84,8 +84,8 @@ struct { const char * from; const char * to; } const known_extensions[] = { struct Lzma_options { - int dictionary_size; // 4KiB..512MiB - int match_len_limit; // 5..273 + int dictionary_size; // 4 KiB .. 512 MiB + int match_len_limit; // 5 .. 273 }; enum Mode { m_compress, m_decompress, m_test }; @@ -114,7 +114,7 @@ void show_help() " -m, --match-length= set match length limit in bytes [36]\n" " -o, --output= if reading stdin, place the output into \n" " -q, --quiet suppress all messages\n" - " -s, --dictionary-size= set dictionary size limit in bytes [8MiB]\n" + " -s, --dictionary-size= set dictionary size limit in bytes [8 MiB]\n" " -S, --volume-size= set volume size limit in bytes\n" " -t, --test test compressed file integrity\n" " -v, --verbose be verbose (a 2nd -v gives more)\n" @@ -739,8 +739,8 @@ void show_progress( const unsigned long long partial_size, int main( const int argc, const char * const argv[] ) { - // Mapping from gzip/bzip2 style 1..9 compression modes - // to the corresponding LZMA compression modes. + /* Mapping from gzip/bzip2 style 1..9 compression modes + to the corresponding LZMA compression modes. */ const Lzma_options option_mapping[] = { { 1 << 16, 16 }, // -0 entry values not used -- cgit v1.2.3