]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Canonicalize path for header ignore comparison
authorAnders Björklund <anders@itension.se>
Mon, 1 Feb 2016 20:00:09 +0000 (21:00 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 6 Feb 2016 14:00:37 +0000 (15:00 +0100)
Clang shows included headers from the current directory starting
with a "./", that causes the ignore comparison to miss otherwise.

ccache.c

index efaedfba8d0a1ce2dff1e6d6e41b991f05d59932..0620a507c779902d7e639747af60cfe22ee0d609 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -530,6 +530,8 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
        size_t size;
        bool is_pch;
        size_t path_len = strlen(path);
+       char *canonical;
+       size_t canonical_len;
        char *ignore;
        size_t ignore_len;
        size_t i;
@@ -575,16 +577,24 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
                goto failure;
        }
 
+       /* canonicalize path for comparison, clang uses ./header.h */
+       canonical = path;
+       canonical_len = path_len;
+       if (canonical[0] == '.' && canonical[1] == '/') {
+               canonical += 2;
+               canonical_len -= 2;
+       }
+
        for (i = 0; i < ignore_headers_len; i++) {
                ignore = ignore_headers[i];
                ignore_len = strlen(ignore);
-               if (ignore_len > path_len) {
+               if (ignore_len > canonical_len) {
                        continue;
                }
-               if (strncmp(path, ignore, ignore_len) == 0
+               if (strncmp(canonical, ignore, ignore_len) == 0
                    && (ignore[ignore_len-1] == DIR_DELIM_CH
-                       || path[ignore_len] == DIR_DELIM_CH
-                       || path[ignore_len] == '\0')) {
+                       || canonical[ignore_len] == DIR_DELIM_CH
+                       || canonical[ignore_len] == '\0')) {
                        goto ignore;
                }
        }