]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
added args_strip() function for stripping --cacche-* options in
authorAndrew Tridgell <tridge@samba.org>
Sat, 8 Feb 2003 05:49:22 +0000 (06:49 +0100)
committerAndrew Tridgell <tridge@samba.org>
Sat, 8 Feb 2003 05:49:22 +0000 (06:49 +0100)
failed()

args.c
ccache.c
ccache.h

diff --git a/args.c b/args.c
index 94affa2050ed57941be0c3540d60a757850ac46a..3dd71e9c5d2af9cea399cf5f9ecb04661c8ad870 100644 (file)
--- a/args.c
+++ b/args.c
@@ -47,3 +47,24 @@ void args_pop(ARGS *args, int n)
                args->argv[args->argc] = NULL;
        }
 }
+
+/* strip any arguments beginning with the specified prefix */
+void args_strip(ARGS *args, const char *prefix)
+{
+       int i;
+       for (i=0; i<args->argc; ) {
+               if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) {
+                       if (i < args->argc-1) {
+                               /* note that we can't free the entry we are removing
+                                  as it may be part of the original argc/argv passed
+                                  to main() */
+                               memmove(&args->argv[i], 
+                                       &args->argv[i+1], 
+                                       (args->argc-1) * sizeof(args->argv[i]));
+                       }
+                       args->argc--;
+               } else {
+                       i++;
+               }
+       }
+}
index eda5556ac539dcaf351e46250bca7710689568a6..d048c08e20f858f7a87d7c8ac50aa2d23bb5e530 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -97,6 +97,9 @@ static void failed(void)
                cpp_stderr = NULL;
        }
 
+       /* strip any local args */
+       args_strip(orig_args, "--ccache-");
+
        execv(orig_args->argv[0], orig_args->argv);
        cc_log("execv returned (%s)!\n", strerror(errno));
        perror(orig_args->argv[0]);
index b09d131eea23e06f7f11579596075108f2eb3e0f..e1e43bd805335977a394ba9b05ca0acfc2b94ad9 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -128,6 +128,7 @@ typedef struct {
 ARGS *args_init(void);
 void args_add(ARGS *args, const char *s);
 void args_pop(ARGS *args, int n);
+void args_strip(ARGS *args, const char *prefix);
 
 #if HAVE_COMPAR_FN_T
 #define COMPAR_FN_T __compar_fn_t