mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 22:36:09 +00:00
win: os_getenv(): use _wgetenv()
This commit is contained in:
@@ -36,8 +36,25 @@
|
|||||||
const char *os_getenv(const char *name)
|
const char *os_getenv(const char *name)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
|
#if !defined(WIN32)
|
||||||
const char *e = getenv(name);
|
const char *e = getenv(name);
|
||||||
return e == NULL || *e == NUL ? NULL : e;
|
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
|
/// Returns `true` if the environment variable, `name`, has been defined
|
||||||
|
Reference in New Issue
Block a user