From: Joel Rosdahl Date: Tue, 1 Jun 2010 19:27:30 +0000 (+0200) Subject: Extract code into a rewrite_x_option_to_preprocessed_language function X-Git-Tag: v3.0~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35617456e8d79d715a5c3609081507a070baed79;p=thirdparty%2Fccache.git Extract code into a rewrite_x_option_to_preprocessed_language function --- diff --git a/ccache.c b/ccache.c index fc829c81a..22bc731ea 100644 --- a/ccache.c +++ b/ccache.c @@ -557,6 +557,27 @@ static const char *extension_for_language(const char *language) return NULL; } +static void rewrite_x_option_to_preprocessed_language(ARGS *args) +{ + int i; + + for (i = 0; i < args->argc; i++) { + if (strcmp(args->argv[i], "-x") == 0) { + i++; + if (i < args->argc) { + char *language = args->argv[i]; + const char *prepr_language = preprocessed_language(language, NULL); + if (!prepr_language) { + stats_update(STATS_ERROR); + failed(); + } + args->argv[i] = x_strdup(prepr_language); + free(language); + } + } + } +} + /* run the real compiler and put the result in cache */ static void to_cache(ARGS *args) { @@ -564,7 +585,6 @@ static void to_cache(ARGS *args) struct stat st; int status; int compress; - int i; x_asprintf(&tmp_stdout, "%s.tmp.stdout.%s", cached_obj, tmp_string()); x_asprintf(&tmp_stderr, "%s.tmp.stderr.%s", cached_obj, tmp_string()); @@ -582,21 +602,7 @@ static void to_cache(ARGS *args) putenv("DEPENDENCIES_OUTPUT"); if (compile_preprocessed_source_code) { - for (i=0; iargc; i++) { - if (strcmp(args->argv[i], "-x") == 0) { - i++; - if (i < args->argc) { - char *language = args->argv[i]; - const char *prepr_language = preprocessed_language(language, NULL); - if (!prepr_language) { - stats_update(STATS_ERROR); - failed(); - } - args->argv[i] = x_strdup(prepr_language); - free(language); - } - } - } + rewrite_x_option_to_preprocessed_language(args); args_add(args, i_tmpfile); } else { args_add(args, input_file);