aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-01-28 02:59:44 +0100
committerJustin M. Keyes <justinkz@gmail.com>2019-02-25 23:47:54 +0100
commit865584dd0c5b34530e44f03d4b42349a83cbca47 (patch)
tree21f29782dae4e4d87022ce85e373e841bbd7989b
parent76562fa19269efb693d952568bccfbb65692dc8d (diff)
downloadrneovim-865584dd0c5b34530e44f03d4b42349a83cbca47.tar.gz
rneovim-865584dd0c5b34530e44f03d4b42349a83cbca47.tar.bz2
rneovim-865584dd0c5b34530e44f03d4b42349a83cbca47.zip
win: os_getenv(): use _wgetenv()
-rw-r--r--src/nvim/os/env.c17
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