From 772c3a09a8c99c3d032b1564f5da9ebbc766b3f1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 5 Aug 2017 18:20:38 +0200 Subject: Minor changes --- build2/scope.cxx | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'build2/scope.cxx') 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 (*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 } } -- cgit v1.1