[llvm] r215241 - Convert from Windows to Unix paths in sys::path::native.
Rafael Espindola
rafael.espindola at gmail.com
Fri Aug 8 14:29:34 PDT 2014
Author: rafael
Date: Fri Aug 8 16:29:34 2014
New Revision: 215241
URL: http://llvm.org/viewvc/llvm-project?rev=215241&view=rev
Log:
Convert from Windows to Unix paths in sys::path::native.
Part of pr20544. Test to follow in a second.
Modified:
llvm/trunk/lib/Support/Path.cpp
Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=215241&r1=215240&r2=215241&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Fri Aug 8 16:29:34 2014
@@ -540,9 +540,19 @@ void native(const Twine &path, SmallVect
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
}
More information about the llvm-commits
mailing list