diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-05 23:31:21 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-07-24 23:17:28 -0400 |
commit | 5ed0975ea2366dab642f2b962df9fbeca319a79e (patch) | |
tree | 03937c6f77c5dda0558460134240e7092d36a516 /src/nvim/os | |
parent | b0ab46056fe907b4657fe57140c61d540d23b3ca (diff) | |
download | rneovim-5ed0975ea2366dab642f2b962df9fbeca319a79e.tar.gz rneovim-5ed0975ea2366dab642f2b962df9fbeca319a79e.tar.bz2 rneovim-5ed0975ea2366dab642f2b962df9fbeca319a79e.zip |
vim-patch:8.0.1012: MS-Windows: problem with $HOME when is was set internally
Problem: MS-Windows: Problem with $HOME when is was set internally.
Solution: Only use the $HOME default internally. (Yasuhiro Matsumoto, closes
vim/vim#2013)
https://github.com/vim/vim/commit/48340b62e812dc9280f621a2eb6db76d43555c66
Restore vim_getenv() behaviour for $HOME on Windows.
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/env.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 0df857352b..6997156d4c 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -196,16 +196,19 @@ void init_homedir(void) const char *homedrive = os_getenv("HOMEDRIVE"); const char *homepath = os_getenv("HOMEPATH"); if (homepath == NULL) { - homepath = "\\"; + homepath = "\\"; } - if (homedrive != NULL && strlen(homedrive) + strlen(homepath) < MAXPATHL) { + if (homedrive != NULL + && strlen(homedrive) + strlen(homepath) < MAXPATHL) { snprintf(os_buf, MAXPATHL, "%s%s", homedrive, homepath); if (os_buf[0] != NUL) { var = os_buf; - vim_setenv("HOME", os_buf); } } } + if (var == NULL) { + var = os_getenv("USERPROFILE"); + } #endif if (var != NULL) { @@ -608,6 +611,12 @@ char *vim_getenv(const char *name) return xstrdup(kos_env_path); } +#ifdef WIN32 + if (strcmp(name, "HOME") == 0) { + return xstrdup(homedir); + } +#endif + bool vimruntime = (strcmp(name, "VIMRUNTIME") == 0); if (!vimruntime && strcmp(name, "VIM") != 0) { return NULL; @@ -758,7 +767,12 @@ size_t home_replace(const buf_T *const buf, const char_u *src, dirlen = strlen(homedir); } - const char *const homedir_env = os_getenv("HOME"); + const char *homedir_env = os_getenv("HOME"); +#ifdef WIN32 + if (homedir_env == NULL) { + homedir_env = os_getenv("USERPROFILE"); + } +#endif char *homedir_env_mod = (char *)homedir_env; bool must_free = false; |