summaryrefslogtreecommitdiffstats
path: root/zgrep.cc
diff options
context:
space:
mode:
Diffstat (limited to 'zgrep.cc')
-rw-r--r--zgrep.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/zgrep.cc b/zgrep.cc
index b1c18b4..41317a5 100644
--- a/zgrep.cc
+++ b/zgrep.cc
@@ -72,23 +72,23 @@ int zgrep_stdin( int infd, const std::vector< const char * > & grep_args )
if( dup2( infd, STDIN_FILENO ) >= 0 && close( infd ) == 0 )
{
const char ** const argv = new const char *[grep_args.size()+2];
- argv[0] = "grep";
+ argv[0] = GREP;
for( unsigned int i = 0; i < grep_args.size(); ++i )
argv[i+1] = grep_args[i];
argv[grep_args.size()+1] = 0;
execvp( argv[0], (char **)argv );
}
- show_error( "Can't exec `grep'." );
+ show_exec_error( GREP );
_exit( 2 );
}
// parent
if( grep_pid < 0 )
- { show_error( "Can't fork `grep'", errno ); return 2; }
+ { show_fork_error( GREP ); return 2; }
int retval = 0;
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 2;
- if( wait_for_child( grep_pid, "grep" ) != 0 ) retval = 2;
+ if( wait_for_child( grep_pid, GREP ) != 0 ) retval = 2;
if( close( infd ) != 0 )
- { show_error( "Can't close output of data feeder", errno ); return 2; }
+ { show_close_error( "data feeder" ); return 2; }
return retval;
}
@@ -110,19 +110,19 @@ int zgrep_file( int infd, const std::string & input_filename,
close( infd ) == 0 && close( fda[0] ) == 0 && close( fda[1] ) == 0 )
{
const char ** const argv = new const char *[grep_args.size()+2];
- argv[0] = "grep";
+ argv[0] = GREP;
for( unsigned int i = 0; i < grep_args.size(); ++i )
argv[i+1] = grep_args[i];
argv[grep_args.size()+1] = 0;
execvp( argv[0], (char **)argv );
}
- show_error( "Can't exec `grep'." );
+ show_exec_error( GREP );
_exit( 2 );
}
// parent
close( fda[1] );
if( grep_pid < 0 )
- { show_error( "Can't fork `grep'", errno ); return 2; }
+ { show_fork_error( GREP ); return 2; }
enum { buffer_size = 256 };
uint8_t buffer[buffer_size];
bool line_begin = true;
@@ -148,12 +148,12 @@ int zgrep_file( int infd, const std::string & input_filename,
}
int retval = 0;
if( pid && wait_for_child( pid, "data feeder" ) != 0 ) retval = 2;
- if( wait_for_child( grep_pid, "grep" ) != 0 ) retval = 2;
+ if( wait_for_child( grep_pid, GREP ) != 0 ) retval = 2;
if( grep_list && retval == 0 )
std::printf( "%s\n", input_filename.c_str() );
if( close( infd ) != 0 )
- { show_error( "Can't close output of data feeder", errno ); return 2; }
+ { show_close_error( "data feeder" ); return 2; }
if( close( fda[0] ) != 0 )
- { show_error( "Can't close output of grep", errno ); return 2; }
+ { show_close_error( GREP ); return 2; }
return retval;
}