added args_strip() function for stripping --cacche-* options in

failed()
This commit is contained in:
Andrew Tridgell 2003-02-08 06:49:22 +01:00
parent f9bb806617
commit 70b4385dbe
3 changed files with 25 additions and 0 deletions

21
args.c
View File

@ -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++;
}
}
}

View File

@ -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]);

View File

@ -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