]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't check for symlinks on Windows
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 13 Jul 2016 14:13:27 +0000 (16:13 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 13 Jul 2016 14:13:27 +0000 (16:13 +0200)
ccache.c
ccache.h
test/util.c
util.c

index 4d0ffc3e9ed786d9029da69e8b8d11390d56d256..7b016c8acb1afdeec48288a7e34879fe91603add 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2804,8 +2804,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               lstat(argv[i], &st);
-               if ((st.st_mode & S_IFMT) == S_IFLNK) {
+               if (is_symlink(argv[i])) {
                        /* Don't rewrite source file path if it's a symlink since
                           make_relative_path resolves symlinks using realpath(3) and this leads
                           to potentially choosing incorrect relative header files. See the
index 3c4c1e7e0c625e686d6bf907b9d7a094c67d68e8..0b1792da686ff4008775bacad77a62912f59c36c 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -167,6 +167,7 @@ size_t common_dir_prefix_length(const char *s1, const char *s2);
 char *get_relative_path(const char *from, const char *to);
 bool is_absolute_path(const char *path);
 bool is_full_path(const char *path);
+bool is_symlink(const char *path);
 void update_mtime(const char *path);
 void x_exit(int status) ATTR_NORETURN;
 int x_rename(const char *oldpath, const char *newpath);
index adfecaf3b7541ee17af976704843bfa170854bf4..49c079cbb0e2e6f9c984b6481eddbb2d726809d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Joel Rosdahl
+ * Copyright (C) 2010-2016 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
@@ -30,18 +30,6 @@ path_exists(const char *path)
        return lstat(path, &st) == 0;
 }
 
-bool
-is_symlink(const char *path)
-{
-#ifdef _WIN32
-       (void) path;
-       return 0;
-#else
-       struct stat st;
-       return lstat(path, &st) == 0 && S_ISLNK(st.st_mode);
-#endif
-}
-
 void
 create_file(const char *path, const char *content)
 {
diff --git a/util.c b/util.c
index 1a7f3fdd17a118e604fc4998074ca94c765907d5..b242841a3ae02a8430aefd890a76a1b80e47b0f8 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1501,6 +1501,17 @@ is_full_path(const char *path)
        return false;
 }
 
+bool is_symlink(const char *path)
+{
+#ifdef _WIN32
+       (void)path;
+       return false;
+#else
+       struct stat st;
+       return x_lstat(path, &st) == 0 && ((st.st_mode & S_IFMT) == S_IFLNK);
+#endif
+}
+
 /*
  * Update the modification time of a file in the cache to save it from LRU
  * cleanup.