diff options
author | Eli Zaretskii <eliz@gnu.org> | 2016-11-28 17:43:25 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2016-11-28 17:43:25 +0200 |
commit | 5878abf87b6b3ead1367cbae5cc6b0743349f611 (patch) | |
tree | 83fef8ba83ca1733c6a95e3201db9be45558ba07 /src/w32.c | |
parent | 46065291fa0807a10180b958285f5d375cf05914 (diff) | |
download | emacs-5878abf87b6b3ead1367cbae5cc6b0743349f611.tar.gz |
Fix 'expand-file-name' during startup on MS-Windows
* src/w32.c (w32_init_file_name_codepage): New function, resets
file_name_codepage and w32_ansi_code_page to undo the values
recorded during dumping.
(codepage_for_filenames): Fix an embarrassing typo. Ignore the
cached value of file-name encoding if it is nil, i.e. not
initialized yet. Actually cache the last used file-name encoding
to avoid calling APIs when not necessary.
* src/w32.h (w32_init_file_name_codepage): Add prototype.
* src/w32term.c (syms_of_w32term): Set the value of
w32_unicode_filenames according to the OS version. This avoids
resetting it during startup, which then causes temacs to run with
the incorrect value.
* src/emacs.c (main): Call w32_init_file_name_codepage early
during the startup.
* src/fileio.c (Fexpand_file_name) [WINDOWSNT]: Update 'newdir'
after converting $HOME to a UTF-8 string, so that 'newdirlim' is
consistent with it. (Bug#25038)
* lisp/international/mule-cmds.el (set-locale-environment): Set
'default-file-name-coding-system' to the ANSI codepage even in
non-interactive sessions.
* lisp/files.el (directory-abbrev-alist, abbreviated-home-dir):
Doc fix.
(abbreviate-file-name): Decode 'abbreviated-home-dir' if it is a
unibyte string.
* doc/lispref/files.texi (Directory Names): Index
'directory-abbrev-alist'.
Diffstat (limited to 'src/w32.c')
-rw-r--r-- | src/w32.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/w32.c b/src/w32.c index 793bc0f28d0..7c57693cf3d 100644 --- a/src/w32.c +++ b/src/w32.c @@ -1493,6 +1493,16 @@ w32_valid_pointer_p (void *p, int size) /* Current codepage for encoding file names. */ static int file_name_codepage; +/* Initialize the codepage used for decoding file names. This is + needed to undo the value recorded during dumping, which might not + be correct when we run the dumped Emacs. */ +void +w32_init_file_name_codepage (void) +{ + file_name_codepage = CP_ACP; + w32_ansi_code_page = CP_ACP; +} + /* Produce a Windows ANSI codepage suitable for encoding file names. Return the information about that codepage in CP_INFO. */ int @@ -1509,12 +1519,13 @@ codepage_for_filenames (CPINFO *cp_info) if (NILP (current_encoding)) current_encoding = Vdefault_file_name_coding_system; - if (!EQ (last_file_name_encoding, current_encoding)) + if (!EQ (last_file_name_encoding, current_encoding) + || NILP (last_file_name_encoding)) { /* Default to the current ANSI codepage. */ file_name_codepage = w32_ansi_code_page; - if (NILP (current_encoding)) + if (!NILP (current_encoding)) { char *cpname = SSDATA (SYMBOL_NAME (current_encoding)); char *cp = NULL, *end; @@ -1543,6 +1554,9 @@ codepage_for_filenames (CPINFO *cp_info) if (!GetCPInfo (file_name_codepage, &cp)) emacs_abort (); } + + /* Cache the new value. */ + last_file_name_encoding = current_encoding; } if (cp_info) *cp_info = cp; |