]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Implement is_absolute_path() helper function
authorRamiro Polla <ramiro.polla@gmail.com>
Thu, 15 Jul 2010 18:05:22 +0000 (15:05 -0300)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 16 Jul 2010 14:01:02 +0000 (16:01 +0200)
ccache.h
execute.c
util.c

index 5a99ebfb4a48d7f8a3ac90e2fb788d6f4dd64bf2..900b12cc74ef06294e9dec5e8d32a1051f3dfa1a 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -107,6 +107,7 @@ const char *get_home_directory(void);
 char *get_cwd();
 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);
 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);
index 50e96b1430a09b3b7147225ce8a0b94b3d081f17..d04f7e66e935ff775e10b9f10c08c44c8d87ae94 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -90,7 +90,7 @@ char *find_executable(const char *name, const char *exclude_name)
 {
        char *path;
 
-       if (*name == '/') {
+       if (is_absolute_path(name)) {
                return x_strdup(name);
        }
 
diff --git a/util.c b/util.c
index 0c8b1d8cb613a34c5565c16458c9ab682ed27990..5dbe0548b35b6f342d54641c0bfb369afcc4f905 100644 (file)
--- a/util.c
+++ b/util.c
@@ -938,6 +938,15 @@ char *get_relative_path(const char *from, const char *to)
        return result;
 }
 
+/*
+ * Return whether path is absolute.
+ */
+int
+is_absolute_path(const char *path)
+{
+       return path[0] == '/';
+}
+
 /*
  * Update the modification time of a file in the cache to save it from LRU
  * cleanup.