aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-23 09:05:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-23 09:05:54 +0200
commitbd32ea47fd8f720b54f81a769dc007d1fdb4e5c1 (patch)
treeefd3aec2fd1e2fd65b0262470de5a2e82d9c8449 /build2/variable.cxx
parentce030e8bf6a8f278eb3a571aef0f0df18875daa7 (diff)
Reverse empty simple values as an empty names sequence rather than empty name
This way we get: config.import.foo = Rather than: config.import.foo = {}
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r--build2/variable.cxx27
1 files changed, 16 insertions, 11 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 7a13618..0134683 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -643,7 +643,8 @@ namespace build2
static names_view
name_reverse (const value& v, names&)
{
- return names_view (&v.as<name> (), 1);
+ const name& n (v.as<name> ());
+ return n.empty () ? names_view (nullptr, 0) : names_view (&n, 1);
}
const char* const value_traits<name>::type_name = "name";
@@ -726,19 +727,23 @@ namespace build2
static names_view
process_path_reverse (const value& v, names& s)
{
- auto& pp (v.as<process_path> ());
- s.reserve (pp.effect.empty () ? 1 : 2);
+ const process_path& x (v.as<process_path> ());
- s.push_back (name (pp.recall.directory (),
- string (),
- pp.recall.leaf ().string ()));
-
- if (!pp.effect.empty ())
+ if (!x.empty ())
{
- s.back ().pair = '@';
- s.push_back (name (pp.effect.directory (),
+ s.reserve (x.effect.empty () ? 1 : 2);
+
+ s.push_back (name (x.recall.directory (),
string (),
- pp.effect.leaf ().string ()));
+ x.recall.leaf ().string ()));
+
+ if (!x.effect.empty ())
+ {
+ s.back ().pair = '@';
+ s.push_back (name (x.effect.directory (),
+ string (),
+ x.effect.leaf ().string ()));
+ }
}
return s;