From ae26a497b6a3b9948872ee9bd41b2484b0e05c94 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 10 Apr 2017 17:18:05 +0200 Subject: Adding upstream version 1.6. Signed-off-by: Daniel Baumann --- zdiff.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'zdiff.cc') diff --git a/zdiff.cc b/zdiff.cc index 26a7365..735eb0b 100644 --- a/zdiff.cc +++ b/zdiff.cc @@ -1,5 +1,5 @@ /* Zdiff - decompress and compare two files line by line - Copyright (C) 2010-2016 Antonio Diaz Diaz. + Copyright (C) 2010-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 @@ -55,14 +55,14 @@ void show_help() "temporary filenames instead of those specified.\n" "\nThe supported formats are bzip2, gzip, lzip and xz.\n" "\nUsage: zdiff [options] file1 [file2]\n" - "\nCompares to . If is omitted zdiff tries the\n" + "\nZdiff compares file1 to file2. If file2 is omitted zdiff tries the\n" "following:\n" - "\n 1. If is compressed, compares its decompressed contents with\n" - " the corresponding uncompressed file (the name of with the\n" + "\n 1. If file1 is compressed, compares its decompressed contents with\n" + " the corresponding uncompressed file (the name of file1 with the\n" " extension removed).\n" - "\n 2. If is uncompressed, compares it with the decompressed\n" - " contents of .[lz|bz2|gz|xz] (the first one that is found).\n" - "\n 3. If no suitable file is found, compares with data read from\n" + "\n 2. If file1 is uncompressed, compares it with the decompressed\n" + " contents of file1.[lz|bz2|gz|xz] (the first one that is found).\n" + "\n 3. If no suitable file is found, compares file1 with data read from\n" " standard input.\n" "\nExit status is 0 if inputs are identical, 1 if different, 2 if trouble.\n" "\nOptions:\n" @@ -148,7 +148,8 @@ bool set_fifonames( const std::string filenames[2] ) } -bool set_data_feeder( const std::string & fifoname, const int infd, +bool set_data_feeder( const std::string & filename, + const std::string & fifoname, const int infd, Children & children, int format_index ) { const uint8_t * magic_data = 0; @@ -166,7 +167,7 @@ bool set_data_feeder( const std::string & fifoname, const int infd, if( pid == 0 ) // child 1 (compressor feeder) { if( close( fda[0] ) != 0 || - !feed_data( infd, fda[1], magic_data, magic_size ) ) + !feed_data( filename, infd, fda[1], magic_data, magic_size ) ) _exit( 2 ); if( close( fda[1] ) != 0 ) { show_close_error(); _exit( 2 ); } @@ -225,7 +226,7 @@ bool set_data_feeder( const std::string & fifoname, const int infd, program_name, fifoname.c_str(), std::strerror( errno ) ); _exit( 2 ); } - if( !feed_data( infd, outfd, magic_data, magic_size ) ) + if( !feed_data( filename, infd, outfd, magic_data, magic_size ) ) _exit( 2 ); if( close( outfd ) != 0 ) { show_close_error(); _exit( 2 ); } @@ -386,8 +387,10 @@ int main( const int argc, const char * const argv[] ) if( !set_fifonames( filenames ) ) return 2; Children children[2]; - if( !set_data_feeder( fifonames[0], infd[0], children[0], format_types[0] ) || - !set_data_feeder( fifonames[1], infd[1], children[1], format_types[1] ) ) + if( !set_data_feeder( filenames[0], fifonames[0], infd[0], children[0], + format_types[0] ) || + !set_data_feeder( filenames[1], fifonames[1], infd[1], children[1], + format_types[1] ) ) return 2; const pid_t diff_pid = fork(); -- cgit v1.2.3