refs #33, fix for lexically_normal

This commit is contained in:
Steffen Schuemann 2019-10-23 23:08:15 +02:00
parent cf5188899b
commit 9db85faf14

View File

@ -2621,6 +2621,7 @@ GHC_INLINE bool path::is_relative() const
GHC_INLINE path path::lexically_normal() const GHC_INLINE path path::lexically_normal() const
{ {
path dest; path dest;
bool lastDotDot = false;
for (const string_type& s : *this) { for (const string_type& s : *this) {
if (s == ".") { if (s == ".") {
dest /= ""; dest /= "";
@ -2639,17 +2640,14 @@ GHC_INLINE path path::lexically_normal() const
continue; continue;
} }
} }
dest /= s; if (!(s.empty() && lastDotDot)) {
dest /= s;
}
lastDotDot = s == "..";
} }
if (dest.empty()) { if (dest.empty()) {
dest = "."; dest = ".";
} }
else {
static const path suffix[2] = {"", ".."};
if(std::equal(std::reverse_iterator<path::const_iterator>(dest.end()), std::reverse_iterator<path::const_iterator>(dest.begin()), suffix)) {
dest._path.pop_back();
}
}
return dest; return dest;
} }