]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix setup of coding-systems on MS-Windows
authorEli Zaretskii <eliz@gnu.org>
Sun, 5 Jan 2025 05:56:27 +0000 (07:56 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 5 Jan 2025 12:18:50 +0000 (13:18 +0100)
* src/emacs.c (main) [HAVE_PDUMPER] [WINDOWSNT]: Call
'w32_init_file_name_codepage' again after loading the pdumper
file.
* src/w32.c (w32_init_file_name_codepage) [HAVE_PDUMPER]:
Reinitialize additional variables.  (Bug#75207)

(cherry picked from commit cc5cd4de93d1e5ba205cbf0c370aef4559bc342b)

src/emacs.c
src/w32.c

index c1e0c9f3a5734f66b109d34c8ede6f69c1b5bbd1..896f219baab600873dd5a04057f3b2712dd6fe33 100644 (file)
@@ -1419,7 +1419,18 @@ android_emacs_init (int argc, char **argv, char *dump_file)
 
 #ifdef HAVE_PDUMPER
   if (attempt_load_pdump)
-    initial_emacs_executable = load_pdump (argc, argv, dump_file);
+    {
+      initial_emacs_executable = load_pdump (argc, argv, dump_file);
+#ifdef WINDOWSNT
+  /* Reinitialize the codepage for file names, needed to decode
+     non-ASCII file names during startup.  This is needed because
+     loading the pdumper file above assigns to those variables values
+     from the dump stage, which might be incorrect, if dumping was done
+     on a different system.  */
+      if (dumped_with_pdumper_p ())
+       w32_init_file_name_codepage ();
+#endif
+    }
 #else
   ptrdiff_t bufsize;
   initial_emacs_executable = find_emacs_executable (argv[0], &bufsize);
index a49399153aaa25db4e5dd99fca1c6c94afd43329..deeca031f64739e97efe34b549ddb9c320c5c331 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -1685,6 +1685,19 @@ w32_init_file_name_codepage (void)
 {
   file_name_codepage = CP_ACP;
   w32_ansi_code_page = CP_ACP;
+#ifdef HAVE_PDUMPER
+  /* If we were dumped with pdumper, this function will be called after
+     loading the pdumper file, and needs to reset the following
+     variables that come from the dump stage, which could be on a
+     different system with different default codepages.  Then, the
+     correct value of w32-ansi-code-page will be assigned by
+     globals_of_w32fns, which is called from 'main'.  Until that call
+     happens, w32-ansi-code-page will have the value of CP_ACP, which
+     stands for the default ANSI codepage.  The other variables will be
+     computed by codepage_for_filenames below.  */
+  Vdefault_file_name_coding_system = Qnil;
+  Vfile_name_coding_system = Qnil;
+#endif
 }
 
 /* Produce a Windows ANSI codepage suitable for encoding file names.