From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#65908: 29.1.50; Emacs 29 regresses on macOS Date: Thu, 05 Oct 2023 15:18:42 +0200 Message-ID: References: <8875281f07b4d23d857c@heytings.org> <83o7hd4n5n.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27605"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: ccsmile2008@outlook.com, Eli Zaretskii , 65908@debbugs.gnu.org, gregory@heytings.org, stefankangas@gmail.com To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 05 15:20:08 2023 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 1qoOGs-0006uh-Qw for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Oct 2023 15:20:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoOGY-00047y-N8; Thu, 05 Oct 2023 09:19:46 -0400 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 1qoOGW-00047m-Sh for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 09:19:45 -0400 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 1qoOGW-000788-Jn for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 09:19:44 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qoOGo-0003Uy-Bd for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 09:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Oct 2023 13:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65908 X-GNU-PR-Package: emacs Original-Received: via spool by 65908-submit@debbugs.gnu.org id=B65908.169651195513391 (code B ref 65908); Thu, 05 Oct 2023 13:20:02 +0000 Original-Received: (at 65908) by debbugs.gnu.org; 5 Oct 2023 13:19:15 +0000 Original-Received: from localhost ([127.0.0.1]:46260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoOG0-0003Ts-1W for submit@debbugs.gnu.org; Thu, 05 Oct 2023 09:19:15 -0400 Original-Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:53454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoOFw-0003Td-SN for 65908@debbugs.gnu.org; Thu, 05 Oct 2023 09:19:10 -0400 Original-Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-533d6a8d6b6so1737800a12.2 for <65908@debbugs.gnu.org>; Thu, 05 Oct 2023 06:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696511925; x=1697116725; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Q9zpghMEmQOQbEYR8Fn9/AWoBVeDmzRbZ5PPrPq6lqg=; b=FOeqUNybIOpbGR9QanWtZdqgyyFW7U28hP0g6kOzkq/7LAfV4jZeUyhM56yTel7THe RHg39H+5TzaQxq6H2suzVW2Yy4wGVFhTSwyyF+Lb098QsRgwx5LyfpshnrpswP2l1YkZ vPYM4qE+yHLiLKS2pKJsWYtv2qV4vHDPFODAlkoR8PVCXF/HWEfZSAGdzGnMUKZpKgsN 5d5ntSQ/+IFL0tlJaMhipJLbaPd4NflEXoFk/dxcWq2pYI2USdPh4ycs+XkdqhAoqBXx 9rraPue7HE0Dm4tE7ulfZcrSx5AmmeTfM761d/x1fRFaPpkv3EzCCFdclogcOs/Ew1zu wAeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696511925; x=1697116725; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Q9zpghMEmQOQbEYR8Fn9/AWoBVeDmzRbZ5PPrPq6lqg=; b=d63mAeTJwmx9qcS05+A008ZiynoDtMd7Vb9RjWVcofbzuD+nd4fYPJNC/UdMXkCI6D IRu/vLDdNmIQTPGXU9zy4nnChOherjaT+KFRgk0cmYmQrpv7jcJSFolqVu6jaLhNFCEe JKtqwKB9raD+fl/Jnpara5F8Af/jPoVH9hps+fJh7hjDpo97J6Prr5uagZ5sTnj0Lf/g +bMJkFUKsxY2BXtBDsakpnIygND4t0Cl3rXsXrttQoLIZs3So9u/yavy4OCAuC83r0Ck yty0lZLX+5CieI1dYYNIeZbp5PLsYxUIVVNUWoe8heqFJmOUIvVFMV1K6BPiwl4BxfIS R8yg== X-Gm-Message-State: AOJu0Ywz5whmyETQ3mcJ/DEZ/mqOgbHxUaUiJdICj/d4eDPHO/1yzXKS TR3UsIXws+FYBrkCoCzykNg= X-Google-Smtp-Source: AGHT+IHDffB5MpepDDWbsJeK4l0eqeQ4DhJenSwNm/bGjWOf+oAoRO6rTjNbUK3KQTSfvYPpvac74A== X-Received: by 2002:a17:906:5198:b0:9aa:25f5:8d93 with SMTP id y24-20020a170906519800b009aa25f58d93mr4367692ejk.49.1696511924514; Thu, 05 Oct 2023 06:18:44 -0700 (PDT) Original-Received: from Pro.fritz.box (pd9e3618b.dip0.t-ipconnect.de. [217.227.97.139]) by smtp.gmail.com with ESMTPSA id u20-20020a17090657d400b009b97aa5a3aesm1192517ejr.34.2023.10.05.06.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 06:18:43 -0700 (PDT) In-Reply-To: ("Gerd =?UTF-8?Q?M=C3=B6llmann?="'s message of "Thu, 05 Oct 2023 13:12:10 +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:271870 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Gerd M=C3=B6llmann writes: > It would be nice if I could get at least the right character encoding on > my system... On the plus side, I at least know now what's happening, > although I don't know what to do. I'd like to propose the attached patch for problem of invalid LANG setting. This simply falls back to "en_US.UTF-8" if LANG isn't valid, or something valid can't be deduced from the locale. I find this acceptable even in my setting ("en_DE") because even Apple's Terminal doesn't get this right. A closer looks at what is set in the locale in Terminal shows that, for instance, date format and thousands separator are en_US anyway. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Handle-LANG-on-macOS-differntly-bug-bug-65908.patch Content-Description: ns_init_locale >From 93457632cd5f17de01ec291d888d2d2fb0acffdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= Date: Thu, 5 Oct 2023 15:12:40 +0200 Subject: [PATCH] Handle LANG on macOS differntly (bug#bug#65908) * src/nsterm.m (ns_init_locale): If LANG is set, try to use that, otherwise try to deduce what LANG should be. Check is the result is valid, and use LANG="en_US.UTF-8" if not. --- src/nsterm.m | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 4e0dfa58c63..09cb7236b6e 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -554,29 +554,25 @@ - (unsigned long)unsignedLong /* macOS doesn't set any environment variables for the locale when run from the GUI. Get the locale from the OS and set LANG. */ { - NSLocale *locale = [NSLocale currentLocale]; - NSTRACE ("ns_init_locale"); - /* If we were run from a terminal then assume an unset LANG variable - is intentional and don't try to "fix" it. */ - if (!isatty (STDIN_FILENO)) + const char *lang = getenv ("LANG"); + if (lang == NULL) { - char *oldLocale = setlocale (LC_ALL, NULL); - /* It seems macOS should probably use UTF-8 everywhere. - 'localeIdentifier' does not specify the encoding, and I can't - find any way to get the OS to tell us which encoding to use, - so hard-code '.UTF-8'. */ - NSString *localeID = [NSString stringWithFormat:@"%@.UTF-8", - [locale localeIdentifier]]; + const NSLocale *locale = [NSLocale currentLocale]; + const NSString *localeID = [NSString stringWithFormat:@"%@.UTF-8", + [locale localeIdentifier]]; + lang = [localeID UTF8String]; + } - /* Check the locale ID is valid and if so set LANG, but not if - it is already set. */ - if (setlocale (LC_ALL, [localeID UTF8String])) - setenv("LANG", [localeID UTF8String], 0); + /* Check if LANG can be used for initializing the locale. If not, + use a default setting. Note that Emacs' main will undo the + setlocale below, initializing the locale from the + environment. */ + if (setlocale (LC_ALL, lang) == NULL) + lang = "en_US.UTF-8"; - setlocale (LC_ALL, oldLocale); - } + setenv ("LANG", lang, 1); } -- 2.39.3 (Apple Git-145) --=-=-=--