diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2012-02-13 19:56:19 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2012-02-13 19:56:19 +0100 |
commit | 8ba68e7e3bb4ea2761a9a84e5a99ad95ddbff31e (patch) | |
tree | 29b2f86ec91f75243a84dfefd41162a3e74b9e07 | |
parent | e98dd744385b7ec45895005a8765552e7c3cd1fa (diff) | |
download | ccache-8ba68e7e3bb4ea2761a9a84e5a99ad95ddbff31e.tar.gz |
Minor cleanup
-rw-r--r-- | ccache.c | 53 | ||||
-rw-r--r-- | conf.c | 8 |
2 files changed, 31 insertions, 30 deletions
@@ -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 */ @@ -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); |