]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Minor code cleanup
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 8 Nov 2012 20:27:40 +0000 (21:27 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 8 Nov 2012 20:27:40 +0000 (21:27 +0100)
ccache.c
compopt.c
test/test_compopt.c

index 4b720ac7e7f64a202e9ba974a71012451a857fcd..f899bf90649dd4797386d0064064ff52cd83bde5 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1775,12 +1775,10 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
 
                /*
-                * Options taking an argument that that we may want to rewrite
-                * to relative paths to get better hit rate. A secondary effect
-                * is that paths in the standard error output produced by the
-                * compiler will be normalized.
+                * Options taking an argument that we may want to rewrite to relative paths
+                * to get better hit rate. A secondary effect is that paths in the standard
+                * error output produced by the compiler will be normalized.
                 */
-
                if (compopt_takes_path(argv[i])) {
                        char *relpath;
                        char *pch_file = NULL;
@@ -1791,9 +1789,6 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                goto out;
                        }
 
-                       /* if the argument only affects the preprocessed output then
-                        * it should not affect the compilation of the .c file
-                        */
                        relpath = make_relative_path(x_strdup(argv[i+1]));
                        if (compopt_affects_cpp(argv[i])) {
                                args_add(cpp_args, argv[i]);
@@ -1851,9 +1846,6 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        relpath = make_relative_path(x_strdup(argv[i] + 2));
                        option = format("-%c%s", argv[i][1], relpath);
 
-                       /* if the argument only affects the preprocessed output then
-                        * it should not affect the compilation of the .c file
-                        */
                        if (compopt_short(compopt_affects_cpp, argv[i])) {
                                args_add(cpp_args, option);
                        } else {
@@ -1874,9 +1866,6 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                goto out;
                        }
 
-                       /* if the argument only affects the preprocessed output then
-                        * it should not affect the compilation of the .c file
-                        */
                        if (compopt_affects_cpp(argv[i])) {
                                args_add(cpp_args, argv[i]);
                                args_add(cpp_args, argv[i+1]);
@@ -1891,8 +1880,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
 
                /* other options */
                if (argv[i][0] == '-') {
-                       if (compopt_affects_cpp(argv[i]) || 
-                           compopt_prefix_affects_cpp(argv[i])) {
+                       if (compopt_affects_cpp(argv[i])
+                           || compopt_prefix_affects_cpp(argv[i])) {
                                args_add(cpp_args, argv[i]);
                        } else {
                                args_add(stripped_args, argv[i]);
index 5c8682d10f88ca74653a407f00dd08f335b65bfc..6f7642517160603de7b0d1b3cf2b40eefc0371c5 100644 (file)
--- a/compopt.c
+++ b/compopt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Joel Rosdahl
+ * Copyright (C) 2010, 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
@@ -58,7 +58,7 @@ static const struct compopt compopts[] = {
        {"-fno-working-directory", AFFECTS_CPP},
        {"-frepo",          TOO_HARD},
        {"-ftest-coverage", TOO_HARD}, /* generates a .gcno file at the same time */
-       {"-fworking-directory", AFFECTS_CPP},   
+       {"-fworking-directory", AFFECTS_CPP},
        {"-idirafter",      AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
        {"-iframework",     AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
        {"-imacros",        AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
@@ -179,9 +179,8 @@ compopt_takes_arg(const char *option)
        return co && (co->type & TAKES_ARG);
 }
 
-/* determines if argument takes a concatentated argument
-   by comparing prefixes
-*/
+/* Determines if argument takes a concatentated argument by comparing prefixes.
+ */
 bool
 compopt_takes_concat_arg(const char *option)
 {
@@ -189,14 +188,13 @@ compopt_takes_concat_arg(const char *option)
        return co && (co->type & TAKES_CONCAT_ARG);
 }
 
-/* determines if the prefix of the option matches
-   any option and affects the preprocessor
-*/
+/* Determines if the prefix of the option matches any option and affects the
+ * preprocessor.
+ */
 bool
 compopt_prefix_affects_cpp(const char *option)
 {
        /* prefix options have to take concatentated args */
        const struct compopt *co = find_prefix(option);
-       return co && (co->type & TAKES_CONCAT_ARG) && 
-                                (co->type & AFFECTS_CPP);
+       return co && (co->type & TAKES_CONCAT_ARG) && (co->type & AFFECTS_CPP);
 }
index 7a797d89c5e5d7630138ba403b199bace571c296..9af5e4e1677e9f315ddb80145736bfdc29aa8a6d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Joel Rosdahl
+ * Copyright (C) 2010, 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
@@ -99,5 +99,4 @@ TEST(dash_iframework_prefix_affects_cpp)
        CHECK(compopt_prefix_affects_cpp("-iframework"));
 }
 
-
 TEST_SUITE_END