diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-08 21:29:34 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-08 21:29:34 +0000 |
commit | d649b9d4af9b3aa667208ba3dcecd472e2a88273 (patch) | |
tree | ac22bb3c3c8f07146850dd9c696db1480b84cd7a /llvm/lib/Support/Path.cpp | |
parent | eb9d13fcd11914252a2fd801273ccc002e653e93 (diff) | |
download | bcm5719-llvm-d649b9d4af9b3aa667208ba3dcecd472e2a88273.tar.gz bcm5719-llvm-d649b9d4af9b3aa667208ba3dcecd472e2a88273.zip |
Convert from Windows to Unix paths in sys::path::native.
Part of pr20544. Test to follow in a second.
llvm-svn: 215241
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 2dd6741c735..bc6543a5722 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -540,9 +540,19 @@ void native(const Twine &path, SmallVectorImpl<char> &result) { native(result); } -void native(SmallVectorImpl<char> &path) { +void native(SmallVectorImpl<char> &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 } |