diff options
Diffstat (limited to '')
-rw-r--r-- | main.cc | 46 |
1 files changed, 25 insertions, 21 deletions
@@ -25,12 +25,13 @@ #include <cctype> #include <cerrno> +#include <climits> // CHAR_BIT #include <cstdarg> #include <cstdio> #include <ctime> #include <fcntl.h> -#include <pthread.h> // for pthread_t -#include <stdint.h> // for lzlib.h +#include <pthread.h> // for pthread_t +#include <stdint.h> // for lzlib.h #include <unistd.h> #include <sys/stat.h> #include <grp.h> @@ -140,14 +141,28 @@ void show_help( const long num_online ) } +void show_lzlib_version() + { + std::printf( "Using lzlib %s\n", LZ_version() ); +#if !defined LZ_API_VERSION + std::fputs( "LZ_API_VERSION is not defined.\n", stdout ); +#elif LZ_API_VERSION >= 1012 + std::printf( "Using LZ_API_VERSION = %u\n", LZ_api_version() ); +#else + std::printf( "Compiled with LZ_API_VERSION = %u. " + "Using an unknown LZ_API_VERSION\n", LZ_API_VERSION ); +#endif + } + + void show_version() { std::printf( "%s %s\n", program_name, PROGVERSION ); std::printf( "Copyright (C) %s Antonio Diaz Diaz.\n", program_year ); - std::printf( "Using lzlib %s\n", LZ_version() ); std::printf( "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n" ); + show_lzlib_version(); } @@ -193,18 +208,7 @@ int check_lib() std::printf( "warning: LZ_API_VERSION != LZ_api_version() (%u vs %u)\n", LZ_API_VERSION, LZ_api_version() ); } #endif - if( verbosity >= 1 ) - { - std::printf( "Using lzlib %s\n", LZ_version() ); -#if !defined LZ_API_VERSION - std::fputs( "LZ_API_VERSION is not defined.\n", stdout ); -#elif LZ_API_VERSION >= 1012 - std::printf( "Using LZ_API_VERSION = %u\n", LZ_api_version() ); -#else - std::printf( "Compiled with LZ_API_VERSION = %u. " - "Using an unknown LZ_API_VERSION\n", LZ_API_VERSION ); -#endif - } + if( verbosity >= 1 ) show_lzlib_version(); return retval; } @@ -222,7 +226,7 @@ const char * format_num3( long long num ) char * p = buf + bufsize - 1; // fill the buffer backwards *p = 0; // terminator const bool negative = num < 0; - if( num > 1024 || num < -1024 ) + if( num > 9999 || num < -9999 ) { char prefix = 0; // try binary first, then si for( int i = 0; i < n && num != 0 && num % 1024 == 0; ++i ) @@ -269,7 +273,7 @@ long long getnum( const char * const arg, const char * const option_name, if( !errno && tail[0] ) { - const int factor = ( tail[1] == 'i' ) ? 1024 : 1000; + const int factor = (tail[1] == 'i') ? 1024 : 1000; int exponent = 0; // 0 = bad multiplier switch( tail[0] ) { @@ -354,8 +358,8 @@ long long parse_mtime( const char * arg, const char * const pn ) { struct tm t; t.tm_year = y - 1900; t.tm_mon = mo - 1; t.tm_mday = d; - t.tm_hour = ( n >= 5 ) ? h : 0; t.tm_min = ( n >= 6 ) ? m : 0; - t.tm_sec = ( n >= 7 ) ? s : 0; t.tm_isdst = -1; + t.tm_hour = (n >= 5) ? h : 0; t.tm_min = (n >= 6) ? m : 0; + t.tm_sec = (n >= 7) ? s : 0; t.tm_isdst = -1; errno = 0; const long long mtime = std::mktime( &t ); if( mtime != -1 || errno == 0 ) return mtime; // valid datetime @@ -396,7 +400,7 @@ int hstat( const char * const filename, struct stat * const st, bool nonempty_arg( const Arg_parser & parser, const int i ) - { return ( parser.code( i ) == 0 && !parser.argument( i ).empty() ); } + { return parser.code( i ) == 0 && !parser.argument( i ).empty(); } int open_instream( const std::string & name ) @@ -582,7 +586,7 @@ int main( const int argc, const char * const argv[] ) { opt_sol, "solid", Arg_parser::no }, { opt_un, "uncompressed", Arg_parser::no }, { opt_wn, "warn-newer", Arg_parser::no }, - { 0, 0, Arg_parser::no } }; + { 0, 0, Arg_parser::no } }; const Arg_parser parser( argc, argv, options, true ); // in_order if( parser.error().size() ) // bad option |