summaryrefslogtreecommitdiffstats
path: root/zcat.cc
diff options
context:
space:
mode:
Diffstat (limited to 'zcat.cc')
-rw-r--r--zcat.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/zcat.cc b/zcat.cc
index 02473f0..2a72364 100644
--- a/zcat.cc
+++ b/zcat.cc
@@ -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, zst)\n"
+ " -O, --force-format=<fmt> force the input format\n"
" -q, --quiet suppress all messages\n"
" -r, --recursive operate recursively on directories\n"
" -R, --dereference-recursive recursively follow symbolic links\n"
@@ -128,7 +128,9 @@ void show_help()
" --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"
- " --zst=<command> set compressor and options for zstd format\n" );
+ " --zst=<command> set compressor and options for zstd format\n"
+ "\nValid formats for options '-M' and '-O' are 'bz2', 'gz', 'lz', 'xz', 'zst',\n"
+ "and 'un' for uncompressed.\n" );
show_help_addr();
}
@@ -235,10 +237,10 @@ bool cat( int infd, const int format_index, const std::string & input_filename,
enum { buffer_size = 4096, outbuf_size = (5 * buffer_size) + 256 + 1 };
// input buffer with space for sentinel newline at the end
uint8_t * const inbuf = new uint8_t[buffer_size+1];
- // output buffer with space for character quoting, 255-digit line number,
- // worst case flushing respect to inbuf, and a canary byte.
+ /* output buffer with space for character quoting, 255-digit line number,
+ worst case flushing respect to inbuf, and a canary byte. */
uint8_t * const outbuf = new uint8_t[outbuf_size];
- outbuf[outbuf_size-1] = 0;
+ outbuf[outbuf_size-1] = 0; // canary byte; quoting does not print 0
Children children;
bool error = false;
@@ -258,7 +260,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, zst_opt };
- int format_index = -1;
+ int format_index = -1; // undefined
int recursive = 0; // 1 = '-r', 2 = '-R'
std::list< std::string > filenames;
Cat_options cat_options;
@@ -338,11 +340,11 @@ int main( const int argc, const char * const argv[] )
case 'v': cat_options.show_nonprinting = true; break;
case 'V': show_version(); return 0;
case verbose_opt: if( verbosity < 4 ) ++verbosity; break;
- case bz2_opt: parse_compressor( arg, fmt_bz2, 1 ); break;
- 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;
+ case bz2_opt: parse_compressor( arg, pn, fmt_bz2, 1 ); break;
+ case gz_opt: parse_compressor( arg, pn, fmt_gz, 1 ); break;
+ case lz_opt: parse_compressor( arg, pn, fmt_lz, 1 ); break;
+ case xz_opt: parse_compressor( arg, pn, fmt_xz, 1 ); break;
+ case zst_opt: parse_compressor( arg, pn, fmt_zst, 1 ); break;
default : internal_error( "uncaught option." );
}
} // end process options