aboutsummaryrefslogtreecommitdiff
path: root/build2/scope.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/scope.cxx')
-rw-r--r--build2/scope.cxx42
1 files changed, 24 insertions, 18 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx
index 1cbb815..6b6b18a 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -788,29 +788,35 @@ namespace build2
return er.first;
}
- // Find the most qualified scope that encompasses this path.
- //
scope& scope_map::
find (const dir_path& k)
{
scope_map_base& m (*this);
- // Normally we would have a scope for the full path so try that before
- // making any copies.
+ // Better implementation that should work but doesn't.
//
- auto i (m.find (k)), e (m.end ());
-
- if (i != e)
- return i->second;
-
- for (dir_path d (k.directory ());; d = d.directory ())
- {
- auto i (m.find (d));
-
- if (i != e)
- return i->second;
-
- assert (!d.empty ()); // We should have the global scope.
- }
+#if 0
+ assert (k.normalized (false)); // Allow non-canonical dir separators.
+ auto i (m.find_sup (k));
+ return i != m.end () ? i->second : const_cast<scope&> (*global_scope);
+#else
+ // Normally we would have a scope for the full path so try that before
+ // making any copies.
+ //
+ auto i (m.find (k)), e (m.end ());
+
+ if (i != e)
+ return i->second;
+
+ for (dir_path d (k.directory ());; d = d.directory ())
+ {
+ auto i (m.find (d));
+
+ if (i != e)
+ return i->second;
+
+ assert (!d.empty ()); // We should have the global scope.
+ }
+#endif
}
}