getenv: return NULL if empty #2574

Making an environment variable empty can be a way of unsetting it for
platforms that don't support unsetenv(). In most cases, we treat empty
variables as having been unset. For all others, use os_env_exists().
This commit is contained in:
Scott Prager
2015-05-03 09:25:53 -04:00
parent fa0f122221
commit 412d246be7
10 changed files with 67 additions and 60 deletions

View File

@@ -1658,9 +1658,9 @@ static char_u *viminfo_filename(char_u *file)
file = use_viminfo;
else if ((file = find_viminfo_parameter('n')) == NULL || *file == NUL) {
#ifdef VIMINFO_FILE2
/* don't use $HOME when not defined (turned into "c:/"!). */
if (os_getenv((char_u *)"HOME") == NULL) {
/* don't use $VIM when not available. */
// don't use $HOME when not defined (turned into "c:/"!).
if (!os_env_exists("HOME")) {
// don't use $VIM when not available.
expand_env((char_u *)"$VIM", NameBuff, MAXPATHL);
if (STRCMP("$VIM", NameBuff) != 0) /* $VIM was expanded */
file = (char_u *)VIMINFO_FILE2;