From 9db85faf1486534d7838562afd671269ef93bf07 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Wed, 23 Oct 2019 23:08:15 +0200 Subject: [PATCH] refs #33, fix for lexically_normal --- include/ghc/filesystem.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index ce2ca0e..f926d38 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -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 /= ""; @@ -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(dest.end()), std::reverse_iterator(dest.begin()), suffix)) { - dest._path.pop_back(); - } - } return dest; }