summaryrefslogtreecommitdiff
path: root/gnulib-local
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-02-18 00:04:17 +0100
committerLudovic Courtès <ludo@gnu.org>2012-02-18 00:04:17 +0100
commit5de0053178b4acc793ae62838175e5f3ab56c603 (patch)
tree6d6d121a942bc161e87b3480380cf148a6be71ea /gnulib-local
parentcac24946da089e1e1fddf9c9dc7ae7dae9e29014 (diff)
downloadguile-5de0053178b4acc793ae62838175e5f3ab56c603.tar.gz
Don't fail when locale env. vars specify a dot-less locale name.
Fixes <http://bugs.gnu.org/10742>. Reported by Alírio Eyng <alirioeyng@ig.com.br>. * gnulib-local/lib/localcharset.c.diff (environ_locale_charset): Change to set CODESET to "" when LOCALE lacks a dot. Return "ISO-8859-1" when CODESET is the empty string. * lib/localcharset.c: Update. * test-suite/standalone/Makefile.am (check_SCRIPTS): Add `test-command-line-encoding2'. (TESTS): Likewise. * test-suite/standalone/test-command-line-encoding2: New file.
Diffstat (limited to 'gnulib-local')
-rw-r--r--gnulib-local/lib/localcharset.c.diff51
1 files changed, 24 insertions, 27 deletions
diff --git a/gnulib-local/lib/localcharset.c.diff b/gnulib-local/lib/localcharset.c.diff
index 2b27ee479..6f216ad80 100644
--- a/gnulib-local/lib/localcharset.c.diff
+++ b/gnulib-local/lib/localcharset.c.diff
@@ -5,28 +5,10 @@ rationale.
--- a/lib/localcharset.c 2011-12-14 23:10:58.000000000 +0100
+++ b/lib/localcharset.c 2011-12-15 00:45:12.000000000 +0100
-@@ -527,6 +527,76 @@ locale_charset (void)
- codeset = "";
+@@ -545,3 +545,74 @@ locale_charset (void)
- /* Resolve alias. */
-+ for (aliases = get_charset_aliases ();
-+ *aliases != '\0';
-+ aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
-+ if (strcmp (codeset, aliases) == 0
-+ || (aliases[0] == '*' && aliases[1] == '\0'))
-+ {
-+ codeset = aliases + strlen (aliases) + 1;
-+ break;
-+ }
-+
-+ /* Don't return an empty string. GNU libc and GNU libiconv interpret
-+ the empty string as denoting "the locale's character encoding",
-+ thus GNU libiconv would call this function a second time. */
-+ if (codeset[0] == '\0')
-+ codeset = "ASCII";
-+
-+ return codeset;
-+}
+ return codeset;
+ }
+
+/* A variant of the above, without calls to `setlocale', `nl_langinfo',
+ etc. */
@@ -71,14 +53,29 @@ rationale.
+ strcpy (buf, "ASCII");
+ return buf;
+ }
-+
-+ /* Resolve through the charset.alias file. */
-+ codeset = locale;
++ else
++ codeset = "";
+ }
+ else
+ codeset = "";
+
+ /* Resolve alias. */
- for (aliases = get_charset_aliases ();
- *aliases != '\0';
- aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
++ for (aliases = get_charset_aliases ();
++ *aliases != '\0';
++ aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
++ if (strcmp (codeset, aliases) == 0
++ || (aliases[0] == '*' && aliases[1] == '\0'))
++ {
++ codeset = aliases + strlen (aliases) + 1;
++ break;
++ }
++
++ /* Don't return an empty string. GNU libc and GNU libiconv interpret
++ the empty string as denoting "the locale's character encoding",
++ thus GNU libiconv would call this function a second time. */
++ if (codeset[0] == '\0')
++ /* Default to Latin-1, for backward compatibility with Guile 1.8. */
++ codeset = "ISO-8859-1";
++
++ return codeset;
++}