aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/env.c
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2014-06-08 19:57:18 +0100
committerSeth Jackson <sethjackson@gmail.com>2015-12-12 22:33:10 -0500
commit810d31a43001e0955a0a3194998afcc9a0ed33ec (patch)
tree90ca7f70057a79e5bf5370dc29954262c4f35eff /src/nvim/os/env.c
parentf183cc14de40542899f1bad44943695b0ccf0e5c (diff)
downloadrneovim-810d31a43001e0955a0a3194998afcc9a0ed33ec.tar.gz
rneovim-810d31a43001e0955a0a3194998afcc9a0ed33ec.tar.bz2
rneovim-810d31a43001e0955a0a3194998afcc9a0ed33ec.zip
Windows: Implement os_setenv() using _putenv_s()
Windows does not have setenv(), instead the _putenv_s() function is used - added a function check and fatal errors. Implemented os_setenv() for Windows. Vim supports the original putenv() function if no alternative is available. Neovim only supports systems where safer alternatives exist, so the check for putenv() was removed from config/CMakeLists.txt.
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r--src/nvim/os/env.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 0e052ced55..a791dca39c 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -46,7 +46,19 @@ bool os_env_exists(const char *name)
int os_setenv(const char *name, const char *value, int overwrite)
FUNC_ATTR_NONNULL_ALL
{
+#ifdef HAVE_SETENV
return setenv(name, value, overwrite);
+#elif defined(HAVE_PUTENV_S)
+ if (!overwrite && os_getenv(name) != NULL) {
+ return 0;
+ }
+ if (_putenv_s(name, value) == 0) {
+ return 0;
+ }
+ return -1;
+#else
+# error "This system has no implementation available for os_setenv()"
+#endif
}
/// Unset environment variable