From: ludo@gnu.org (Ludovic Courtès)
To: Mike Gran <spk121@yahoo.com>
Cc: Bruno Haible <bruno@clisp.org>,
"guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: Re: Accessing the environment's locale encoding settings
Date: Thu, 24 Nov 2011 00:28:08 +0100 [thread overview]
Message-ID: <878vn6l8qf.fsf@gnu.org> (raw)
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)")
[-- Attachment #1: Type: text/plain, Size: 375 bytes --]
Hi Mike,
Mike Gran <spk121@yahoo.com> skribis:
> Here's a suggestion. One could add an option to the guile interpreter's command
> line args (--locale=ARG perhaps) that has the effect of calling
> setlocale(LC_ALL,"ARG") first thing. If --locale is called with no ARG
> specified, it would call to setlocale(LC_ALL, "").
I tried something along these lines:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1446 bytes --]
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 <stdio.h>
#include <errno.h>
#include <ctype.h>
+#include <locale.h>
#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),
[-- Attachment #3: Type: text/plain, Size: 310 bytes --]
WDYT?
It’s 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’.
next prev parent reply other threads:[~2011-11-23 23:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-16 0:13 Accessing the environment's locale encoding settings Ludovic Courtès
2011-11-16 2:00 ` Bruno Haible
2011-11-16 10:35 ` Ludovic Courtès
2011-11-16 16:11 ` Noah Lavine
2011-11-16 16:32 ` Peter Brett
2011-11-18 22:17 ` Mark H Weaver
2011-11-20 16:55 ` Bruno Haible
2011-11-20 17:41 ` Ludovic Courtès
2011-11-20 19:44 ` Mike Gran
2011-11-23 23:28 ` Ludovic Courtès [this message]
2011-11-24 4:42 ` Mike Gran
2011-11-24 13:16 ` Peter Brett
2011-11-25 2:11 ` Mark H Weaver
2011-12-15 19:08 ` Ludovic Courtès
2011-11-20 20:12 ` Bruno Haible
2011-12-15 0:41 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878vn6l8qf.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=bruno@clisp.org \
--cc=guile-devel@gnu.org \
--cc=spk121@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).