blob: 76051ef4c36875fd05c081243f3be3f032fa1605 [file] [log] [blame] [edit]
From 07f996a95eece4e2b40249e5c8a702f3096ef70f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <mati865@gmail.com>
Date: Sun, 22 Nov 2020 17:49:19 +0100
Subject: [PATCH 2/2] Use posix style path separators with MinGW
---
lib/Support/Path.cpp | 4 ++++
lib/Support/Windows/Path.inc | 5 +++++
lib/Support/Windows/Program.inc | 7 ++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index 37b3086fddf..8ab8e33f248 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -51,8 +51,10 @@ namespace {
}
inline char preferred_separator(Style style) {
+#ifndef __MINGW32__
if (real_style(style) == Style::windows)
return '\\';
+#endif
return '/';
}
@@ -611,8 +613,10 @@ bool is_separator(char value, Style style) {
}
StringRef get_separator(Style style) {
+#ifndef __MINGW32__
if (real_style(style) == Style::windows)
return "\\";
+#endif
return "/";
}
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index e352beb7761..501e252f188 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -146,7 +146,12 @@ std::string getMainExecutable(const char *argv0, void *MainExecAddr) {
if (UTF16ToUTF8(PathName.data(), PathName.size(), PathNameUTF8))
return "";
+#ifndef __MINGW32__
return std::string(PathNameUTF8.data());
+#else
+ return llvm::sys::path::convert_to_slash(std::string(PathNameUTF8.data()),
+ llvm::sys::path::Style::windows);
+#endif
}
UniqueID file_status::getUniqueID() const {
diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc
index 9fe05d24ec2..9e6fe77ca4f 100644
--- a/lib/Support/Windows/Program.inc
+++ b/lib/Support/Windows/Program.inc
@@ -101,8 +101,13 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
if (std::error_code EC =
windows::UTF16ToUTF8(U16Result.data(), U16Result.size(), U8Result))
return EC;
-
+#ifndef __MINGW32__
return std::string(U8Result.begin(), U8Result.end());
+#else
+ return llvm::sys::path::convert_to_slash(
+ std::string(U8Result.begin(), U8Result.end()),
+ llvm::sys::path::Style::windows);
+#endif
}
bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix) {
--
2.29.2.windows.2