zgrep.cc (zutils-1.9.tar.lz) | : | zgrep.cc (zutils-1.10.tar.lz) | ||
---|---|---|---|---|
/* Zgrep - search compressed files for a regular expression | /* Zgrep - search compressed files for a regular expression | |||
Copyright (C) 2010-2020 Antonio Diaz Diaz. | Copyright (C) 2010-2021 Antonio Diaz Diaz. | |||
This program is free software: you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 2 of the License, or | the Free Software Foundation, either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | GNU General Public License for more details. | |||
skipping to change at line 195 | skipping to change at line 195 | |||
{ | { | |||
if( line_begin ) | if( line_begin ) | |||
{ line_begin = false; std::printf( "%s:", input_filename.c_str() ); } | { line_begin = false; std::printf( "%s:", input_filename.c_str() ); } | |||
if( buffer[i] == '\n' ) line_begin = true; | if( buffer[i] == '\n' ) line_begin = true; | |||
putchar( buffer[i] ); | putchar( buffer[i] ); | |||
} | } | |||
else if( std::fwrite( buffer, 1, size, stdout ) != (unsigned)size ) | else if( std::fwrite( buffer, 1, size, stdout ) != (unsigned)size ) | |||
{ std::fflush( stdout ); show_error( "Write error", errno ); return 2; } | { std::fflush( stdout ); show_error( "Write error", errno ); return 2; } | |||
std::fflush( stdout ); | std::fflush( stdout ); | |||
} | } | |||
if( size < buffer_size ) break; | if( size < buffer_size ) break; // end of grep's output | |||
} | } | |||
int retval = wait_for_child( grep_pid, GREP ); | int retval = wait_for_child( grep_pid, GREP ); | |||
if( !good_status( children, retval == 1 ) ) retval = 2; | if( !good_status( children, retval == 1 ) ) retval = 2; | |||
if( list_mode && (retval == 0) == (list_mode == 1) ) | if( list_mode && (retval == 0) == (list_mode == 1) ) | |||
{ std::printf( "%s\n", input_filename.c_str() ); std::fflush( stdout ); } | { std::printf( "%s\n", input_filename.c_str() ); std::fflush( stdout ); } | |||
if( close( infd ) != 0 ) | if( close( infd ) != 0 ) | |||
{ show_close_error(); return 2; } | { show_close_error(); return 2; } | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added |