aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-name.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-12-14 08:03:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-12-14 08:03:32 +0200
commit218a739b33325c5dd6baa5cf6291dad849ad2441 (patch)
tree754661d712d80d87c1c113cb7bfd6ec542e5858b /libbuild2/functions-name.cxx
parent6d892e32a83908406a6f2fc6d47dd4a8b131fc60 (diff)
Handle NULL values in $string() and $concat() functions
This is relied upon by the parser to provide conversion/concatenation semantics consistent with untyped values. Note that we handle NULL values only for types that have empty representation.
Diffstat (limited to 'libbuild2/functions-name.cxx')
-rw-r--r--libbuild2/functions-name.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx
index 9011cc0..84608d4 100644
--- a/libbuild2/functions-name.cxx
+++ b/libbuild2/functions-name.cxx
@@ -142,7 +142,13 @@ namespace build2
//
function_family fn (m, "name");
- fn["string"] += [](name n) {return to_string (n);};
+ // Note that we must handle NULL values (relied upon by the parser
+ // to provide conversion semantics consistent with untyped values).
+ //
+ fn["string"] += [](name* n)
+ {
+ return n != nullptr ? to_string (move (*n)) : string ();
+ };
fn["name"] += [](const scope* s, name n)
{
@@ -438,6 +444,11 @@ namespace build2
//
function_family fb (m, "builtin");
+ // Note that while we should normally handle NULL values (relied upon by
+ // the parser to provide concatenation semantics consistent with untyped
+ // values), the result will unlikely be what the user expected. So for now
+ // we keep it a bit tighter.
+ //
fb[".concat"] += [](dir_path d, name n)
{
d /= n.dir;