]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
C++-ify is_full_path
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 31 Jul 2020 17:28:48 +0000 (19:28 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 31 Jul 2020 18:31:54 +0000 (20:31 +0200)
src/Util.hpp
src/ccache.cpp
src/legacy_util.cpp
src/legacy_util.hpp

index 62b9e49fc5da9eac9c8479545a6fc0a0094c736d..8b57199ce0aa85a8e5ef62114c210db777463627 100644 (file)
@@ -273,6 +273,18 @@ is_dir_separator(char ch)
     ;
 }
 
+// Return whether `path` is a full path.
+inline bool
+is_full_path(nonstd::string_view path)
+{
+#ifdef _WIN32
+  if (path.find('\\') != nonstd::string_view::npos) {
+    return true;
+  }
+#endif
+  return path.find('/') != nonstd::string_view::npos;
+}
+
 // Return whether `path` represents a precompiled header (see "Precompiled
 // Headers" in GCC docs).
 bool is_precompiled_header(nonstd::string_view path);
index e2ed2ea11147f579ecb5b5c05425edeb722f40ab..885e7fa7d22b3de93887679589d215084934e438 100644 (file)
@@ -1726,8 +1726,7 @@ find_compiler(Context& ctx, const char* const* argv)
   std::string base(Util::base_name(argv[0]));
   if (Util::same_program_name(base, MYNAME)) {
     ctx.orig_args.pop_front();
-    if (is_full_path(ctx.orig_args[0].c_str())) {
-      // A full path was given.
+    if (Util::is_full_path(ctx.orig_args[0])) {
       return;
     }
     base = std::string(Util::base_name(ctx.orig_args[0]));
index ca79f26b394cde35810e27d3d559f5d1606f82ab..09937a429b6ab9abe10dd1305d1ccf501a6696d1 100644 (file)
 #  include <sys/time.h>
 #endif
 
-// Return whether the argument is a full path.
-bool
-is_full_path(const char* path)
-{
-#ifdef _WIN32
-  if (strchr(path, '\\')) {
-    return true;
-  }
-#endif
-  return strchr(path, '/');
-}
-
 // Update the modification time of a file in the cache to save it from LRU
 // cleanup.
 void
index 44b018fe588dbe4a71ba91278285b0ecf6cee9f8..523e1621e92d2ada591ba151d0b2d6e9c399c4e2 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <string>
 
-bool is_full_path(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);