diff options
author | Matthieu Coudron <mattator@gmail.com> | 2018-11-09 23:57:00 +0900 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2019-12-11 21:07:13 -0500 |
commit | 19b6237087ebcf45427ceb6943d23ce33b39567f (patch) | |
tree | f333dc24b4d91f691c8ba38f1582ff3d58ce71fd /src/nvim/os/env.c | |
parent | f3fcaedfad59684e6f57ff0bb131b75a3c7fdcaa (diff) | |
download | rneovim-19b6237087ebcf45427ceb6943d23ce33b39567f.tar.gz rneovim-19b6237087ebcf45427ceb6943d23ce33b39567f.tar.bz2 rneovim-19b6237087ebcf45427ceb6943d23ce33b39567f.zip |
jobstart now supports env/clear_env
to modify the environment of the launched job.
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r-- | src/nvim/os/env.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index eb86cb8ac7..15153e9bd7 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -184,7 +184,7 @@ int os_unsetenv(const char *name) return r == 0 ? 0 : -1; } -char *os_getenvname_at_index(size_t index) +char **os_getfullenv(void) { #ifdef _WIN32 wchar_t *env = GetEnvironmentStringsW(); @@ -224,13 +224,20 @@ char *os_getenvname_at_index(size_t index) # else extern char **environ; # endif - // Check if index is inside the environ array and is not the last element. + return environ; +} + +char *os_getenvname_at_index(size_t index) +{ + char **env = os_getfullenv(); + // check if index is inside the environ array for (size_t i = 0; i <= index; i++) { - if (environ[i] == NULL) { + if (env[i] == NULL) { return NULL; } } - char *str = environ[index]; + char *str = env[index]; + assert(str != NULL); size_t namesize = 0; while (str[namesize] != '=' && str[namesize] != NUL) { namesize++; |