Skip to content

Commit

Permalink
refs #33, fix for lexically_normal
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Oct 23, 2019
1 parent cf51888 commit 9db85fa
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2621,6 +2621,7 @@ GHC_INLINE bool path::is_relative() const
GHC_INLINE path path::lexically_normal() const
{
path dest;
bool lastDotDot = false;
for (const string_type& s : *this) {
if (s == ".") {
dest /= "";
Expand All @@ -2639,17 +2640,14 @@ GHC_INLINE path path::lexically_normal() const
continue;
}
}
dest /= s;
if (!(s.empty() && lastDotDot)) {
dest /= s;
}
lastDotDot = s == "..";
}
if (dest.empty()) {
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;
}

Expand Down

0 comments on commit 9db85fa

Please sign in to comment.