From a7c6b3a57ae1b36daa715d852ad4a7223ccdad6f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 8 Aug 2014 21:29:34 +0000 Subject: [PATCH] Convert from Windows to Unix paths in sys::path::native. Part of pr20544. Test to follow in a second. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215241 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Path.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 2dd6741c735..bc6543a5722 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -540,9 +540,19 @@ void native(const Twine &path, SmallVectorImpl &result) { native(result); } -void native(SmallVectorImpl &path) { +void native(SmallVectorImpl &Path) { #ifdef LLVM_ON_WIN32 std::replace(path.begin(), path.end(), '/', '\\'); +#else + for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI) { + if (*PI == '\\') { + auto PN = PI + 1; + if (PN < PE && *PN == '\\') + ++PI; // increment once, the for loop will move over the escaped slash + else + *PI = '/'; + } + } #endif } -- 2.11.0