From 8d2e541ab1aa24140eb680fb046e49a4a3f0bbd2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 Oct 2016 14:51:27 +0200 Subject: Various design/implementation cleanups --- build2/variable.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'build2/variable.cxx') 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 (r).visibility = v; // Not changing the key. + const_cast (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"; } -- cgit v1.1