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