summaryrefslogtreecommitdiffstats
path: root/rc.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-04-10 15:19:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-04-10 15:19:00 +0000
commit6e01d7d8f65270f174ed4f161a5292aa5b89be0c (patch)
treeb73c1aad1d4cf13aad03fb2764f8123f266d27b4 /rc.cc
parentReleasing debian version 1.5-5. (diff)
downloadzutils-6e01d7d8f65270f174ed4f161a5292aa5b89be0c.tar.xz
zutils-6e01d7d8f65270f174ed4f161a5292aa5b89be0c.zip
Merging upstream version 1.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rc.cc')
-rw-r--r--rc.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/rc.cc b/rc.cc
index 2326465..9af190d 100644
--- a/rc.cc
+++ b/rc.cc
@@ -1,5 +1,5 @@
/* Zutils - Utilities dealing with compressed files
- Copyright (C) 2009-2016 Antonio Diaz Diaz.
+ Copyright (C) 2009-2017 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 = "2016";
+const char * const program_year = "2017";
std::string compressor_names[num_formats] =
{ "bzip2", "gzip", "lzip", "xz" }; // default compressor names
@@ -49,7 +49,7 @@ std::vector< std::string > compressor_args[num_formats];
// empty means all enabled.
std::vector< bool > enabled_formats;
-struct { const char * from; const char * to; int format_index; } const
+const struct { const char * from; const char * to; int format_index; }
known_extensions[] = {
{ ".bz2", "", fmt_bz2 },
{ ".tbz", ".tar", fmt_bz2 },
@@ -253,12 +253,12 @@ int parse_format_type( const std::string & arg )
int extension_index( const std::string & name )
{
- for( int i = 0; known_extensions[i].from; ++i )
+ for( int eindex = 0; known_extensions[eindex].from; ++eindex )
{
- const std::string ext( known_extensions[i].from );
+ const std::string ext( known_extensions[eindex].from );
if( name.size() > ext.size() &&
name.compare( name.size() - ext.size(), ext.size(), ext ) == 0 )
- return i;
+ return eindex;
}
return -1;
}
@@ -347,6 +347,16 @@ 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 )