summaryrefslogtreecommitdiffstats
path: root/main.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:06:25 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:06:25 +0000
commitcbcc47a0b7c19d9fe1e73a07860a7c10739a9d1c (patch)
tree5bf33f510fd297a75e361729c74fdfffb72b54e6 /main.cc
parentAdding upstream version 1.17~pre1. (diff)
downloadlzip-cbcc47a0b7c19d9fe1e73a07860a7c10739a9d1c.tar.xz
lzip-cbcc47a0b7c19d9fe1e73a07860a7c10739a9d1c.zip
Adding upstream version 1.17~rc1.upstream/1.17_rc1
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--main.cc26
1 files changed, 14 insertions, 12 deletions
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;