From: Joel Rosdahl Date: Wed, 13 Jul 2016 14:13:27 +0000 (+0200) Subject: Don't check for symlinks on Windows X-Git-Tag: v3.3~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22d2fda3afcbddd91675c5d3abc390685d8102de;p=thirdparty%2Fccache.git Don't check for symlinks on Windows --- diff --git a/ccache.c b/ccache.c index 4d0ffc3e9..7b016c8ac 100644 --- 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 diff --git a/ccache.h b/ccache.h index 3c4c1e7e0..0b1792da6 100644 --- 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); diff --git a/test/util.c b/test/util.c index adfecaf3b..49c079cbb 100644 --- a/test/util.c +++ b/test/util.c @@ -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 1a7f3fdd1..b242841a3 100644 --- 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.