|| is_dir_separator(dir_prefix_or_file.back()));
}
-std::string
-normalize_abstract_absolute_path(std::string_view path)
+static std::string
+do_normalize_abstract_absolute_path(std::string_view path)
{
if (!util::is_absolute_path(path)) {
return std::string(path);
}
#ifdef _WIN32
- if (path.find("\\") != std::string_view::npos) {
- std::string new_path(path);
- std::replace(new_path.begin(), new_path.end(), '\\', '/');
- return normalize_abstract_absolute_path(new_path);
- }
-
std::string drive(path.substr(0, 2));
path = path.substr(2);
#endif
#endif
}
+std::string
+normalize_abstract_absolute_path(std::string_view path)
+{
+#ifdef _WIN32
+ std::string new_path(path);
+ std::replace(new_path.begin(), new_path.end(), '\\', '/');
+ return do_normalize_abstract_absolute_path(new_path);
+#else
+ return do_normalize_abstract_absolute_path(path);
+#endif
+}
+
std::string
normalize_concrete_absolute_path(const std::string& path)
{
static std::optional<Digest>
result_key_from_includes(Context& ctx, Hash& hash, std::string_view stdout_data)
{
- for (std::string_view token : core::MsvcShowIncludesOutput::get_includes(
+ for (std::string_view include : core::MsvcShowIncludesOutput::get_includes(
stdout_data, ctx.config.msvc_dep_prefix())) {
- const std::string path = Util::make_relative_path(ctx, token);
+ const std::string path = Util::make_relative_path(
+ ctx, Util::normalize_abstract_absolute_path(include));
remember_include_file(ctx, path, hash, false, &hash);
}
if (path[i] == '\\' && prefix[j] == '/') {
continue;
}
-#endif
+ if (std::tolower(path[i]) != std::tolower(prefix[j])) {
+ return false;
+ }
+#else
if (path[i] != prefix[j]) {
return false;
}
+#endif
}
return true;
}
std::string posix;
// /-escape volume.
- if (path[0] >= 'A' && path[0] <= 'Z' && path[1] == ':') {
+ if (path[1] == ':'
+ && ((path[0] >= 'A' && path[0] <= 'Z')
+ || (path[0] >= 'a' && path[0] <= 'z'))) {
posix = "/" + path;
} else {
posix = path;
CHECK(util::path_starts_with("C:/foo/bar", "C:\\\\foo"));
CHECK(util::path_starts_with("C:\\foo\\bar", "C:/foo"));
CHECK(util::path_starts_with("C:\\\\foo\\\\bar", "C:/foo"));
+ CHECK(util::path_starts_with("C:/FOO/BAR", "c:\\foo"));
+ CHECK(util::path_starts_with("c:/foo/bar", "C:\\FOO"));
CHECK(!util::path_starts_with("C:\\foo\\bar", "/foo/baz"));
CHECK(!util::path_starts_with("C:\\foo\\bar", "C:/foo/baz"));
CHECK(!util::path_starts_with("C:\\beh\\foo", "/foo"));