From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Accessing the environment's locale encoding settings Date: Thu, 24 Nov 2011 00:28:08 +0100 Message-ID: <878vn6l8qf.fsf@gnu.org> References: <877h30exfk.fsf@gnu.org> <201111160300.38410.bruno@clisp.org> <87r5189wxw.fsf@gnu.org> <201111201755.18910.bruno@clisp.org> <87ehx2bsis.fsf@gnu.org> <1321818250.84716.YahooMailNeo@web37905.mail.mud.yahoo.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1322090906 27675 80.91.229.12 (23 Nov 2011 23:28:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2011 23:28:26 +0000 (UTC) Cc: Bruno Haible , "guile-devel@gnu.org" To: Mike Gran Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Nov 24 00:28:22 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RTMEl-00017K-Ia for guile-devel@m.gmane.org; Thu, 24 Nov 2011 00:28:19 +0100 Original-Received: from localhost ([::1]:60560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTMEl-0005W3-59 for guile-devel@m.gmane.org; Wed, 23 Nov 2011 18:28:19 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:40808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTMEh-0005Vm-6j for guile-devel@gnu.org; Wed, 23 Nov 2011 18:28:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RTMEg-0004v1-6z for guile-devel@gnu.org; Wed, 23 Nov 2011 18:28:15 -0500 Original-Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:59410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTMEg-0004up-0S for guile-devel@gnu.org; Wed, 23 Nov 2011 18:28:14 -0500 X-IronPort-AV: E=Sophos;i="4.69,562,1315173600"; d="scan'208";a="132359239" Original-Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 24 Nov 2011 00:28:11 +0100 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 Frimaire an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <1321818250.84716.YahooMailNeo@web37905.mail.mud.yahoo.com> (Mike Gran's message of "Sun, 20 Nov 2011 11:44:10 -0800 (PST)") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.82 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12926 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Mike, Mike Gran skribis: > Here's a suggestion.=A0=A0One=A0could add an option to the guile interpre= ter's command > line args (--locale=3DARG perhaps) that has the effect of calling > setlocale(LC_ALL,"ARG") first thing.=A0 If --locale is called with=A0no A= RG > specified, it would call to setlocale(LC_ALL, ""). I tried something along these lines: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff -ubB --show-c-function /home/ludo/src/guile/libguile/script.c /home/ludo/src/guile/libguile/script.c.locale.bak --- guile/libguile/script.c 2011-11-21 21:41:02.000000000 +0100 +++ guile/libguile/script.c.locale.bak 2011-11-21 21:41:00.000000000 +0100 @@ -26,6 +26,7 @@ #include #include #include +#include #include "libguile/_scm.h" #include "libguile/eval.h" @@ -369,6 +370,15 @@ scm_shell_usage (int fatal, char *messag } +static int +terminating_argument (const char *arg) +{ + return (strcmp (arg, "--") == 0 + || strcmp (arg, "-c") == 0 + || strcmp (arg, "-ds") == 0 + || strcmp (arg, "-s") == 0); +} + /* Given an array of command-line switches, return a Scheme expression to carry out the actions specified by the switches. */ @@ -376,6 +386,22 @@ scm_shell_usage (int fatal, char *messag SCM scm_compile_shell_switches (int argc, char **argv) { + int i; + + for (i = 0; i < argc && !terminating_argument (argv[i]); i++) + { + if (strncmp (argv[i], "--locale", sizeof "--locale") == 0) + { + const char *equal; + + equal = strchr (argv[i], '='); + if (equal != NULL) + setlocale (LC_ALL, &argv[i][equal + 1]); + else + setlocale (LC_ALL, ""); + } + } + return scm_call_2 (scm_c_public_ref ("ice-9 command-line", "compile-shell-switches"), scm_makfromstrs (argc, argv), --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable WDYT? It=E2=80=99s not completely satisfying either because --locale is not in 2.0.[0-3], so users who really need it will need some configury; furthermore, from 2.2.x on, it will be mostly unneeded. Yet, a choice has to be made between this hack and the other one. :-) Thoughts? Thanks, Ludo=E2=80=99. --=-=-=--