summaryrefslogtreecommitdiffstats
path: root/zcat.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-02-03 11:13:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-02-03 11:13:44 +0000
commit50250d834c659e3593397cc6ee691d7efc721643 (patch)
treeb7f3fe28e142413de4866c7a314da8e53827c3f8 /zcat.cc
parentReleasing debian version 1.10-2. (diff)
downloadzutils-50250d834c659e3593397cc6ee691d7efc721643.tar.xz
zutils-50250d834c659e3593397cc6ee691d7efc721643.zip
Merging upstream version 1.11.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'zcat.cc')
-rw-r--r--zcat.cc32
1 files changed, 18 insertions, 14 deletions
diff --git a/zcat.cc b/zcat.cc
index 62b93aa..02473f0 100644
--- a/zcat.cc
+++ b/zcat.cc
@@ -1,5 +1,5 @@
/* Zcat - decompress and concatenate files to standard output
- Copyright (C) 2010-2021 Antonio Diaz Diaz.
+ Copyright (C) 2010-2022 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
@@ -31,7 +31,7 @@
#include <stdint.h>
#include <unistd.h>
#include <sys/stat.h>
-#if defined(__MSVCRT__) || defined(__OS2__)
+#if defined __MSVCRT__ || defined __OS2__
#include <io.h>
#endif
@@ -102,7 +102,7 @@ void show_help()
"same compressed format.\n"
"\nIf no files are specified, recursive searches examine the current\n"
"working directory, and nonrecursive searches read standard input.\n"
- "\nThe formats supported are bzip2, gzip, lzip, and xz.\n"
+ "\nThe formats supported are bzip2, gzip, lzip, xz, and zstd.\n"
"\nUsage: zcat [options] [files]\n"
"\nExit status is 0 if no errors occurred, 1 otherwise.\n"
"\nOptions:\n"
@@ -115,7 +115,7 @@ void show_help()
" -M, --format=<list> process only the formats in <list>\n"
" -n, --number number all output lines\n"
" -N, --no-rcfile don't read runtime configuration file\n"
- " -O, --force-format=<fmt> force the format given (bz2, gz, lz, xz)\n"
+ " -O, --force-format=<fmt> force the format given (bz2, gz, lz, xz, zst)\n"
" -q, --quiet suppress all messages\n"
" -r, --recursive operate recursively on directories\n"
" -R, --dereference-recursive recursively follow symbolic links\n"
@@ -127,7 +127,8 @@ void show_help()
" --bz2=<command> set compressor and options for bzip2 format\n"
" --gz=<command> set compressor and options for gzip format\n"
" --lz=<command> set compressor and options for lzip format\n"
- " --xz=<command> set compressor and options for xz format\n" );
+ " --xz=<command> set compressor and options for xz format\n"
+ " --zst=<command> set compressor and options for zstd format\n" );
show_help_addr();
}
@@ -256,7 +257,7 @@ bool cat( int infd, const int format_index, const std::string & input_filename,
int main( const int argc, const char * const argv[] )
{
- enum { verbose_opt = 256, bz2_opt, gz_opt, lz_opt, xz_opt };
+ enum { verbose_opt = 256, bz2_opt, gz_opt, lz_opt, xz_opt, zst_opt };
int format_index = -1;
int recursive = 0; // 1 = '-r', 2 = '-R'
std::list< std::string > filenames;
@@ -289,11 +290,12 @@ int main( const int argc, const char * const argv[] )
{ 'v', "show-nonprinting", Arg_parser::no }, // cat
{ 'V', "version", Arg_parser::no },
{ verbose_opt, "verbose", Arg_parser::no },
- { bz2_opt, "bz2", Arg_parser::yes },
- { gz_opt, "gz", Arg_parser::yes },
- { lz_opt, "lz", Arg_parser::yes },
- { xz_opt, "xz", Arg_parser::yes },
- { 0 , 0, Arg_parser::no } };
+ { bz2_opt, "bz2", Arg_parser::yes },
+ { gz_opt, "gz", Arg_parser::yes },
+ { lz_opt, "lz", Arg_parser::yes },
+ { xz_opt, "xz", Arg_parser::yes },
+ { zst_opt, "zst", Arg_parser::yes },
+ { 0, 0, Arg_parser::no } };
const Arg_parser parser( argc, argv, options );
if( parser.error().size() ) // bad option
@@ -306,6 +308,7 @@ int main( const int argc, const char * const argv[] )
{
const int code = parser.code( argind );
if( !code ) break; // no more options
+ const char * const pn = parser.parsed_name( argind ).c_str();
const std::string & arg = parser.argument( argind );
switch( code )
{
@@ -321,11 +324,11 @@ int main( const int argc, const char * const argv[] )
case 'h': show_help(); return 0;
case 'l': break;
case 'L': break;
- case 'M': parse_format_list( arg ); break;
+ case 'M': parse_format_list( arg, pn ); break;
case 'n': if( cat_options.number_lines == 0 )
{ cat_options.number_lines = 2; } break;
case 'N': break;
- case 'O': format_index = parse_format_type( arg ); break;
+ case 'O': format_index = parse_format_type( arg, pn ); break;
case 'q': verbosity = -1; break;
case 'r': recursive = 1; break;
case 'R': recursive = 2; break;
@@ -339,11 +342,12 @@ int main( const int argc, const char * const argv[] )
case gz_opt: parse_compressor( arg, fmt_gz, 1 ); break;
case lz_opt: parse_compressor( arg, fmt_lz, 1 ); break;
case xz_opt: parse_compressor( arg, fmt_xz, 1 ); break;
+ case zst_opt: parse_compressor( arg, fmt_zst, 1 ); break;
default : internal_error( "uncaught option." );
}
} // end process options
-#if defined(__MSVCRT__) || defined(__OS2__)
+#if defined __MSVCRT__ || defined __OS2__
setmode( STDIN_FILENO, O_BINARY );
setmode( STDOUT_FILENO, O_BINARY );
#endif