|
|
@@ -3394,15 +3394,16 @@ static void SystemToolsAppendComponents(
|
|
|
static const std::string cur = ".";
|
|
|
for (std::vector<std::string>::const_iterator i = first; i != last; ++i) {
|
|
|
if (*i == up) {
|
|
|
- if (out_components.size() > 1) {
|
|
|
+ // Remove the previous component if possible. Ignore ../ components
|
|
|
+ // that try to go above the root. Keep ../ components if they are
|
|
|
+ // at the beginning of a relative path (base path is relative).
|
|
|
+ if (out_components.size() > 1 && out_components.back() != up) {
|
|
|
out_components.resize(out_components.size() - 1);
|
|
|
+ } else if (!out_components.empty() && out_components[0].empty()) {
|
|
|
+ out_components.emplace_back(std::move(*i));
|
|
|
}
|
|
|
} else if (!i->empty() && *i != cur) {
|
|
|
-#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
|
|
|
- out_components.push_back(std::move(*i));
|
|
|
-#else
|
|
|
- out_components.push_back(*i);
|
|
|
-#endif
|
|
|
+ out_components.emplace_back(std::move(*i));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -4738,7 +4739,7 @@ void SystemTools::ClassInitialize()
|
|
|
// Test progressively shorter logical-to-physical mappings.
|
|
|
std::string cwd_str = cwd;
|
|
|
std::string pwd_path;
|
|
|
- Realpath(pwd_str.c_str(), pwd_path);
|
|
|
+ Realpath(pwd_str, pwd_path);
|
|
|
while (cwd_str == pwd_path && cwd_str != pwd_str) {
|
|
|
// The current pair of paths is a working logical mapping.
|
|
|
cwd_changed = cwd_str;
|
|
|
@@ -4748,7 +4749,7 @@ void SystemTools::ClassInitialize()
|
|
|
// mapping still works.
|
|
|
pwd_str = SystemTools::GetFilenamePath(pwd_str);
|
|
|
cwd_str = SystemTools::GetFilenamePath(cwd_str);
|
|
|
- Realpath(pwd_str.c_str(), pwd_path);
|
|
|
+ Realpath(pwd_str, pwd_path);
|
|
|
}
|
|
|
|
|
|
// Add the translation to keep the logical path name.
|