aboutsummaryrefslogtreecommitdiff
path: root/bpkg/database.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-15 11:55:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-15 14:21:10 +0300
commit02ada52a38576331f58744ffa83d9cbba6b53827 (patch)
tree0ab02eef86106f7568e6b487719521e3126f5fa9 /bpkg/database.cxx
parent3a0917dc2e05e8c0a48b12adf19fa2ee9a4a91f8 (diff)
Use portable environment variable manipulation functions
Diffstat (limited to 'bpkg/database.cxx')
-rw-r--r--bpkg/database.cxx14
1 files changed, 2 insertions, 12 deletions
diff --git a/bpkg/database.cxx b/bpkg/database.cxx
index f5102f0..3c55237 100644
--- a/bpkg/database.cxx
+++ b/bpkg/database.cxx
@@ -4,8 +4,6 @@
#include <bpkg/database.hxx>
-#include <stdlib.h> // getenv() setenv()/_putenv()
-
#include <odb/schema-catalog.hxx>
#include <odb/sqlite/exceptions.hxx>
@@ -25,7 +23,7 @@ namespace bpkg
// BPKG_OPEN_CONFIG environment variable. A bit heavy-weight but seems like
// the best option.
//
- static const char open_name[] = "BPKG_OPEN_CONFIG";
+ static const string open_name ("BPKG_OPEN_CONFIG");
class conn_factory: public single_connection_factory // No need for pool.
{
@@ -36,21 +34,13 @@ namespace bpkg
v.complete ();
v.normalize ();
-#ifndef _WIN32
- setenv (open_name, v.string ().c_str (), 1 /* overwrite */);
-#else
- _putenv ((string (open_name) + '=' + v.string ()).c_str ());
-#endif
+ setenv (open_name, v.string ());
}
virtual
~conn_factory ()
{
-#ifndef _WIN32
unsetenv (open_name);
-#else
- _putenv ((string (open_name) + '=').c_str ());
-#endif
}
};