aboutsummaryrefslogtreecommitdiff
path: root/bdep/bdep.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-14 22:58:24 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-15 14:18:57 +0300
commitbc1f722b043e654808a95e1d7acb85b86e4aed6a (patch)
treed84b3688940d6f4f9e85cc6a53224e54ba6289de /bdep/bdep.cxx
parent4ff307952533453e1e8650f714b5eb82e407f072 (diff)
Use portable environment variable manipulation functions
Diffstat (limited to 'bdep/bdep.cxx')
-rw-r--r--bdep/bdep.cxx24
1 files changed, 17 insertions, 7 deletions
diff --git a/bdep/bdep.cxx b/bdep/bdep.cxx
index cab10fa..d0327d8 100644
--- a/bdep/bdep.cxx
+++ b/bdep/bdep.cxx
@@ -4,8 +4,6 @@
#ifndef _WIN32
# include <signal.h> // signal()
-#else
-# include <stdlib.h> // getenv(), _putenv()
#endif
#include <cstring> // strcmp()
@@ -36,6 +34,12 @@
using namespace std;
using namespace bdep;
+namespace bdep
+{
+ int
+ main (int argc, char* argv[]);
+}
+
// Initialize the command option class O with the common options and then
// parse the rest of the command line placing non-option arguments to args.
// Once this is done, use the "final" values of the common options to do
@@ -122,7 +126,7 @@ init (const common_options& co, cli::group_scanner& scan, strings& args)
return o;
}
-int
+int bdep::
main (int argc, char* argv[])
try
{
@@ -143,15 +147,15 @@ try
//
#ifdef _WIN32
{
- string mp ("PATH=");
- if (const char* p = getenv ("PATH"))
+ string mp;
+ if (optional<string> p = getenv ("PATH"))
{
- mp += p;
+ mp = move (*p);
mp += ';';
}
mp += "/bin";
- _putenv (mp.c_str ());
+ setenv ("PATH", mp);
}
#endif
@@ -313,3 +317,9 @@ catch (const std::exception& e)
return 1;
}
*/
+
+int
+main (int argc, char* argv[])
+{
+ return bdep::main (argc, argv);
+}