summaryrefslogtreecommitdiffstats
path: root/rc.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-05-20 06:48:08 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-05-20 06:48:08 +0000
commit54ee6afc95073460b77bfa6b84550f94bb1a39b5 (patch)
treedca863df8c71f8323c1df714b02814eaaf858ba5 /rc.cc
parentAdding upstream version 1.4. (diff)
downloadzutils-54ee6afc95073460b77bfa6b84550f94bb1a39b5.tar.xz
zutils-54ee6afc95073460b77bfa6b84550f94bb1a39b5.zip
Adding upstream version 1.5.upstream/1.5
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-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 );
}