Merging upstream version 1.5.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
3a44ca3665
commit
060bb99151
30 changed files with 328 additions and 279 deletions
35
rc.cc
35
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 );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue