From: Joel Rosdahl Date: Wed, 2 Jun 2010 18:22:33 +0000 (+0200) Subject: Fix handling of -finput-charset when CCACHE_CPP2 is in effect X-Git-Tag: v3.0~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dd153c944a75e98553308a2ac305b88147db4132;p=thirdparty%2Fccache.git Fix handling of -finput-charset when CCACHE_CPP2 is in effect --- diff --git a/args.c b/args.c index 5e239eebb..bdb1e3e29 100644 --- a/args.c +++ b/args.c @@ -35,6 +35,17 @@ ARGS *args_init(int init_argc, char **init_args) return args; } +void args_free(ARGS *args) +{ + int i; + for (i = 0; i < args->argc; ++i) { + if (args->argv[i]) { + free(args->argv[i]); + } + } + free(args->argv); + free(args); +} void args_add(ARGS *args, const char *s) { diff --git a/ccache.c b/ccache.c index 22bc731ea..95102f0b3 100644 --- a/ccache.c +++ b/ccache.c @@ -1703,13 +1703,19 @@ static void process_args(int argc, char **argv, ARGS **preprocessor_args, * the conversion otherwise will happen twice. */ if (input_charset) { - *preprocessor_args = args_init(stripped_args->argc, - stripped_args->argv); + *preprocessor_args = args_init(stripped_args->argc, stripped_args->argv); args_add(*preprocessor_args, input_charset); + if (compile_preprocessed_source_code) { + *compiler_args = stripped_args; + } else { + *compiler_args = args_init(stripped_args->argc, stripped_args->argv); + args_add(*compiler_args, input_charset); + args_free(stripped_args); + } } else { *preprocessor_args = stripped_args; + *compiler_args = stripped_args; } - *compiler_args = stripped_args; } static unsigned parse_sloppiness(char *p) diff --git a/ccache.h b/ccache.h index 627973426..7753f42c1 100644 --- a/ccache.h +++ b/ccache.h @@ -150,6 +150,7 @@ typedef struct { ARGS *args_init(int , char **); +void args_free(ARGS *args); void args_add(ARGS *args, const char *s); void args_add_prefix(ARGS *args, const char *s); void args_pop(ARGS *args, int n); diff --git a/test.sh b/test.sh index cf2a2f56f..5bba16929 100755 --- a/test.sh +++ b/test.sh @@ -291,13 +291,13 @@ base_tests() { checkstat 'cache miss' 39 if [ -x /usr/bin/printf ]; then - /usr/bin/printf 'char foo[] = "\xa3";\n' >cp1250.c - if CCACHE_DISABLE=1 $COMPILER -c -finput-charset=cp1250 cp1250.c >/dev/null 2>&1; then + /usr/bin/printf '#include \nwchar_t foo[] = L"\xbf";\n' >latin1.c + if CCACHE_DISABLE=1 $COMPILER -c -finput-charset=latin1 latin1.c >/dev/null 2>&1; then testname="-finput-charset" - $CCACHE_COMPILE -c -finput-charset=cp1250 cp1250.c + CCACHE_CPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c checkstat 'cache hit (preprocessed)' 10 checkstat 'cache miss' 40 - $CCACHE_COMPILE -c -finput-charset=cp1250 cp1250.c + $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c checkstat 'cache hit (preprocessed)' 11 checkstat 'cache miss' 40 fi