aboutsummaryrefslogtreecommitdiff
path: root/build2/functions-builtin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/functions-builtin.cxx')
-rw-r--r--build2/functions-builtin.cxx16
1 files changed, 6 insertions, 10 deletions
diff --git a/build2/functions-builtin.cxx b/build2/functions-builtin.cxx
index 350bddf..45ad7df 100644
--- a/build2/functions-builtin.cxx
+++ b/build2/functions-builtin.cxx
@@ -2,28 +2,24 @@
// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
-#include <cstdlib> // getenv()
-
#include <build2/function.hxx>
#include <build2/variable.hxx>
-using namespace std;
-
namespace build2
{
// Return NULL value if an environment variable is not set, untyped value
// otherwise.
//
static inline value
- getenv (const string& name)
+ getvar (const string& name)
{
- const char* v (::getenv (name.c_str ()));
+ optional<string> v (getenv (name));
- if (v == nullptr)
+ if (!v)
return value ();
names r;
- r.emplace_back (to_name (v));
+ r.emplace_back (to_name (*v));
return value (move (r));
}
@@ -49,12 +45,12 @@ namespace build2
//
f["getenv"] = [](string name)
{
- return getenv (name);
+ return getvar (name);
};
f["getenv"] = [](names name)
{
- return getenv (convert<string> (move (name)));
+ return getvar (convert<string> (move (name)));
};
}
}