From: Eli Zaretskii Date: Tue, 13 Nov 2018 20:01:57 +0000 (+0200) Subject: Fix recent change in fileio.c X-Git-Tag: emacs-27.0.90~4167 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4a5a17507fe1e12ee02c174350edc479fb01ac01;p=emacs.git Fix recent change in fileio.c * src/fileio.c (get_homedir) [WINDOWSNT]: Convert $HOME to UTF-8. (Fexpand_file_name): Don't convert it here. --- diff --git a/src/fileio.c b/src/fileio.c index e178c39fc18..59446ac1833 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1096,18 +1096,7 @@ the root directory. */) newdir = get_homedir (); nm++; -#ifdef WINDOWSNT - if (newdir[0]) - { - char newdir_utf8[MAX_UTF8_PATH]; - - filename_from_ansi (newdir, newdir_utf8); - tem = make_unibyte_string (newdir_utf8, strlen (newdir_utf8)); - newdir = SSDATA (tem); - } - else -#endif - tem = build_string (newdir); + tem = build_string (newdir); newdirlim = newdir + SBYTES (tem); /* get_homedir may return a unibyte string, which will bite us if we expect the directory to be multibyte. */ @@ -1669,6 +1658,19 @@ char const * get_homedir (void) { char const *home = egetenv ("HOME"); + +#ifdef WINDOWSNT + /* getpw* functions return UTF-8 encoded file names, whereas egetenv + returns strings in locale encoding, so we need to convert for + consistency. */ + char homedir_utf8[MAX_UTF8_PATH]; + if (home) + { + filename_from_ansi (home, homedir_utf8); + home = homedir_utf8; + } +#endif + if (!home) { static char const *userenv[] = {"LOGNAME", "USER"};