diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2016-05-20 06:48:30 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2016-05-20 06:49:00 +0000 |
commit | 4d364776fc785a234cebba08bc93cd06202103dd (patch) | |
tree | 90476b30bb959b780c85efc2ab546a5b5e970f2c /zdiff.cc | |
parent | Releasing debian version 1.4-2. (diff) | |
download | zutils-4d364776fc785a234cebba08bc93cd06202103dd.tar.xz zutils-4d364776fc785a234cebba08bc93cd06202103dd.zip |
Merging upstream version 1.5.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zdiff.cc')
-rw-r--r-- | zdiff.cc | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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 ); } |