From 6c7f7b2ed08fa742632ec389c9c7852e629c7bf2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 8 Nov 2015 05:40:27 +0100 Subject: Adding upstream version 1.4~pre2. Signed-off-by: Daniel Baumann --- zcmp.cc | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'zcmp.cc') diff --git a/zcmp.cc b/zcmp.cc index 8625833..365e76b 100644 --- a/zcmp.cc +++ b/zcmp.cc @@ -1,5 +1,5 @@ /* Zcmp - decompress and compare two files byte by byte - Copyright (C) 2010-2014 Antonio Diaz Diaz. + Copyright (C) 2010-2015 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 @@ -68,21 +68,22 @@ void show_help() " standard input.\n" "\nExit status is 0 if inputs are identical, 1 if different, 2 if trouble.\n" "\nOptions:\n" - " -h, --help display this help and exit\n" - " -V, --version output version information and exit\n" - " -b, --print-bytes print differing bytes\n" - " --format=[][,] force given formats (bz2, gz, lz, xz)\n" - " -i, --ignore-initial=[,] ignore differences in the first bytes\n" - " -l, --list list position, value of all differing bytes\n" - " -n, --bytes= compare at most bytes\n" - " -N, --no-rcfile don't read runtime configuration file\n" - " -q, --quiet suppress all messages\n" - " -s, --silent (same as --quiet)\n" - " -v, --verbose verbose mode (same as --list)\n" - " --bz2= set compressor and options for bzip2 format\n" - " --gz= set compressor and options for gzip format\n" - " --lz= set compressor and options for lzip format\n" - " --xz= set compressor and options for xz format\n" + " -h, --help display this help and exit\n" + " -V, --version output version information and exit\n" + " -b, --print-bytes print differing bytes\n" + " -i, --ignore-initial=[,] ignore differences in the first bytes\n" + " -l, --list list position, value of all differing bytes\n" + " -M, --format= exclude formats not in \n" + " -n, --bytes= compare at most bytes\n" + " -N, --no-rcfile don't read runtime configuration file\n" + " -O, --force-format=[][,] force given formats (bz2, gz, lz, xz)\n" + " -q, --quiet suppress all messages\n" + " -s, --silent (same as --quiet)\n" + " -v, --verbose verbose mode (same as --list)\n" + " --bz2= set compressor and options for bzip2 format\n" + " --gz= set compressor and options for gzip format\n" + " --lz= set compressor and options for lzip format\n" + " --xz= set compressor and options for xz format\n" "Numbers may be followed by a multiplier: k = kB = 10^3 = 1000,\n" "Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...\n" ); show_help_addr(); @@ -311,7 +312,7 @@ int cmp( const long long max_size, const int infd[2], int main( const int argc, const char * const argv[] ) { - enum { format_opt = 256, bz2_opt, gz_opt, lz_opt, xz_opt }; + enum { bz2_opt = 256, gz_opt, lz_opt, xz_opt }; // number of initial bytes ignored for each file long long ignore_initial[2] = { 0, 0 }; long long max_size = -1; // < 0 means unlimited size @@ -326,13 +327,14 @@ int main( const int argc, const char * const argv[] ) { 'h', "help", Arg_parser::no }, { 'i', "ignore-initial", Arg_parser::yes }, { 'l', "list", Arg_parser::no }, + { 'M', "format", Arg_parser::yes }, { 'n', "bytes", Arg_parser::yes }, { 'N', "no-rcfile", Arg_parser::no }, + { 'O', "force-format", Arg_parser::yes }, { 'q', "quiet", Arg_parser::no }, { 's', "silent", Arg_parser::no }, { 'v', "verbose", Arg_parser::no }, { 'V', "version", Arg_parser::no }, - { format_opt, "format", Arg_parser::yes }, { bz2_opt, "bz2", Arg_parser::yes }, { gz_opt, "gz", Arg_parser::yes }, { lz_opt, "lz", Arg_parser::yes }, @@ -350,20 +352,21 @@ int main( const int argc, const char * const argv[] ) { const int code = parser.code( argind ); if( !code ) break; // no more options - const char * const arg = parser.argument( argind ).c_str(); + const std::string & arg = parser.argument( argind ); switch( code ) { case 'b': print_bytes = true; break; case 'h': show_help(); return 0; - case 'i': parse_ignore_initial( arg, ignore_initial ); break; + case 'i': parse_ignore_initial( arg.c_str(), ignore_initial ); break; case 'l': verbosity = 1; break; - case 'n': max_size = getnum( arg ); break; + case 'M': parse_format_list( arg ); break; + case 'n': max_size = getnum( arg.c_str() ); break; case 'N': break; + case 'O': parse_format_types2( arg, format_types ); break; case 'q': case 's': verbosity = -1; break; case 'v': verbosity = 1; break; case 'V': show_version(); return 0; - case format_opt: parse_format_types( arg, format_types ); break; case bz2_opt: parse_compressor( arg, fmt_bz2 ); break; case gz_opt: parse_compressor( arg, fmt_gz ); break; case lz_opt: parse_compressor( arg, fmt_lz ); break; -- cgit v1.2.3