Skip to content

Commit

Permalink
refs #70, fix for missed issue and mingw errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Oct 5, 2020
1 parent 56b5e7a commit f15dea9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<int>(rnl1), p1.end(), '/', '\\');
auto p2 = p._path;
std::replace(p2.begin()+rnl2, p2.end(), '/', '\\');
std::replace(p2.begin()+static_cast<int>(rnl2), p2.end(), '/', '\\');
return p1.compare(rnl1, std::string::npos, p2, rnl2, std::string::npos);
#else
return _path.compare(p._path);
Expand Down
1 change: 1 addition & 0 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f15dea9

Please sign in to comment.