aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-12-07 12:40:43 -0800
committerPaul Eggert2016-12-07 12:40:43 -0800
commitc5532f5a5c304134ecb0367997402c2935d6030c (patch)
treecff0c6b05099fcaa51dae8e1c042528cdb318925 /src
parent32b46fc82f1275d8e0c86340546db366dea48c8c (diff)
parent39809036d39711fb5d01105739dd301ac046b151 (diff)
downloademacs-c5532f5a5c304134ecb0367997402c2935d6030c.tar.gz
emacs-c5532f5a5c304134ecb0367997402c2935d6030c.zip
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)
734 to have non-stub implementations of APIs we need to convert file 734 to have non-stub implementations of APIs we need to convert file
735 names between UTF-8 and the system's ANSI codepage. */ 735 names between UTF-8 and the system's ANSI codepage. */
736 maybe_load_unicows_dll (); 736 maybe_load_unicows_dll ();
737 /* Initialize the codepage for file names, needed to decode
738 non-ASCII file names during startup. */
739 w32_init_file_name_codepage ();
737#endif 740#endif
738 /* This has to be done before module_init is called below, so that 741 /* This has to be done before module_init is called below, so that
739 the latter could use the thread ID of the main thread. */ 742 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). */)
1074 if (!(newdir = egetenv ("HOME"))) 1074 if (!(newdir = egetenv ("HOME")))
1075 newdir = newdirlim = ""; 1075 newdir = newdirlim = "";
1076 nm++; 1076 nm++;
1077 /* `egetenv' may return a unibyte string, which will bite us since
1078 we expect the directory to be multibyte. */
1079#ifdef WINDOWSNT 1077#ifdef WINDOWSNT
1080 if (newdir[0]) 1078 if (newdir[0])
1081 { 1079 {
@@ -1083,11 +1081,14 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1083 1081
1084 filename_from_ansi (newdir, newdir_utf8); 1082 filename_from_ansi (newdir, newdir_utf8);
1085 tem = make_unibyte_string (newdir_utf8, strlen (newdir_utf8)); 1083 tem = make_unibyte_string (newdir_utf8, strlen (newdir_utf8));
1084 newdir = SSDATA (tem);
1086 } 1085 }
1087 else 1086 else
1088#endif 1087#endif
1089 tem = build_string (newdir); 1088 tem = build_string (newdir);
1090 newdirlim = newdir + SBYTES (tem); 1089 newdirlim = newdir + SBYTES (tem);
1090 /* `egetenv' may return a unibyte string, which will bite us
1091 if we expect the directory to be multibyte. */
1091 if (multibyte && !STRING_MULTIBYTE (tem)) 1092 if (multibyte && !STRING_MULTIBYTE (tem))
1092 { 1093 {
1093 hdir = DECODE_FILE (tem); 1094 hdir = DECODE_FILE (tem);
@@ -1116,8 +1117,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1116 1117
1117 newdir = pw->pw_dir; 1118 newdir = pw->pw_dir;
1118 /* `getpwnam' may return a unibyte string, which will 1119 /* `getpwnam' may return a unibyte string, which will
1119 bite us since we expect the directory to be 1120 bite us when we expect the directory to be multibyte. */
1120 multibyte. */
1121 tem = make_unibyte_string (newdir, strlen (newdir)); 1121 tem = make_unibyte_string (newdir, strlen (newdir));
1122 newdirlim = newdir + SBYTES (tem); 1122 newdirlim = newdir + SBYTES (tem);
1123 if (multibyte && !STRING_MULTIBYTE (tem)) 1123 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)
1509/* Current codepage for encoding file names. */ 1509/* Current codepage for encoding file names. */
1510static int file_name_codepage; 1510static int file_name_codepage;
1511 1511
1512/* Initialize the codepage used for decoding file names. This is
1513 needed to undo the value recorded during dumping, which might not
1514 be correct when we run the dumped Emacs. */
1515void
1516w32_init_file_name_codepage (void)
1517{
1518 file_name_codepage = CP_ACP;
1519 w32_ansi_code_page = CP_ACP;
1520}
1521
1512/* Produce a Windows ANSI codepage suitable for encoding file names. 1522/* Produce a Windows ANSI codepage suitable for encoding file names.
1513 Return the information about that codepage in CP_INFO. */ 1523 Return the information about that codepage in CP_INFO. */
1514int 1524int
@@ -1525,12 +1535,13 @@ codepage_for_filenames (CPINFO *cp_info)
1525 if (NILP (current_encoding)) 1535 if (NILP (current_encoding))
1526 current_encoding = Vdefault_file_name_coding_system; 1536 current_encoding = Vdefault_file_name_coding_system;
1527 1537
1528 if (!EQ (last_file_name_encoding, current_encoding)) 1538 if (!EQ (last_file_name_encoding, current_encoding)
1539 || NILP (last_file_name_encoding))
1529 { 1540 {
1530 /* Default to the current ANSI codepage. */ 1541 /* Default to the current ANSI codepage. */
1531 file_name_codepage = w32_ansi_code_page; 1542 file_name_codepage = w32_ansi_code_page;
1532 1543
1533 if (NILP (current_encoding)) 1544 if (!NILP (current_encoding))
1534 { 1545 {
1535 char *cpname = SSDATA (SYMBOL_NAME (current_encoding)); 1546 char *cpname = SSDATA (SYMBOL_NAME (current_encoding));
1536 char *cp = NULL, *end; 1547 char *cp = NULL, *end;
@@ -1559,6 +1570,9 @@ codepage_for_filenames (CPINFO *cp_info)
1559 if (!GetCPInfo (file_name_codepage, &cp)) 1570 if (!GetCPInfo (file_name_codepage, &cp))
1560 emacs_abort (); 1571 emacs_abort ();
1561 } 1572 }
1573
1574 /* Cache the new value. */
1575 last_file_name_encoding = current_encoding;
1562 } 1576 }
1563 if (cp_info) 1577 if (cp_info)
1564 *cp_info = cp; 1578 *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 *);
195extern int filename_to_ansi (const char *, char *); 195extern int filename_to_ansi (const char *, char *);
196extern int filename_from_utf16 (const wchar_t *, char *); 196extern int filename_from_utf16 (const wchar_t *, char *);
197extern int filename_to_utf16 (const char *, wchar_t *); 197extern int filename_to_utf16 (const char *, wchar_t *);
198extern void w32_init_file_name_codepage (void);
198extern int codepage_for_filenames (CPINFO *); 199extern int codepage_for_filenames (CPINFO *);
199extern Lisp_Object ansi_encode_filename (Lisp_Object); 200extern Lisp_Object ansi_encode_filename (Lisp_Object);
200extern int w32_copy_file (const char *, const char *, int, int, int); 201extern 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'.
7188This variable is set to non-nil by default when Emacs runs on Windows 7188This variable is set to non-nil by default when Emacs runs on Windows
7189systems of the NT family, including W2K, XP, Vista, Windows 7 and 7189systems of the NT family, including W2K, XP, Vista, Windows 7 and
7190Windows 8. It is set to nil on Windows 9X. */); 7190Windows 8. It is set to nil on Windows 9X. */);
7191 w32_unicode_filenames = 0; 7191 if (os_subtype == OS_9X)
7192 w32_unicode_filenames = 0;
7193 else
7194 w32_unicode_filenames = 1;
7192 7195
7193 7196
7194 /* FIXME: The following variable will be (hopefully) removed 7197 /* FIXME: The following variable will be (hopefully) removed