]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Use util::lexically_normal
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 8 Nov 2024 15:36:52 +0000 (16:36 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 9 Nov 2024 12:59:03 +0000 (13:59 +0100)
src/ccache/config.cpp
src/ccache/util/path.cpp

index 2cfb300f5402e4d4571b03fd1268e2fc6c8a052c..e69a9aa2e5e3087846808930394eda7dd9d03991 100644 (file)
@@ -1021,7 +1021,7 @@ Config::set_item(const std::string& key,
     m_base_dir = value;
     if (!m_base_dir.empty()) { // The empty string means "disable"
       verify_absolute_path(m_base_dir);
-      m_base_dir = m_base_dir.lexically_normal();
+      m_base_dir = util::lexically_normal(m_base_dir);
     }
     break;
 
index fb1b8e7f28e82e519a99468ddb2eaa53bddd1787..f23db8a05c19b794675699fc92a990000532b279 100644 (file)
@@ -83,12 +83,7 @@ make_relative_path(const fs::path& actual_cwd,
   DEBUG_ASSERT(apparent_cwd.is_absolute());
   DEBUG_ASSERT(path.is_absolute());
 
-  fs::path normalized_path = path.lexically_normal();
-  if (!normalized_path.has_filename()) {
-    // Skip trailing slash since fs::equivalent doesn't work otherwise on
-    // Windows.
-    normalized_path = normalized_path.parent_path();
-  }
+  fs::path normalized_path = util::lexically_normal(path);
   fs::path closest_existing_path = normalized_path;
   std::vector<fs::path> relpath_candidates;
   fs::path path_suffix;
@@ -140,8 +135,8 @@ path_starts_with(const fs::path& path, const fs::path& prefix)
   // Note: Not all paths on Windows are case insensitive, but for our purposes
   // (checking whether a path is below the base directory) users will expect
   // them to be.
-  fs::path p1 = util::to_lowercase(path.lexically_normal().string());
-  fs::path p2 = util::to_lowercase(prefix.lexically_normal().string());
+  fs::path p1 = util::to_lowercase(util::lexically_normal(path).string());
+  fs::path p2 = util::to_lowercase(util::lexically_normal(prefix).string());
 #else
   const fs::path& p1 = path;
   const fs::path& p2 = prefix;