diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-01-28 02:59:44 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-02-25 23:47:54 +0100 |
commit | 865584dd0c5b34530e44f03d4b42349a83cbca47 (patch) | |
tree | 21f29782dae4e4d87022ce85e373e841bbd7989b | |
parent | 76562fa19269efb693d952568bccfbb65692dc8d (diff) | |
download | rneovim-865584dd0c5b34530e44f03d4b42349a83cbca47.tar.gz rneovim-865584dd0c5b34530e44f03d4b42349a83cbca47.tar.bz2 rneovim-865584dd0c5b34530e44f03d4b42349a83cbca47.zip |
win: os_getenv(): use _wgetenv()
-rw-r--r-- | src/nvim/os/env.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 6cf48eb814..4f14e4eee3 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -36,8 +36,25 @@ const char *os_getenv(const char *name) FUNC_ATTR_NONNULL_ALL { +#if !defined(WIN32) const char *e = getenv(name); return e == NULL || *e == NUL ? NULL : e; +#else + wchar_t *wname; + utf8_to_utf16(name, &wname); + if (wname == NULL) { + xfree(wname); + return NULL; + } + wchar_t *wvalue = _wgetenv(wname); + char *value; + int rv = utf16_to_utf8(wvalue, &value); + if (rv != 0 || *value == NUL) { + xfree(value); + return NULL; + } + return value; // TODO(jmk): this was allocated, but callers don't free it ... +#endif } /// Returns `true` if the environment variable, `name`, has been defined |