aboutsummaryrefslogtreecommitdiff
path: root/build2/functions-builtin.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-15 12:18:52 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-15 14:28:49 +0300
commitb72f23ce67bc30d3bedbeabcf0b6d9c1fbf2a64f (patch)
tree5972d56a40da992ccd76e91e0ca6c05e7265c8eb /build2/functions-builtin.cxx
parent75313e6fead3b82a4be2d37b341a735f7b61279b (diff)
Use portable environment variable manipulation functions
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)));
};
}
}