aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-01-28 11:02:15 +0100
committerJustin M. Keyes <justinkz@gmail.com>2019-02-26 22:38:52 +0100
commit1d8e7683604828592bd41cdac5a351145cd93487 (patch)
tree5e1faaf2da6e92ecfcbe5e7dd37b8b284a8d0849 /src
parent865584dd0c5b34530e44f03d4b42349a83cbca47 (diff)
downloadrneovim-1d8e7683604828592bd41cdac5a351145cd93487.tar.gz
rneovim-1d8e7683604828592bd41cdac5a351145cd93487.tar.bz2
rneovim-1d8e7683604828592bd41cdac5a351145cd93487.zip
os_getenv, os_setenv: revert "widechar" impl
It's reported that the Windows widechar variants do automatically convert from the current codepage to UTF16, which is very helpful. So the "widechar" impls are a good direction. But libuv v1.12 does that for us, so the next commit will use that instead. ref #8398 ref #9267
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/env.c33
1 files changed, 2 insertions, 31 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 4f14e4eee3..cbbd36dc8e 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -36,25 +36,8 @@
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
@@ -72,21 +55,9 @@ int os_setenv(const char *name, const char *value, int overwrite)
if (!overwrite && os_getenv(name) != NULL) {
return 0;
}
- wchar_t *wname;
- utf8_to_utf16(name, &wname);
- if (wname == NULL) {
- return -1;
- }
- wchar_t *wvalue;
- utf8_to_utf16(value, &wvalue);
- if (wvalue == NULL) {
- return -1;
- }
- int rv = (int)_wputenv_s(wname, wvalue);
- xfree(wname); // Unlike unix putenv(), we can free after _wputenv_s().
- xfree(wvalue);
+ int rv = (int)_putenv_s(name, value);
if (rv != 0) {
- ELOG("_wputenv_s failed: %d: %s", rv, uv_strerror(rv));
+ ELOG("_putenv_s failed: %d: %s", rv, uv_strerror(rv));
return -1;
}
return 0;