From: Joel Rosdahl Date: Mon, 13 Feb 2012 18:56:19 +0000 (+0100) Subject: Minor cleanup X-Git-Tag: v3.2~165 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8ba68e7e3bb4ea2761a9a84e5a99ad95ddbff31e;p=thirdparty%2Fccache.git Minor cleanup --- diff --git a/ccache.c b/ccache.c index 7b93f5c2a..918ea1cbe 100644 --- a/ccache.c +++ b/ccache.c @@ -192,34 +192,37 @@ static const char HASH_PREFIX[] = "3"; static void add_prefix(struct args *orig_args) { - if (!str_eq(conf->prefix_command, "")) { - char *e; - char *tok, *saveptr = NULL; - struct args *prefix = args_init(0, NULL); - int i; - - e = x_strdup(conf->prefix_command); - for (tok = strtok_r(e, " ", &saveptr); - tok; - tok = strtok_r(NULL, " ", &saveptr)) { - char *p; + char *e; + char *tok, *saveptr = NULL; + struct args *prefix; + int i; - p = find_executable(tok, MYNAME); - if (!p) { - fatal("%s: %s", tok, strerror(errno)); - } + if (str_eq(conf->prefix_command, "")) { + return; + } - args_add(prefix, p); - free(p); - } - free(e); + prefix = args_init(0, NULL); + e = x_strdup(conf->prefix_command); + for (tok = strtok_r(e, " ", &saveptr); + tok; + tok = strtok_r(NULL, " ", &saveptr)) { + char *p; - cc_log("Using command-line prefix %s", conf->prefix_command); - for (i = prefix->argc; i != 0; i--) { - args_add_prefix(orig_args, prefix->argv[i-1]); + p = find_executable(tok, MYNAME); + if (!p) { + fatal("%s: %s", tok, strerror(errno)); } - args_free(prefix); + + args_add(prefix, p); + free(p); } + free(e); + + cc_log("Using command-line prefix %s", conf->prefix_command); + for (i = prefix->argc; i != 0; i--) { + args_add_prefix(orig_args, prefix->argv[i-1]); + } + args_free(prefix); } /* Something went badly wrong - just execute the real compiler. */ @@ -228,10 +231,7 @@ failed(void) { assert(orig_args); - /* strip any local args */ args_strip(orig_args, "--ccache-"); - - /* add prefix from CCACHE_PREFIX */ add_prefix(orig_args); cc_log("Failed; falling back to running the real compiler"); @@ -2235,7 +2235,6 @@ ccache(int argc, char *argv[]) failed(); } - /* add prefix from CCACHE_PREFIX */ add_prefix(compiler_args); /* run real compiler, sending output to cache */ diff --git a/conf.c b/conf.c index 7b1cefdb9..de549e150 100644 --- a/conf.c +++ b/conf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Joel Rosdahl + * Copyright (C) 2011-2012 Joel Rosdahl * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -516,7 +516,8 @@ conf_print_items(struct conf *conf, printer(s, conf->item_origins[find_conf("cache_dir")->number], context); reformat(&s, "cache_dir_levels = %u", conf->cache_dir_levels); - printer(s, conf->item_origins[find_conf("cache_dir_levels")->number], context); + printer(s, conf->item_origins[find_conf("cache_dir_levels")->number], + context); reformat(&s, "compiler = %s", conf->compiler); printer(s, conf->item_origins[find_conf("compiler")->number], context); @@ -537,7 +538,8 @@ conf_print_items(struct conf *conf, printer(s, conf->item_origins[find_conf("disable")->number], context); reformat(&s, "extra_files_to_hash = %s", conf->extra_files_to_hash); - printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number], context); + printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number], + context); reformat(&s, "hard_link = %s", conf->hard_link ? "true" : "false"); printer(s, conf->item_origins[find_conf("hard_link")->number], context);