mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0280
patch 8.0.0280: problem setting multi-byte environment var on MS-Windows Problem: On MS-Windows setting an environment variable with multi-byte strings does not work well. Solution: Use wputenv when possible. (Taro Muraoka, Ken Takata) 7c23d1d9d9cc
This commit is contained in:
parent
978c95e5c4
commit
cd5b131575
@ -9,6 +9,7 @@
|
|||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
|
#include "nvim/fileio.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
#include "nvim/message.h"
|
#include "nvim/message.h"
|
||||||
@ -18,6 +19,10 @@
|
|||||||
#include "nvim/ex_getln.h"
|
#include "nvim/ex_getln.h"
|
||||||
#include "nvim/version.h"
|
#include "nvim/version.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE__NSGETENVIRON
|
#ifdef HAVE__NSGETENVIRON
|
||||||
#include <crt_externs.h>
|
#include <crt_externs.h>
|
||||||
#endif
|
#endif
|
||||||
@ -45,7 +50,21 @@ bool os_env_exists(const char *name)
|
|||||||
int os_setenv(const char *name, const char *value, int overwrite)
|
int os_setenv(const char *name, const char *value, int overwrite)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SETENV
|
#ifdef WIN32
|
||||||
|
size_t envbuflen = strlen(name) + strlen(value) + 2;
|
||||||
|
char *envbuf = xmalloc(envbuflen);
|
||||||
|
snprintf(envbuf, envbuflen, "%s=%s", name, value);
|
||||||
|
|
||||||
|
WCHAR *p;
|
||||||
|
utf8_to_utf16(envbuf, &p);
|
||||||
|
xfree(envbuf);
|
||||||
|
if (p == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_wputenv(p);
|
||||||
|
xfree(p); // Unlike Unix systems, we can free the string for _wputenv().
|
||||||
|
return 0;
|
||||||
|
#elif defined(HAVE_SETENV)
|
||||||
return setenv(name, value, overwrite);
|
return setenv(name, value, overwrite);
|
||||||
#elif defined(HAVE_PUTENV_S)
|
#elif defined(HAVE_PUTENV_S)
|
||||||
if (!overwrite && os_getenv(name) != NULL) {
|
if (!overwrite && os_getenv(name) != NULL) {
|
||||||
|
@ -27,6 +27,7 @@ describe('executable()', function()
|
|||||||
clear({env={PATH=[[C:\Windows\system32;C:\Windows]]}})
|
clear({env={PATH=[[C:\Windows\system32;C:\Windows]]}})
|
||||||
print(helpers.eval('$PATH'))
|
print(helpers.eval('$PATH'))
|
||||||
print('XXXXXXXXXXXXXXXXXXXXXXXXX')
|
print('XXXXXXXXXXXXXXXXXXXXXXXXX')
|
||||||
|
print(helpers.eval("echo glob(fnamemodify(exepath(v:progpath), ':h').'/*')"))
|
||||||
eq('arg1=lemon;arg2=sky;arg3=tree;',
|
eq('arg1=lemon;arg2=sky;arg3=tree;',
|
||||||
call('system', sibling_exe..' lemon sky tree'))
|
call('system', sibling_exe..' lemon sky tree'))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user