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
This commit is contained in:
Rafael Espindola 2014-08-08 21:29:34 +00:00
parent 996a304351
commit a7c6b3a57a

View File

@ -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
}