From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Accessing the environment's locale encoding settings Date: Thu, 24 Nov 2011 21:11:40 -0500 Message-ID: <87d3ch6jdv.fsf@netris.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> <878vn6l8qf.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1322187215 5313 80.91.229.12 (25 Nov 2011 02:13:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Nov 2011 02:13:35 +0000 (UTC) Cc: Bruno Haible , guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Nov 25 03:13:27 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 1RTlI5-0006qm-LM for guile-devel@m.gmane.org; Fri, 25 Nov 2011 03:13:25 +0100 Original-Received: from localhost ([::1]:35657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTlI4-0000Us-Sh for guile-devel@m.gmane.org; Thu, 24 Nov 2011 21:13:24 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTlI1-0000Um-RP for guile-devel@gnu.org; Thu, 24 Nov 2011 21:13:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RTlI0-0003pd-LA for guile-devel@gnu.org; Thu, 24 Nov 2011 21:13:21 -0500 Original-Received: from world.peace.net ([96.39.62.75]:52972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTlI0-0003oC-IW; Thu, 24 Nov 2011 21:13:20 -0500 Original-Received: from ip68-9-118-38.ri.ri.cox.net ([68.9.118.38] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1RTlHi-0007zd-V5; Thu, 24 Nov 2011 21:13:04 -0500 In-Reply-To: <878vn6l8qf.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 24 Nov 2011 00:28:08 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 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:12931 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > 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? I like the --locale argument, except that the default (if there is no --locale argument) should be to either (A) call setlocale(LC_ALL, "") or (B) do something like the other hack, where the arguments are decoded as if the locale had been temporarily set according to the environment variables. My strong preference would be Option A. If you are trying to maintain backward compatibility, keep in mind that for most practical purposes, Guile 1.8 acts closer to option A than the other options. Furthermore, Option A is the Right Thing moving forward, and matches what Guile 2.2 will do. If we accept only ASCII arguments by default, then _most_ Guile scripts will need to add the --locale argument, but only for versions after 2.0.3. More likely, many authors won't bother with this ugliness, and their scripts will be broken for non-ASCII locales. If we choose option A, then 2.0.[0123] simply have a bug that was fixed in 2.0.4, and apart from those versions, things will mostly work the right way by default, and fairly close to how Guile 1.8 worked. Also, I see a problem with your code: > @@ -376,6 +386,22 @@ scm_shell_usage (int fatal, char *messag > SCM > scm_compile_shell_switches (int argc, char **argv) > { > + int i; > + > + for (i =3D 0; i < argc && !terminating_argument (argv[i]); i++) > + { > + if (strncmp (argv[i], "--locale", sizeof "--locale") =3D=3D 0) (sizeof "--locale") is 9, not 8. It includes the NULL terminator, so this test will not recognize "--locale=3D...", as you apparently intended based on the code that follows. Best, Mark > + { > + const char *equal; > + > + equal =3D strchr (argv[i], '=3D'); > + if (equal !=3D 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),