From 3a442eb97bf6682452b2be09a0015deef37a75cb Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Fri, 16 Jul 2010 16:54:14 -0300 Subject: [PATCH] Implement is_full_path() helper function --- ccache.c | 2 +- ccache.h | 1 + util.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ccache.c b/ccache.c index 2741c4eac..7acde89f6 100644 --- a/ccache.c +++ b/ccache.c @@ -1266,7 +1266,7 @@ static void find_compiler(int argc, char **argv) if (compare_executable_name(base, MYNAME)) { args_remove_first(orig_args); free(base); - if (strchr(argv[1],'/')) { + if (is_full_path(argv[1])) { /* a full path was given */ return; } diff --git a/ccache.h b/ccache.h index d416c3e73..92247326c 100644 --- a/ccache.h +++ b/ccache.h @@ -109,6 +109,7 @@ int compare_executable_name(const char *s1, const char *s2); size_t common_dir_prefix_length(const char *s1, const char *s2); char *get_relative_path(const char *from, const char *to); int is_absolute_path(const char *path); +int is_full_path(const char *path); void update_mtime(const char *path); void *x_fmmap(const char *fname, off_t *size, const char *errstr); int x_munmap(void *addr, size_t length); diff --git a/util.c b/util.c index 2f691cc6d..de87746a3 100644 --- a/util.c +++ b/util.c @@ -959,6 +959,17 @@ is_absolute_path(const char *path) return path[0] == '/'; } +/* + * Return whether the argument is a full path. + */ +int +is_full_path(const char *path) +{ + if (strchr(path, '/')) + return 1; + return 0; +} + /* * Update the modification time of a file in the cache to save it from LRU * cleanup. -- 2.47.3