summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnulib-local/lib/localcharset.c.diff51
-rw-r--r--lib/localcharset.c8
-rw-r--r--test-suite/standalone/Makefile.am5
-rwxr-xr-xtest-suite/standalone/test-command-line-encoding220
4 files changed, 52 insertions, 32 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;
++}
diff --git a/lib/localcharset.c b/lib/localcharset.c
index 47a6e5d5b..2c06328cb 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -589,9 +589,8 @@ environ_locale_charset (void)
strcpy (buf, "ASCII");
return buf;
}
-
- /* Resolve through the charset.alias file. */
- codeset = locale;
+ else
+ codeset = "";
}
else
codeset = "";
@@ -611,7 +610,8 @@ environ_locale_charset (void)
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";
+ /* Default to Latin-1, for backward compatibility with Guile 1.8. */
+ codeset = "ISO-8859-1";
return codeset;
}
diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am
index d8cfafa25..daa3d0744 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in.
##
## Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-## 2011 Free Software Foundation, Inc.
+## 2011, 2012 Free Software Foundation, Inc.
##
## This file is part of GUILE.
##
@@ -85,6 +85,9 @@ EXTRA_DIST += test-import-order-a.scm test-import-order-b.scm \
check_SCRIPTS += test-command-line-encoding
TESTS += test-command-line-encoding
+check_SCRIPTS += test-command-line-encoding2
+TESTS += test-command-line-encoding2
+
# test-num2integral
test_num2integral_SOURCES = test-num2integral.c
test_num2integral_CFLAGS = ${test_cflags}
diff --git a/test-suite/standalone/test-command-line-encoding2 b/test-suite/standalone/test-command-line-encoding2
new file mode 100755
index 000000000..536945bc2
--- /dev/null
+++ b/test-suite/standalone/test-command-line-encoding2
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Choose a locale name that lacks a dot followed by the encoding name.
+# This should not confuse `environ_locale_charset'.
+# See <http://bugs.gnu.org/10742> for the original bug report.
+LC_ALL="en_US"
+export LC_ALL
+unset LANG
+unset LC_CTYPE
+
+exec guile -q -s "$0" "hello"
+!#
+
+;; Make sure our argument was suitable decoded.
+(exit (string=? (cadr (program-arguments)) "hello"))
+
+;; Local Variables:
+;; mode: scheme
+;; coding: iso-8859-1
+;; End: