]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix handling of -finput-charset when CCACHE_CPP2 is in effect
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 2 Jun 2010 18:22:33 +0000 (20:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 2 Jun 2010 18:25:36 +0000 (20:25 +0200)
args.c
ccache.c
ccache.h
test.sh

diff --git a/args.c b/args.c
index 5e239eebbe04c446cd3fab3af692b15cb0037c7a..bdb1e3e2968d7c31d0edae1c0bee6687515de15f 100644 (file)
--- 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)
 {
index 22bc731ea2381c461a2495e7fe3ffd559bfa6497..95102f0b312c3656a6a652c2056a1b587b58c8d3 100644 (file)
--- 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)
index 627973426bec48752b8b92fd4ba79cb36af198c4..7753f42c10fac572c5f9627e442a491066c4d97b 100644 (file)
--- 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 cf2a2f56f5630a5a527d3c8d1733104e51c55294..5bba169299c00089d27e575d32fbddd33f09a7ad 100755 (executable)
--- 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 <wchar.h>\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