summaryrefslogtreecommitdiffstats
path: root/zcat.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:26:56 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:26:56 +0000
commitd7d5dfbcf513f94115990102c56eccf177417889 (patch)
tree7b47cf460832a31d6e0c34444e7bf1cddacfd02f /zcat.cc
parentAdding debian version 1.0-1. (diff)
downloadzutils-d7d5dfbcf513f94115990102c56eccf177417889.tar.xz
zutils-d7d5dfbcf513f94115990102c56eccf177417889.zip
Merging upstream version 1.1~rc2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zcat.cc')
-rw-r--r--zcat.cc29
1 files changed, 17 insertions, 12 deletions
diff --git a/zcat.cc b/zcat.cc
index 42e821e..366a860 100644
--- a/zcat.cc
+++ b/zcat.cc
@@ -61,7 +61,7 @@ Line_number line_number;
void show_zcat_help()
{
std::printf( "Zcat copies each given file (\"-\" means standard input), to standard\n"
- "output. If any given file is compressed, its uncompressed content is\n"
+ "output. If any given file is compressed, its decompressed content is\n"
"used. If a given file does not exist, and its name does not end with one\n"
"of the known extensions, zcat tries the compressed file names\n"
"corresponding to the supported formats. If no files are specified,\n"
@@ -70,7 +70,7 @@ void show_zcat_help()
"all uncompressed or all in the same compression format.\n"
"\nThe supported formats are bzip2, gzip, lzip and xz.\n"
"\nUsage: zcat [options] [files]\n"
- "\nExit status is 0 if no errors occurred, 1 otherwise.\n"
+ "\nExit status is 0 if no errors occurred, non-zero otherwise.\n"
"\nOptions:\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
@@ -80,13 +80,18 @@ void show_zcat_help()
" -E, --show-ends display '$' at end of each line\n"
" --format=<fmt> force given format (bz2, gz, lz, xz)\n"
" -n, --number number all output lines\n"
+ " -N, --no-rcfile don't read runtime configuration file\n"
" -q, --quiet suppress all messages\n"
" -r, --recursive operate recursively on directories\n"
" -s, --squeeze-blank never more than one single blank line\n"
" -t equivalent to '-vT'\n"
" -T, --show-tabs display TAB characters as '^I'\n"
" -v, --show-nonprinting use '^' and 'M-' notation, except for LF and TAB\n"
- " --verbose verbose mode (show error messages)\n" );
+ " --verbose verbose mode (show error messages)\n"
+ " --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" );
show_help_addr();
}
@@ -187,7 +192,7 @@ int do_cat( const int infd, const int buffer_size,
}
-int cat( int infd, const int format_type, const std::string & input_filename,
+int cat( int infd, const int format_index, const std::string & input_filename,
const Cat_options & cat_options )
{
enum { buffer_size = 4096 };
@@ -195,17 +200,17 @@ int cat( int infd, const int format_type, const std::string & input_filename,
uint8_t * const inbuf = new uint8_t[buffer_size+1];
// buffer with space for character quoting and 255-digit line number
uint8_t * const outbuf = new uint8_t[(4*buffer_size)+256];
- pid_t pid = 0;
int retval = 0;
- if( !set_data_feeder( &infd, &pid, format_type ) ) retval = 1;
+ Children children;
+ if( !set_data_feeder( &infd, children, format_index ) ) retval = 1;
else
retval = do_cat( infd, buffer_size, inbuf, outbuf,
input_filename, cat_options );
- if( retval == 0 )
- if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 1;
- if( retval == 0 )
- if( close( infd ) != 0 )
- { show_close_error( "data feeder" ); retval = 1; }
- delete[] inbuf; delete[] outbuf;
+
+ if( !good_status( children, retval == 0 ) ) retval = 1;
+
+ if( retval == 0 && close( infd ) != 0 )
+ { show_close_error( "data feeder" ); retval = 1; }
+ delete[] outbuf; delete[] inbuf;
return retval;
}