Extract print_command function from print_executed_command

This commit is contained in:
Joel Rosdahl 2010-05-09 22:19:22 +02:00
parent 4ea12e1d1d
commit 39f48df93b
3 changed files with 14 additions and 7 deletions

View File

@ -249,7 +249,7 @@ static void failed(void)
cc_log("Failed; falling back to running the real compiler");
if (getenv("CCACHE_VERBOSE")) {
print_executed_command(orig_args->argv);
print_executed_command(stdout, orig_args->argv);
}
execv(orig_args->argv[0], orig_args->argv);
cc_log("execv returned (%s)!", strerror(errno));

View File

@ -11,6 +11,7 @@
#include <sys/file.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#ifdef __GNUC__
#define ATTR_FORMAT(x, y, z) __attribute__((format (x, y, z)))
@ -134,7 +135,8 @@ int execute(char **argv,
const char *path_stdout,
const char *path_stderr);
char *find_executable(const char *name, const char *exclude_name);
void print_executed_command(char **argv);
void print_command(FILE *fp, char **argv);
void print_executed_command(FILE *fp, char **argv);
typedef struct {
char **argv;

View File

@ -46,7 +46,7 @@ int execute(char **argv,
int fd;
if (getenv("CCACHE_VERBOSE")) {
print_executed_command(argv);
print_executed_command(stdout, argv);
}
unlink(path_stdout);
@ -141,12 +141,17 @@ char *find_executable(const char *name, const char *exclude_name)
return NULL;
}
void print_executed_command(char **argv)
void print_command(FILE *fp, char **argv)
{
int i;
printf("%s: executing ", MYNAME);
for (i = 0; argv[i]; i++) {
printf("%s%s", (i == 0) ? "" : " ", argv[i]);
fprintf(fp, "%s%s", (i == 0) ? "" : " ", argv[i]);
}
printf("\n");
fprintf(fp, "\n");
}
void print_executed_command(FILE *fp, char **argv)
{
fprintf(fp, "%s: executing ", MYNAME);
print_command(fp, argv);
}