summaryrefslogtreecommitdiffstats
path: root/rc.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-05-20 06:48:30 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-05-20 06:49:00 +0000
commit4d364776fc785a234cebba08bc93cd06202103dd (patch)
tree90476b30bb959b780c85efc2ab546a5b5e970f2c /rc.cc
parentReleasing debian version 1.4-2. (diff)
downloadzutils-4d364776fc785a234cebba08bc93cd06202103dd.tar.xz
zutils-4d364776fc785a234cebba08bc93cd06202103dd.zip
Merging upstream version 1.5.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'rc.cc')
-rw-r--r--rc.cc35
1 files changed, 16 insertions, 19 deletions
diff --git a/rc.cc b/rc.cc
index 1376655..2326465 100644
--- a/rc.cc
+++ b/rc.cc
@@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
- Copyright (C) 2009-2015 Antonio Diaz Diaz.
+ Copyright (C) 2009-2016 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 = "2015";
+const char * const program_year = "2016";
std::string compressor_names[num_formats] =
{ "bzip2", "gzip", "lzip", "xz" }; // default compressor names
@@ -173,7 +173,7 @@ bool parse_rc_line( const std::string & line,
while( i < len && std::isspace( line[i] ) ) ++i; // strip spaces
if( i <= 0 || i >= len || line[i] != '=' )
{ if( verbosity >= 0 )
- std::fprintf( stderr, "%s %d: missing '='.\n", filename, linenum );
+ std::fprintf( stderr, "%s %d: missing '='\n", filename, linenum );
return false; }
++i; // skip the '='
if( !parse_compressor_command( line, i, format_index ) )
@@ -334,26 +334,23 @@ void show_version()
void show_error( const char * const msg, const int errcode, const bool help )
{
- if( verbosity >= 0 )
+ if( verbosity < 0 ) return;
+ if( msg && msg[0] )
{
- if( msg && msg[0] )
- {
- std::fprintf( stderr, "%s: %s", program_name, msg );
- if( errcode > 0 )
- std::fprintf( stderr, ": %s.", std::strerror( errcode ) );
- std::fprintf( stderr, "\n" );
- }
- if( help )
- std::fprintf( stderr, "Try '%s --help' for more information.\n",
- invocation_name );
+ std::fprintf( stderr, "%s: %s", program_name, msg );
+ if( errcode > 0 ) std::fprintf( stderr, ": %s", std::strerror( errcode ) );
+ std::fputc( '\n', stderr );
}
+ if( help )
+ std::fprintf( stderr, "Try '%s --help' for more information.\n",
+ invocation_name );
}
void show_error2( const char * const msg, const char * const name )
{
if( verbosity >= 0 )
- std::fprintf( stderr, "%s: %s '%s': %s.\n",
+ std::fprintf( stderr, "%s: %s '%s': %s\n",
program_name, msg, name, std::strerror( errno ) );
}
@@ -369,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: Can't close output of %s: %s\n",
program_name, prog_name, std::strerror( errno ) );
}
@@ -377,7 +374,7 @@ void show_close_error( const char * const prog_name )
void show_exec_error( const char * const prog_name )
{
if( verbosity >= 0 )
- std::fprintf( stderr, "%s: Can't exec '%s': %s.\n",
+ std::fprintf( stderr, "%s: Can't exec '%s': %s\n",
program_name, prog_name, std::strerror( errno ) );
}
@@ -385,7 +382,7 @@ void show_exec_error( const char * const prog_name )
void show_fork_error( const char * const prog_name )
{
if( verbosity >= 0 )
- std::fprintf( stderr, "%s: Can't fork '%s': %s.\n",
+ std::fprintf( stderr, "%s: Can't fork '%s': %s\n",
program_name, prog_name, std::strerror( errno ) );
}
@@ -399,7 +396,7 @@ int wait_for_child( const pid_t pid, const char * const name,
if( errno != EINTR )
{
if( verbosity >= 0 )
- std::fprintf( stderr, "%s: Error waiting termination of '%s': %s.\n",
+ std::fprintf( stderr, "%s: Error waiting termination of '%s': %s\n",
program_name, name, std::strerror( errno ) );
_exit( eretval );
}