aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-06-03 14:40:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-06-03 14:40:50 +0200
commitaa8f20ac378e7aa8e3ed71864c5f546c2166c39d (patch)
treeb013fc1634eae8043c2b2e7f386aa10308709f39
parent61ef82ec2b2ca396667f92a4e5c6ceb729c42086 (diff)
Handle special path_map root ('/') on Win32
-rw-r--r--butl/path-map34
1 files changed, 15 insertions, 19 deletions
diff --git a/butl/path-map b/butl/path-map
index f55bf18..fc66002 100644
--- a/butl/path-map
+++ b/butl/path-map
@@ -39,34 +39,30 @@ namespace butl
bool
operator() (const key_type& x, const key_type& y) const
{
- const auto& xs (x.string ());
- const auto& ys (y.string ());
+ const string_type& xs (x.string ());
+ const string_type& ys (y.string ());
-#ifdef _WIN32
return base::compare (xs.c_str (),
- xs.size (),
+ root (xs) ? 0 : xs.size (),
ys.c_str (),
- ys.size ()) < 0;
-#else
- return base::compare (xs.c_str (),
- x.root () ? 0 : xs.size (),
- ys.c_str (),
- y.root () ? 0 : ys.size ()) < 0;
-#endif
+ root (ys) ? 0 : ys.size ()) < 0;
}
bool
prefix (const key_type& p, const key_type& k) const
{
- const auto& ps (p.string ());
- const auto& ks (k.string ());
+ const string_type& ps (p.string ());
+ const string_type& ks (k.string ());
-#ifdef _WIN32
- return base::prefix (ps, ks);
-#else
- return base::prefix (p.root () ? string_type () : ps,
- k.root () ? string_type () : ks);
-#endif
+ return base::prefix (root (ps) ? string_type () : ps,
+ root (ks) ? string_type () : ks);
+ }
+
+ protected:
+ static bool
+ root (const string_type& p)
+ {
+ return p.size () == 1 && key_type::traits::is_separator (p[0]);
}
};