From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#75207: Fwd: bug#75207: 29.4; Path conversion from native codepage to UTF-8 fails when Windows is set by default to UTF-8 Date: Sat, 04 Jan 2025 11:30:34 +0200 Message-ID: <867c7bexj9.fsf@gnu.org> References: <000001db5ab4$06cec970$146c5c50$@0lock.xyz> <3gvOgDDbA00XBG4Xyu7q8lDJKQVYNo4pJ_Uzu35u0KNS8rhQ9PrenO2Kcz7GDHPNtUng9gnBpgPXtHMty_d_Bw==@protonmail.internalid> <86a5cdnfwc.fsf@gnu.org> <003001db5d81$a8f144b0$fad3ce10$@0lock.xyz> <87F91035-E0D9-4650-B332-10E4E8AD0AEF@0lock.xyz> <86ed1kghej.fsf@gnu.org> <000701db5dec$b8751ef0$295f5cd0$@0lock.xyz> <86a5c7hqc4.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10517"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 75207@debbugs.gnu.org To: michal@0lock.xyz Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 04 10:31:28 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tU0VD-0002cB-UQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Jan 2025 10:31:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tU0Uv-0001XB-W3; Sat, 04 Jan 2025 04:31:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tU0Up-0001S0-8v for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 04:31:06 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tU0Up-0008RR-0S for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 04:31:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=a835THeZIgPRoqaXyzY2JdaXnTAXpWXoO1HkGCdwdSQ=; b=ilfxCHCWpgno9uzV8Ng5iprJxTTVjfoqnX3dO+lTk6aGnDOYOFGzhfe6BBlC1tvpNRNx+P8EQGM/Q4bgAONW5tSjT7AUWF16cspfy3bTMfbglCyNeXtxK+k0loeL5B8G55BkMvQJFnzSCQoE9x2Jli0mB19vQPq0lNSqAUwBvLEgLZE7KUoh/goUJ7bV0pHuFDj0ktfKQngJpQ+/QTLQiMrm+XvYiyyNaJWlYXkFOAUUh1uaXH93MhCo4mY8p4fEamUtW0IedTL5zaAhhU1EWjVVAaUETj+u+sU7EtdfvmqV9MIKZe6W6tGRkOlvACQlkSO+L1t6DnREM+Ho+UDGvA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tU0Uo-0005V9-Hg for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 04:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Jan 2025 09:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75207 X-GNU-PR-Package: emacs Original-Received: via spool by 75207-submit@debbugs.gnu.org id=B75207.173598304721117 (code B ref 75207); Sat, 04 Jan 2025 09:31:02 +0000 Original-Received: (at 75207) by debbugs.gnu.org; 4 Jan 2025 09:30:47 +0000 Original-Received: from localhost ([127.0.0.1]:53379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tU0UZ-0005UW-0D for submit@debbugs.gnu.org; Sat, 04 Jan 2025 04:30:47 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52564) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tU0UW-0005UG-Gn for 75207@debbugs.gnu.org; Sat, 04 Jan 2025 04:30:45 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tU0UQ-0008LU-Sv; Sat, 04 Jan 2025 04:30:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=a835THeZIgPRoqaXyzY2JdaXnTAXpWXoO1HkGCdwdSQ=; b=mUPrquomTJi6 aAUUMBrFVBnYeSe91pHOy2/0Cn3GV1arb9taLMR4bFhz6VHjkDIvaf8kUbx4TPz6Wuml+33RNuPnl 3plfa4RepJIAe6+urGKb/JMLksbsRExHo4a3zDFjxyyWV5M9MiUoDjm0HapiLZBV+Q60TeFUpakbT 39Mq4Ud4VgukaPOtdah7G99VKatTHJIw0IlBO7bXwi7WdpNMAvPjMG5Ifkiwe8FulasXbzRxg2l0d HvfC4V8CzanBvvUdGGUWqbWRX3GrVUxv/D6CGkPDcafZsyKdhyXvUjYIE2sLkDQNDi+lWbqHvmkBU 63QwDG61m8C2EOo+eWiXnQ==; In-Reply-To: <86a5c7hqc4.fsf@gnu.org> (message from Eli Zaretskii on Fri, 03 Jan 2025 17:25:31 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298346 Archived-At: > Cc: 75207@debbugs.gnu.org > Date: Fri, 03 Jan 2025 17:25:31 +0200 > From: Eli Zaretskii > > > I debugged a bit and it looks like w32_ansi_code_page is set to 1252 at some point. > > AFAICT, that happens when we load the pdumper file. > > > M-: w32-multibyte-code-page -> 0 > > M-: locale-coding-system -> cp65001 > > M-: file-name-coding-system -> nil > > M-: default-file-name-coding-system -> cp65001 > > OK, I think this confirms my hypothesis. I'll try to come up with a > patch, probably tomorrow. The patch is below, and it is for the master branch of the Emacs Git repository. > > > If I send you a C-level patch, are you able to build Emacs after patching it, > > > preferably the master branch of our Git repository? > > > > Sure. > > OK, but you'll need to build Emacs with a different system codepage to > see the effects of the fix. This still stands: to fully test the patch, please change your system codepage after building Emacs and then start Emacs and see if everything works as expected. diff --git a/src/emacs.c b/src/emacs.c index c1e0c9f..896f219 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -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); diff --git a/src/w32.c b/src/w32.c index a493991..deeca03 100644 --- 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.