summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-12-07 12:40:43 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-12-07 12:40:43 -0800
commitc5532f5a5c304134ecb0367997402c2935d6030c (patch)
treecff0c6b05099fcaa51dae8e1c042528cdb318925 /src
parent32b46fc82f1275d8e0c86340546db366dea48c8c (diff)
parent39809036d39711fb5d01105739dd301ac046b151 (diff)
downloademacs-c5532f5a5c304134ecb0367997402c2935d6030c.tar.gz
Merge from origin/emacs-25
3980903 ; Update ChangeLog.2, etc/AUTHORS and ldef-boot.el for Emacs ... 5878abf Fix 'expand-file-name' during startup on MS-Windows
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c3
-rw-r--r--src/fileio.c8
-rw-r--r--src/w32.c18
-rw-r--r--src/w32.h1
-rw-r--r--src/w32term.c5
5 files changed, 28 insertions, 7 deletions
diff --git a/src/emacs.c b/src/emacs.c
index f633f09098d..75b2d6ed607 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -734,6 +734,9 @@ main (int argc, char **argv)
to have non-stub implementations of APIs we need to convert file
names between UTF-8 and the system's ANSI codepage. */
maybe_load_unicows_dll ();
+ /* Initialize the codepage for file names, needed to decode
+ non-ASCII file names during startup. */
+ w32_init_file_name_codepage ();
#endif
/* This has to be done before module_init is called below, so that
the latter could use the thread ID of the main thread. */
diff --git a/src/fileio.c b/src/fileio.c
index 7aa58177d49..3ba85b2b903 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1074,8 +1074,6 @@ filesystem tree, not (expand-file-name ".." dirname). */)
if (!(newdir = egetenv ("HOME")))
newdir = newdirlim = "";
nm++;
- /* `egetenv' may return a unibyte string, which will bite us since
- we expect the directory to be multibyte. */
#ifdef WINDOWSNT
if (newdir[0])
{
@@ -1083,11 +1081,14 @@ filesystem tree, not (expand-file-name ".." dirname). */)
filename_from_ansi (newdir, newdir_utf8);
tem = make_unibyte_string (newdir_utf8, strlen (newdir_utf8));
+ newdir = SSDATA (tem);
}
else
#endif
tem = build_string (newdir);
newdirlim = newdir + SBYTES (tem);
+ /* `egetenv' may return a unibyte string, which will bite us
+ if we expect the directory to be multibyte. */
if (multibyte && !STRING_MULTIBYTE (tem))
{
hdir = DECODE_FILE (tem);
@@ -1116,8 +1117,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
newdir = pw->pw_dir;
/* `getpwnam' may return a unibyte string, which will
- bite us since we expect the directory to be
- multibyte. */
+ bite us when we expect the directory to be multibyte. */
tem = make_unibyte_string (newdir, strlen (newdir));
newdirlim = newdir + SBYTES (tem);
if (multibyte && !STRING_MULTIBYTE (tem))
diff --git a/src/w32.c b/src/w32.c
index 086c1acfb38..fa7fec700c6 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1509,6 +1509,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
@@ -1525,12 +1535,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;
@@ -1559,6 +1570,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;
diff --git a/src/w32.h b/src/w32.h
index 702bb5255cd..c73ff302c05 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -195,6 +195,7 @@ extern int filename_from_ansi (const char *, char *);
extern int filename_to_ansi (const char *, char *);
extern int filename_from_utf16 (const wchar_t *, char *);
extern int filename_to_utf16 (const char *, wchar_t *);
+extern void w32_init_file_name_codepage (void);
extern int codepage_for_filenames (CPINFO *);
extern Lisp_Object ansi_encode_filename (Lisp_Object);
extern int w32_copy_file (const char *, const char *, int, int, int);
diff --git a/src/w32term.c b/src/w32term.c
index ae0f741f24c..23475445e07 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -7188,7 +7188,10 @@ specified by `file-name-coding-system'.
This variable is set to non-nil by default when Emacs runs on Windows
systems of the NT family, including W2K, XP, Vista, Windows 7 and
Windows 8. It is set to nil on Windows 9X. */);
- w32_unicode_filenames = 0;
+ if (os_subtype == OS_9X)
+ w32_unicode_filenames = 0;
+ else
+ w32_unicode_filenames = 1;
/* FIXME: The following variable will be (hopefully) removed