diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-08-05 18:20:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-08-05 18:20:38 +0200 |
commit | 772c3a09a8c99c3d032b1564f5da9ebbc766b3f1 (patch) | |
tree | c6a1e83604699e2c1be12ad6e9a1f228dd885713 | |
parent | 67ceaa76da58303843c913b42ee493e33eb42d49 (diff) |
Minor changes
-rw-r--r-- | build2/cc/compile.cxx | 4 | ||||
-rw-r--r-- | build2/scope.cxx | 42 | ||||
-rw-r--r-- | build2/scope.hxx | 5 |
3 files changed, 31 insertions, 20 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 79d40c3..bfc79c9 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -2052,7 +2052,7 @@ namespace build2 if (!pfx_map->empty ()) { dir_path d (f.directory ()); - auto i (pfx_map->find_sub (d)); + auto i (pfx_map->find_sup (d)); if (i != pfx_map->end ()) { @@ -2097,7 +2097,7 @@ namespace build2 { // Find the most qualified prefix of which we are a sub-path. // - auto i (so_map.find_sub (f)); + auto i (so_map.find_sup (f)); if (i != so_map.end ()) { // Ok, there is an out tree for this headers. Remap to a path 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 } } diff --git a/build2/scope.hxx b/build2/scope.hxx index 2be2b3a..028dbce 100644 --- a/build2/scope.hxx +++ b/build2/scope.hxx @@ -336,6 +336,11 @@ namespace build2 // directory (i.e., the calling code does not know what it is dealing // with), so let's use the whole path. // + // In fact, ideally, we should have used path_map instead of + // dir_path_map to be able to search for both paths without any casting + // (and copies). But currently we have too much stuff pointing to the + // key. + // return find (path_cast<dir_path> (p)); } |