aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-12 14:51:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 08:05:07 +0200
commit8d2e541ab1aa24140eb680fb046e49a4a3f0bbd2 (patch)
tree57401f85aeaa2e3d53534bcb9df007dffafccbac /build2/variable.cxx
parent04e382b0af66057f19c6dce66c43316cbd3cb23c (diff)
Various design/implementation cleanups
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r--build2/variable.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 0134683..cf274be 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -437,7 +437,7 @@ namespace build2
if (n.directory (true))
// Use either the precise or traditional representation depending on
- // whethe this is the original name (if it is, then this might not be
+ // whether this is the original name (if it is, then this might not be
// a path after all; think s/foo/bar/).
//
s = n.original
@@ -773,11 +773,18 @@ namespace build2
const variable& variable_pool::
insert (string n,
const build2::value_type* t,
- variable_visibility v,
- bool o)
+ const variable_visibility* v,
+ const bool* o)
{
- auto p (variable_pool_base::insert (variable {move (n), t, nullptr, v}));
- const variable& r (*p.first);
+ auto p (
+ insert (
+ variable {
+ move (n),
+ t,
+ nullptr,
+ v != nullptr ? *v : variable_visibility::normal}));
+
+ const variable& r (p.first->second);
if (!p.second)
{
@@ -794,16 +801,16 @@ namespace build2
// were set, in which case the variable will be entered with the
// default visibility.
//
- if (r.visibility != v)
+ if (v != nullptr && r.visibility != *v)
{
assert (r.visibility == variable_visibility::normal); // Default.
- const_cast<variable&> (r).visibility = v; // Not changing the key.
+ const_cast<variable&> (r).visibility = *v; // Not changing the key.
}
// Check overridability (all overrides, if any, should already have
// been enetered (see context.cxx:reset()).
//
- if (r.override != nullptr && !o)
+ if (o != nullptr && r.override != nullptr && !*o)
fail << "variable " << r.name << " cannot be overridden";
}