Mercurial > vim
diff src/misc1.c @ 170:8c60f65311fa v7.0052
updated for version 7.0052
author | vimboss |
---|---|
date | Sat, 26 Feb 2005 23:04:13 +0000 |
parents | 0e902b8f511f |
children | 6e9968f34740 |
line wrap: on
line diff
--- a/src/misc1.c +++ b/src/misc1.c @@ -3209,6 +3209,10 @@ init_homedir() { char_u *var; + /* In case we are called a second time (when 'encoding' changes). */ + vim_free(homedir); + homedir = NULL; + #ifdef VMS var = mch_getenv((char_u *)"SYS$LOGIN"); #else @@ -3270,6 +3274,23 @@ init_homedir() } } } + +# if defined(FEAT_MBYTE) + if (enc_utf8 && var != NULL) + { + int len; + char_u *pp; + + /* Convert from active codepage to UTF-8. Other conversions are + * not done, because they would fail for non-ASCII characters. */ + acp_to_enc(var, STRLEN(var), &pp, &len); + if (pp != NULL) + { + homedir = pp; + return; + } + } +# endif #endif #if defined(OS2) || defined(MSDOS) || defined(MSWIN) @@ -3594,7 +3615,25 @@ vim_getenv(name, mustfree) p = NULL; if (p != NULL) + { +#if defined(FEAT_MBYTE) && defined(WIN3264) + if (enc_utf8) + { + int len; + char_u *pp; + + /* Convert from active codepage to UTF-8. Other conversions are + * not done, because they would fail for non-ASCII characters. */ + acp_to_enc(p, STRLEN(p), &pp, &len); + if (pp != NULL) + { + p = pp; + *mustfree = TRUE; + } + } +#endif return p; + } vimruntime = (STRCMP(name, "VIMRUNTIME") == 0); if (!vimruntime && STRCMP(name, "VIM") != 0) @@ -3620,6 +3659,26 @@ vim_getenv(name, mustfree) *mustfree = TRUE; else p = mch_getenv((char_u *)"VIM"); + +#if defined(FEAT_MBYTE) && defined(WIN3264) + if (enc_utf8) + { + int len; + char_u *pp; + + /* Convert from active codepage to UTF-8. Other conversions + * are not done, because they would fail for non-ASCII + * characters. */ + acp_to_enc(p, STRLEN(p), &pp, &len); + if (pp != NULL) + { + if (mustfree) + vim_free(p); + p = pp; + *mustfree = TRUE; + } + } +#endif } }