From b3f1c19cfb79b2d913fa30d4dd5d23af66d60f38 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Fri, 8 Nov 2024 16:36:52 +0100 Subject: [PATCH] refactor: Use util::lexically_normal --- src/ccache/config.cpp | 2 +- src/ccache/util/path.cpp | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/ccache/config.cpp b/src/ccache/config.cpp index 2cfb300f..e69a9aa2 100644 --- a/src/ccache/config.cpp +++ b/src/ccache/config.cpp @@ -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; diff --git a/src/ccache/util/path.cpp b/src/ccache/util/path.cpp index fb1b8e7f..f23db8a0 100644 --- a/src/ccache/util/path.cpp +++ b/src/ccache/util/path.cpp @@ -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 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; -- 2.47.2