From 4d364776fc785a234cebba08bc93cd06202103dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 20 May 2016 08:48:30 +0200 Subject: Merging upstream version 1.5. Signed-off-by: Daniel Baumann --- zdiff.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'zdiff.cc') diff --git a/zdiff.cc b/zdiff.cc index 1e03356..26a7365 100644 --- a/zdiff.cc +++ b/zdiff.cc @@ -1,5 +1,5 @@ /* Zdiff - decompress and compare two files line by line - Copyright (C) 2010-2015 Antonio Diaz Diaz. + Copyright (C) 2010-2016 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 @@ -48,7 +48,7 @@ std::string fifonames[2]; // names of the two fifos passed to diff void show_help() { - std::printf( "Zdiff compares two files (\"-\" means standard input), and if they\n" + std::printf( "Zdiff compares two files ('-' means standard input), and if they\n" "differ, shows the differences line by line. If any given file is\n" "compressed, its decompressed content is used. Zdiff is a front end to\n" "the diff program and has the limitation that messages from diff refer to\n" @@ -123,12 +123,14 @@ bool set_fifonames( const std::string filenames[2] ) if( p ) { fifonames[0] = p; fifonames[0] += '/'; } else fifonames[0] = "/tmp/"; int n = getpid(); - const unsigned pos = fifonames[0].size(); + unsigned pos = fifonames[0].size(); do fifonames[0].insert( pos, 1, codes[n % num_codes] ); while( n /= num_codes ); + pos = fifonames[0].size(); fifonames[1] = fifonames[0]; fifonames[0] += '_'; fifonames[0] += my_basename( filenames[0].c_str() ); - fifonames[1] += '-'; fifonames[1] += my_basename( filenames[1].c_str() ); + fifonames[1] += '_'; fifonames[1] += my_basename( filenames[1].c_str() ); + if( fifonames[1] == fifonames[0] ) fifonames[1][pos] = '-'; for( int i = 0; i < 2; ++i ) if( mkfifo( fifonames[i].c_str(), S_IRUSR | S_IWUSR ) != 0 ) @@ -180,7 +182,7 @@ bool set_data_feeder( const std::string & fifoname, const int infd, if( outfd < 0 ) { if( verbosity >= 0 ) - std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s.\n", + std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s\n", program_name, fifoname.c_str(), std::strerror( errno ) ); _exit( 2 ); } @@ -219,7 +221,7 @@ bool set_data_feeder( const std::string & fifoname, const int infd, if( outfd < 0 ) { if( verbosity >= 0 ) - std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s.\n", + std::fprintf( stderr, "%s: Can't open FIFO '%s' for writing: %s\n", program_name, fifoname.c_str(), std::strerror( errno ) ); _exit( 2 ); } -- cgit v1.2.3