GNU logs - #71262, boring messages


Message sent to bug-guile@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#71262: [PATCH] Try to install C.UTF-8 locale before falling back to C.
Resent-From: Tomas Volf <~@wolfsden.cz>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-guile@HIDDEN
Resent-Date: Wed, 29 May 2024 18:01:01 +0000
Resent-Message-ID: <handler.71262.B.17170056377986 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 71262
X-GNU-PR-Package: guile
X-GNU-PR-Keywords: patch
To: 71262 <at> debbugs.gnu.org
Cc: Tomas Volf <~@wolfsden.cz>
X-Debbugs-Original-To: bug-guile@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.17170056377986
          (code B ref -1); Wed, 29 May 2024 18:01:01 +0000
Received: (at submit) by debbugs.gnu.org; 29 May 2024 18:00:37 +0000
Received: from localhost ([127.0.0.1]:47050 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sCNbI-00024j-IL
	for submit <at> debbugs.gnu.org; Wed, 29 May 2024 14:00:37 -0400
Received: from lists.gnu.org ([209.51.188.17]:47002)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <~@wolfsden.cz>) id 1sCNbG-00024a-Kt
 for submit <at> debbugs.gnu.org; Wed, 29 May 2024 14:00:36 -0400
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 <~@wolfsden.cz>) id 1sCNb5-0002LH-T9
 for bug-guile@HIDDEN; Wed, 29 May 2024 14:00:24 -0400
Received: from wolfsden.cz ([37.205.8.62])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1sCNb1-0004od-3R
 for bug-guile@HIDDEN; Wed, 29 May 2024 14:00:23 -0400
Received: by wolfsden.cz (Postfix, from userid 104)
 id 7DF7024B1FD; Wed, 29 May 2024 18:00:14 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail;
 t=1717005614; bh=MY4rOHfy5vGA9W+KyX8LaSvl5kXssjpzZRI1i1EUaBw=;
 h=From:To:Cc:Subject:Date;
 b=WVHGMqBk2O0P7a0+e2DO01h8i6phxwqgrKOLkNufa5y2fGvaYvNFCkHNJQCJ6/wZE
 4JKGSGMnpdNzH2VCPTRH8F7UqJwmzqtJuKD1npOg16hO4XtCS/oTtoqD0Km5AS/FaZ
 wWt9z8V5rEbB/AqYgUQ+ImfCvviYnayuPmwjsGDAzZpQkwhiukxoun0PipR7VuBr9z
 3YZHoImp/H9lfevJ1Ml6A8G/8YSjZYMyTN6hMH1VA32wAEIsKlv8o908TxkuTPk/R9
 muNhLDsedOlE8GM8v2mwuDNU6IvfpPozmOgEd/NV3Xn6Mfqw7/0k4RxUzgEagBOpZ7
 cBsaDyyAMA7foBkrNwOIcU+bkfVFsg0bJD5pDMcbs9J/dbus7z5CeEwCtKN1M4A7lF
 48c2P+A2R3D5/XMAG/wZl+tagge08lmAX3guhNE4EhZX2SVIpGp8+xknBFhPSYbrHy
 7pt2ftJARF3rREt2oEk0lZKlnKNmo0mvHpayJ8WQNJD/XQWTtPVi4rTk5KOmxIpej4
 QHEV1fLE7tC7z1BsTnaoo+xYJUdwRFNM7E9YZCajl3G5B1D+H/T/DfcKWHVo+HZDAO
 dXfL6WTTzwCza0QyHn1fHBKWTdWTcq6PpJFiLL0QBFF9J1OuWqMfjx1ffRgv6gxKsj
 dgYfjxMln0zA2AEws41kMmco=
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden
X-Spam-Level: 
X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,T_SCC_BODY_TEXT_LINE,
 URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6
Received: from localhost (unknown [193.32.127.145])
 by wolfsden.cz (Postfix) with ESMTPSA id 8E35D24C3A2;
 Wed, 29 May 2024 18:00:13 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail;
 t=1717005613; bh=MY4rOHfy5vGA9W+KyX8LaSvl5kXssjpzZRI1i1EUaBw=;
 h=From:To:Cc:Subject:Date;
 b=BOrCFcvnHXFsYA4KNscDMEbC1KdfeM/8Lk6xEnK8dPWAvanLYSZ+2KfsH1Dy4Yggc
 QmHlGfOtQgN4D2T12XjPNLpIc5v9v6ij8NwOcV2ENt0IUxO08JiZh9eU03iMM9efcH
 zOEY4MoeWBA3Euy4sVUk/aPsWZew88ZAe2M7uQkxPjGYPwqVoLcdwhDYKBYqw3a0cM
 mN3i/iQAScxCQy2aCp9fbU4RB512LcKsPIy7NCnwu52KeiP9NyvKtgQaw03Fi/eeJw
 DXGIRUDwRIXAYVcJKygTuGZBIV9rmtg/lUZiL2WlMaBR/nK0+jBakgN1B5cPvtVfm9
 lwKq1+M1vZij8Nxq4nOwTp5Q2jXnOu95FWfXtJbteE3axTFp2C+DcZzwyoNO7onjiD
 e7nTw9cUaj2CHIHugqZmiXUtQUTEjZa9Jo6Dc5Sy4DB/U1pW5LlMoHi5Wo6gzj6n/d
 Y75JnuRVZm4yi0TYimwwk+5mHcul3scgvIUwYOhS3A2aZsNsSOiGcSZIdrgSxKPtVn
 nU4i69Zo/A9YUKDd1vQtaHrnu009qyZpuTFFH2QS9G6RxNBG3dFBLNjMFCq8/NPSUD
 bCxhz2KxhVbOu764B8LYWZWlnqdYWO1TOyLOZpdc0vnCi8Ldj3LZAXGcapS1XR+uiJ
 OpwVTRJ7+NnQn9706rnVq5BI=
