From: Rafael Espindola Date: Fri, 8 Aug 2014 21:29:34 +0000 (+0000) Subject: Convert from Windows to Unix paths in sys::path::native. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a7c6b3a57ae1b36daa715d852ad4a7223ccdad6f;p=oota-llvm.git 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 --- 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 }