summaryrefslogtreecommitdiffstats
path: root/rc.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--rc.cc32
1 files changed, 11 insertions, 21 deletions
diff --git a/rc.cc b/rc.cc
index 5014806..308cf0c 100644
--- a/rc.cc
+++ b/rc.cc
@@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
- Copyright (C) 2009-2018 Antonio Diaz Diaz.
+ Copyright (C) 2009-2019 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ int verbosity = 0;
namespace {
const char * const config_file_name = "zutilsrc";
-const char * const program_year = "2018";
+const char * const program_year = "2019";
std::string compressor_names[num_formats] =
{ "bzip2", "gzip", "lzip", "xz" }; // default compressor names
@@ -211,8 +211,8 @@ int process_rcfile( const std::string & name )
bool enabled_format( const int format_index )
{
- if( enabled_formats.size() <= num_formats ) return true;
- if( format_index < 0 ) return enabled_formats[num_formats];
+ if( enabled_formats.size() <= num_formats ) return true; // all enabled
+ if( format_index < 0 ) return enabled_formats[num_formats]; // uncompressed
return enabled_formats[format_index];
}
@@ -336,11 +336,9 @@ void show_error( const char * const msg, const int errcode, const bool help )
{
if( verbosity < 0 ) return;
if( msg && msg[0] )
- {
- std::fprintf( stderr, "%s: %s", program_name, msg );
- if( errcode > 0 ) std::fprintf( stderr, ": %s", std::strerror( errcode ) );
- std::fputc( '\n', stderr );
- }
+ std::fprintf( stderr, "%s: %s%s%s\n", program_name, msg,
+ ( errcode > 0 ) ? ": " : "",
+ ( errcode > 0 ) ? std::strerror( errcode ) : "" );
if( help )
std::fprintf( stderr, "Try '%s --help' for more information.\n",
invocation_name );
@@ -350,18 +348,10 @@ void show_error( const char * const msg, const int errcode, const bool help )
void show_file_error( const char * const filename, const char * const msg,
const int errcode )
{
- if( verbosity < 0 ) return;
- std::fprintf( stderr, "%s: %s: %s", program_name, filename, msg );
- if( errcode > 0 ) std::fprintf( stderr, ": %s", std::strerror( errcode ) );
- std::fputc( '\n', stderr );
- }
-
-
-void show_error2( const char * const msg, const char * const name )
- {
if( verbosity >= 0 )
- std::fprintf( stderr, "%s: %s '%s': %s\n",
- program_name, msg, name, std::strerror( errno ) );
+ std::fprintf( stderr, "%s: %s: %s%s%s\n", program_name, filename, msg,
+ ( errcode > 0 ) ? ": " : "",
+ ( errcode > 0 ) ? std::strerror( errcode ) : "" );
}
@@ -376,7 +366,7 @@ void internal_error( const char * const msg )
void show_close_error( const char * const prog_name )
{
if( verbosity >= 0 )
- std::fprintf( stderr, "%s: Can't close output of %s: %s\n",
+ std::fprintf( stderr, "%s: Error closing output of %s: %s\n",
program_name, prog_name, std::strerror( errno ) );
}