aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-03-29 10:25:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-03-29 10:25:10 +0200
commit441c75f68ca1adfcf833ae778ac150baf16ded2f (patch)
treead7e8aa46c9e389459e0edcc2d5d7861204c5dcc
parentf7ff90672af84a83829371f04f961b389823414c (diff)
Add variable_map::lookup_namespace(string) overload
-rw-r--r--libbuild2/config/init.cxx4
-rw-r--r--libbuild2/config/operation.cxx2
-rw-r--r--libbuild2/config/utility.cxx6
-rw-r--r--libbuild2/variable.hxx10
4 files changed, 14 insertions, 8 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index 0472cfd..5dd2789 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -175,10 +175,6 @@ namespace build2
if (!d)
{
- // Used as a variable prefix by configure_execute().
- //
- vp.insert ("config");
-
// Adjust priority for the config module and import pseudo-module so
// that their variables come first in config.build.
//
diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx
index 2fb0423..4597af4 100644
--- a/libbuild2/config/operation.cxx
+++ b/libbuild2/config/operation.cxx
@@ -209,7 +209,7 @@ namespace build2
//
auto& vp (ctx.var_pool);
- for (auto p (rs.vars.lookup_namespace (*vp.find ("config")));
+ for (auto p (rs.vars.lookup_namespace ("config"));
p.first != p.second;
++p.first)
{
diff --git a/libbuild2/config/utility.cxx b/libbuild2/config/utility.cxx
index 928709a..a78b263 100644
--- a/libbuild2/config/utility.cxx
+++ b/libbuild2/config/utility.cxx
@@ -91,7 +91,7 @@ namespace build2
// any original values, they will be "visible"; see find_override() for
// details.
//
- const variable& ns (vp.insert ("config." + n));
+ const string ns ("config." + n);
for (scope* s (&rs); s != nullptr; s = s->parent_scope ())
{
for (auto p (s->vars.lookup_namespace (ns));
@@ -107,12 +107,12 @@ namespace build2
auto match_tail = [&ns, v] (const char* t)
{
- return v->name.compare (ns.name.size () + 1, string::npos, t) == 0;
+ return v->name.compare (ns.size () + 1, string::npos, t) == 0;
};
// Ignore config.*.configured and user-supplied names.
//
- if (v->name.size () <= ns.name.size () ||
+ if (v->name.size () <= ns.size () ||
(!match_tail ("configured") &&
find_if (ig.begin (), ig.end (), match_tail) == ig.end ()))
return true;
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx
index 54d573b..2bfab05 100644
--- a/libbuild2/variable.hxx
+++ b/libbuild2/variable.hxx
@@ -1574,6 +1574,16 @@ namespace build2
const_iterator (r.second, *this));
}
+ pair<const_iterator, const_iterator>
+ lookup_namespace (string ns) const
+ {
+ // It's ok to use the temporary here since we compare names and don't
+ // insert anything.
+ //
+ return lookup_namespace (variable {
+ move (ns), nullptr, nullptr, nullptr, variable_visibility::project});
+ }
+
// Convert a lookup pointing to a value belonging to this variable map
// to its non-const version. Note that this is only safe on the original
// values (see lookup_original()).