diff options
Diffstat (limited to '')
-rw-r--r-- | main.cc | 44 |
1 files changed, 24 insertions, 20 deletions
@@ -82,8 +82,8 @@ struct { const char * from; const char * to; } const known_extensions[] = { struct Lzma_options { - int dictionary_size; // 4 KiB .. 512 MiB - 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 }; @@ -116,8 +116,8 @@ void show_help( const long num_online ) " -s, --dictionary-size=<bytes> set dictionary size limit in bytes [8 MiB]\n" " -t, --test test compressed file integrity\n" " -v, --verbose be verbose (a 2nd -v gives more)\n" - " -1 .. -9 set compression level [default 6]\n" - " --fast alias for -1\n" + " -0 .. -9 set compression level [default 6]\n" + " --fast alias for -0\n" " --best alias for -9\n", num_online ); if( verbosity >= 1 ) { @@ -385,14 +385,14 @@ void cleanup_and_fail( const int retval ) namespace { - // Set permissions, owner and times. + /* Set permissions, owner and times. */ void close_and_set_permissions( const struct stat * const in_statsp ) { bool warning = false; if( in_statsp ) { const mode_t mode = in_statsp->st_mode; - // fchown will in many cases return with EPERM, which can be safely ignored. + /* fchown will in many cases return with EPERM, which can be safely ignored. */ if( fchown( outfd, in_statsp->st_uid, in_statsp->st_gid ) == 0 ) { if( fchmod( outfd, mode ) != 0 ) warning = true; } else @@ -482,7 +482,7 @@ void show_progress( const int packet_size, const Pretty_print * const p, const unsigned long long cfile_size ) { - static unsigned long long csize = 0; // file_size / 100 + static unsigned long long csize = 0; /* file_size / 100 */ static unsigned long long pos = 0; static const Pretty_print * pp = 0; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; @@ -511,16 +511,16 @@ int main( const int argc, const char * const argv[] ) to the corresponding LZMA compression modes. */ const Lzma_options option_mapping[] = { - { 1 << 20, 5 }, // -0 - { 1 << 20, 5 }, // -1 - { 3 << 19, 6 }, // -2 - { 1 << 21, 8 }, // -3 - { 3 << 20, 12 }, // -4 - { 1 << 22, 20 }, // -5 - { 1 << 23, 36 }, // -6 - { 1 << 24, 68 }, // -7 - { 3 << 23, 132 }, // -8 - { 1 << 25, 273 } }; // -9 + { 65535, 16 }, /* -0 */ + { 1 << 20, 5 }, /* -1 */ + { 3 << 19, 6 }, /* -2 */ + { 1 << 21, 8 }, /* -3 */ + { 3 << 20, 12 }, /* -4 */ + { 1 << 22, 20 }, /* -5 */ + { 1 << 23, 36 }, /* -6 */ + { 1 << 24, 68 }, /* -7 */ + { 3 << 23, 132 }, /* -8 */ + { 1 << 25, 273 } }; /* -9 */ Lzma_options encoder_options = option_mapping[6]; // default = "-6" std::string input_filename; std::string default_output_filename; @@ -584,7 +584,7 @@ int main( const int argc, const char * const argv[] ) for( ; argind < parser.arguments(); ++argind ) { const int code = parser.code( argind ); - if( !code ) break; // no more options + if( !code ) break; /* no more options */ const char * const arg = parser.argument( argind ).c_str(); switch( code ) { @@ -615,7 +615,7 @@ int main( const int argc, const char * const argv[] ) case 'V': show_version(); return 0; default : internal_error( "uncaught option." ); } - } // end process options + } /* end process options */ #if defined(__MSVCRT__) || defined(__OS2__) setmode( STDIN_FILENO, O_BINARY ); @@ -626,7 +626,11 @@ int main( const int argc, const char * const argv[] ) outfd = -1; if( data_size <= 0 ) - data_size = 2 * std::max( 65536, encoder_options.dictionary_size ); + { + if( encoder_options.dictionary_size == 65535 && + encoder_options.match_len_limit == 16 ) data_size = 1 << 20; + else data_size = 2 * std::max( 65536, encoder_options.dictionary_size ); + } else if( data_size < encoder_options.dictionary_size ) encoder_options.dictionary_size = std::max( data_size, LZ_min_dictionary_size() ); |