From f15dea96950003a94cc33b73298d9e80ed2f2522 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Mon, 5 Oct 2020 21:59:29 +0200 Subject: [PATCH 1/2] refs #70, fix for missed issue and mingw errors --- include/ghc/filesystem.hpp | 9 ++++++--- test/filesystem_test.cpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index f84befe..1f1ee33 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -184,7 +184,7 @@ // * else result of element wise comparison of path iteration where first comparison is != 0 or 0 // if all comparisons are 0 (on Windows this implementation does case insensitive root_name() // comparison) -// #define LWG_2936_BEHAVIOUR +#define LWG_2936_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2937 enforces that fs::equivalent emits an error, if !fs::exists(p1)||!exists(p2) #define LWG_2937_BEHAVIOUR @@ -2719,10 +2719,13 @@ GHC_INLINE int path::compare(const path& p) const noexcept auto rnl1 = root_name_length(); auto rnl2 = p.root_name_length(); auto rnc = detail::compare_simple_insensitive(_path.c_str(), rnl1, p._path.c_str(), rnl2); + if(rnc) { + return rnc; + } auto p1 = _path; - std::replace(p1.begin()+rnl1, p1.end(), '/', '\\'); + std::replace(p1.begin()+static_cast(rnl1), p1.end(), '/', '\\'); auto p2 = p._path; - std::replace(p2.begin()+rnl2, p2.end(), '/', '\\'); + std::replace(p2.begin()+static_cast(rnl2), p2.end(), '/', '\\'); return p1.compare(rnl1, std::string::npos, p2, rnl2, std::string::npos); #else return _path.compare(p._path); diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index e4b6a47..b3dc1d3 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -618,6 +618,7 @@ TEST_CASE("30.10.8.4.8 path compare", "[filesystem][path][fs.path.compare]") #ifdef GHC_OS_WINDOWS CHECK(fs::path("c:\\a\\b").compare("C:\\a\\b") == 0); + CHECK(fs::path("c:\\a\\b").compare("d:\\a\\b") != 0); CHECK(fs::path("c:\\a\\b").compare("C:\\A\\b") != 0); #endif From a22c0a94d0e17e854e0712cc3a5cdf2bad2920ba Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Mon, 5 Oct 2020 22:41:46 +0200 Subject: [PATCH 2/2] refs #70, mingw compile fix --- include/ghc/filesystem.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 1f1ee33..bedcf34 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -2695,8 +2695,8 @@ GHC_INLINE int path::compare(const path& p) const noexcept ++rnl1; ++rnl2; } - auto iter1 = _path.begin() + rnl1; - auto iter2 = p._path.begin() + rnl2; + auto iter1 = _path.begin() + static_cast(rnl1); + auto iter2 = p._path.begin() + static_cast(rnl2); while (iter1 != _path.end() && iter2 != p._path.end() && *iter1 == *iter2) { ++iter1; ++iter2;