From 03a774e06a09b1a974d2ba2a04c129f1daca92f3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 11:06:37 +0100 Subject: Merging upstream version 1.17~rc1. Signed-off-by: Daniel Baumann --- main.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'main.cc') diff --git a/main.cc b/main.cc index 6b5c430..1fc42de 100644 --- a/main.cc +++ b/main.cc @@ -184,7 +184,7 @@ unsigned long long getnum( const char * const ptr, if( !errno && tail[0] ) { - int factor = ( tail[1] == 'i' ) ? 1024 : 1000; + const int factor = ( tail[1] == 'i' ) ? 1024 : 1000; int exponent = 0; bool bad_multiplier = false; switch( tail[0] ) @@ -431,12 +431,12 @@ int compress( const unsigned long long member_size, else { File_header header; - if( !header.dictionary_size( encoder_options.dictionary_size ) || - encoder_options.match_len_limit < min_match_len_limit || - encoder_options.match_len_limit > max_match_len ) - internal_error( "invalid argument to encoder." ); - encoder = new LZ_encoder( header.dictionary_size(), - encoder_options.match_len_limit, infd, outfd ); + if( header.dictionary_size( encoder_options.dictionary_size ) && + encoder_options.match_len_limit >= min_match_len_limit && + encoder_options.match_len_limit <= max_match_len ) + encoder = new LZ_encoder( header.dictionary_size(), + encoder_options.match_len_limit, infd, outfd ); + else internal_error( "invalid argument to encoder." ); } unsigned long long in_size = 0, out_size = 0, partial_volume_size = 0; @@ -746,14 +746,15 @@ int main( const int argc, const char * const argv[] ) { const int code = parser.code( argind ); if( !code ) break; /* no more options */ - const char * const arg = parser.argument( argind ).c_str(); + const std::string & arg = parser.argument( argind ); switch( code ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': zero = ( code == '0' ); encoder_options = option_mapping[code-'0']; break; - case 'b': member_size = getnum( arg, 100000, max_member_size ); break; + case 'b': member_size = getnum( arg.c_str(), 100000, max_member_size ); + break; case 'c': to_stdout = true; break; case 'd': program_mode = m_decompress; break; case 'f': force = true; break; @@ -761,14 +762,15 @@ int main( const int argc, const char * const argv[] ) case 'h': show_help(); return 0; case 'k': keep_input_files = true; break; case 'm': encoder_options.match_len_limit = - getnum( arg, min_match_len_limit, max_match_len ); + getnum( arg.c_str(), min_match_len_limit, max_match_len ); zero = false; break; case 'n': break; case 'o': default_output_filename = arg; break; case 'q': verbosity = -1; break; - case 's': encoder_options.dictionary_size = get_dict_size( arg ); + case 's': encoder_options.dictionary_size = get_dict_size( arg.c_str() ); zero = false; break; - case 'S': volume_size = getnum( arg, 100000, max_volume_size ); break; + case 'S': volume_size = getnum( arg.c_str(), 100000, max_volume_size ); + break; case 't': program_mode = m_test; break; case 'v': if( verbosity < 4 ) ++verbosity; break; case 'V': show_version(); return 0; -- cgit v1.2.3