From: Andrew Tridgell Date: Wed, 27 Mar 2002 08:40:13 +0000 (+0100) Subject: added args_pop() for neater args processing X-Git-Tag: v1.0~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db1f80c11f08ef3b3c56a589640b8c560d0b670e;p=thirdparty%2Fccache.git added args_pop() for neater args processing --- diff --git a/args.c b/args.c index 636b903f8..d0defd2c8 100644 --- a/args.c +++ b/args.c @@ -39,3 +39,8 @@ void args_add(ARGS *args, const char *s) args->argv[args->argc] = NULL; } +void args_pop(ARGS *args, int n) +{ + args->argc -= n; + args->argv[args->argc] = NULL; +} diff --git a/ccache.c b/ccache.c index aa7e881a7..8ec652ae1 100644 --- a/ccache.c +++ b/ccache.c @@ -55,7 +55,7 @@ static void to_cache(ARGS *args) args_add(args, "-o"); args_add(args, tmp_hashname); status = execute(args->argv, tmp_stdout, tmp_stderr); - args->argc -= 2; + args_pop(args, 2); if (stat(tmp_stdout, &st) != 0 || st.st_size != 0) { cc_log("compiler produced stdout for %s\n", output_file); @@ -204,7 +204,7 @@ static void find_hash(ARGS *args) args_add(args, "-E"); status = execute(args->argv, path_stdout, path_stderr); - args->argc--; + args_pop(args, 1); if (status != 0) { unlink(path_stdout); diff --git a/ccache.h b/ccache.h index 3b51d77df..155753152 100644 --- a/ccache.h +++ b/ccache.h @@ -52,3 +52,5 @@ typedef struct { ARGS *args_init(void); void args_add(ARGS *args, const char *s); +void args_pop(ARGS *args, int n); +