]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Extract print_command function from print_executed_command
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 9 May 2010 20:19:22 +0000 (22:19 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 9 May 2010 20:19:22 +0000 (22:19 +0200)
ccache.c
ccache.h
execute.c

index 7b41f750169cdd60046b1ab3ac78ac1a2bd876be..2fc0658e35ee537f832fe8b90f19f07a85fddea5 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -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));
index 9aae3ff21afe7432348da945928d85ee28906118..0e2429051ff7127002f1d4bda7abd0f3e4979d51 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -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;
index cc3845c6a5b0a4b49a02293628b4f2457dba67a9..d20f2c92269d3918e54ac2ee66ffeb1f78157135 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -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);
 }