Hi Mike, Mike Gran <spk...@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:
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),
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’.