summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2012-02-13 19:56:19 +0100
committerJoel Rosdahl <joel@rosdahl.net>2012-02-13 19:56:19 +0100
commit8ba68e7e3bb4ea2761a9a84e5a99ad95ddbff31e (patch)
tree29b2f86ec91f75243a84dfefd41162a3e74b9e07
parente98dd744385b7ec45895005a8765552e7c3cd1fa (diff)
downloadccache-8ba68e7e3bb4ea2761a9a84e5a99ad95ddbff31e.tar.gz
Minor cleanup
-rw-r--r--ccache.c53
-rw-r--r--conf.c8
2 files changed, 31 insertions, 30 deletions
diff --git a/ccache.c b/ccache.c
index 7b93f5c2..918ea1cb 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 7b1cefdb..de549e15 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);