mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
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.
This commit is contained in:
parent
cac24946da
commit
5de0053178
4 changed files with 52 additions and 32 deletions
|
@ -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;
|
||||
+}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
|
|
20
test-suite/standalone/test-command-line-encoding2
Executable file
20
test-suite/standalone/test-command-line-encoding2
Executable file
|
@ -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:
|
Loading…
Add table
Add a link
Reference in a new issue