From: Tomas Volf <~@wolfsden.cz>
Date: Wed, 29 May 2024 20:00:03 +0200
Message-ID: <20240529180003.11398-1-~@wolfsden.cz>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz;
 helo=wolfsden.cz
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

If user does not have LANG or LC_ALL set (as does often happen in
various sandboxes) glibc will just install C locale.  That is fine (and
permissible by POSIX), however in Guile's context it is of a mixed
usefulness due to the absence of UTF-8 support.

This commit changes the locale auto-installation logic to attempt
C.UTF-8 locale first (if user did not request another one).

User can still get C locale by either GUILE_INSTALL_LOCALE=0 or LANG=C.
This default should be more useful in this day and age, at least for
Guile users.

* libguile/guile.c (should_install_default_locale): New function.
(main)[should_install_locale ()]: Try to install C.UTF-8 before falling
back to C.
* doc/ref/guile-invoke.texi (Environment Variables): Document the
change.
---
 doc/ref/guile-invoke.texi |  6 ++++--
 libguile/guile.c          | 19 +++++++++++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/doc/ref/guile-invoke.texi b/doc/ref/guile-invoke.texi
index 856bce7b8..e08d78200 100644
--- a/doc/ref/guile-invoke.texi
+++ b/doc/ref/guile-invoke.texi
@@ -344,8 +344,10 @@ variable.  By default, the history file is @file{$HOME/.guile_history}.
 This is a flag that can be used to tell Guile whether or not to install
 the current locale at startup, via a call to @code{(setlocale LC_ALL
 "")}@footnote{The @code{GUILE_INSTALL_LOCALE} environment variable was
-ignored in Guile versions prior to 2.0.9.}.  @xref{Locales}, for more
-information on locales.
+ignored in Guile versions prior to 2.0.9.}.  If no explicit locale is
+set by the user (via @code{LC_ALL} or @code{LANG} environment
+variables), @samp{C.UTF-8} is tried before falling back to @samp{C}.
+@xref{Locales}, for more information on locales.
 
 You may explicitly indicate that you do not want to install
 the locale by setting @env{GUILE_INSTALL_LOCALE} to @code{0}, or
diff --git a/libguile/guile.c b/libguile/guile.c
index 8283ef6fa..a4ad10400 100644
--- a/libguile/guile.c
+++ b/libguile/guile.c
@@ -80,6 +80,16 @@ should_install_locale (void)
   return get_integer_from_environment ("GUILE_INSTALL_LOCALE", 1);
 }
 
+static int
+should_install_default_locale (void)
+{
+  /* This logic is derived from a precedence order described in section
+     8.2 of The Open Group Base Specifications Issue 7, 2018 edition. */
+  const char *lang   = getenv ("LANG");
+  const char *lc_all = getenv ("LC_ALL");
+  return (!lc_all || *lc_all == 0) && (!lang || *lang == 0);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -88,8 +98,13 @@ main (int argc, char **argv)
      error messages, use the right locale.  See
      <https://lists.gnu.org/archive/html/guile-devel/2011-11/msg00041.html>
      for the rationale.  */
-  if (should_install_locale () && setlocale (LC_ALL, "") == NULL)
-    fprintf (stderr, "guile: warning: failed to install locale\n");
+  if (should_install_locale ()) {
+    if (should_install_default_locale ()
+        && setlocale(LC_ALL, "C.UTF-8") != NULL)
+      ;
+    else if (setlocale (LC_ALL, "") == NULL)
+      fprintf (stderr, "guile: warning: failed to install locale\n");
+  }
 
   scm_boot_guile (argc, argv, inner_main, 0);
   return 0; /* never reached */
-- 
2.41.0





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Tomas Volf <~@wolfsden.cz>
Subject: bug#71262: Acknowledgement ([PATCH] Try to install C.UTF-8 locale
 before falling back to C.)
Message-ID: <handler.71262.B.17170056377986.ack <at> debbugs.gnu.org>
References: <20240529180003.11398-1-~@wolfsden.cz>
X-Gnu-PR-Message: ack 71262
X-Gnu-PR-Package: guile
X-Gnu-PR-Keywords: patch
Reply-To: 71262 <at> debbugs.gnu.org
Date: Wed, 29 May 2024 18:01:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-guile@HIDDEN

If you wish to submit further information on this problem, please
send it to 71262 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
71262: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D71262
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems



Last modified: Wed, 29 May 2024 18:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.