summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2013-06-28 06:14:44 +0100
committerColin Watson <cjwatson@debian.org>2013-06-28 06:14:44 +0100
commit97186737a1e518cd55a38b1358e58c9ee4c05d05 (patch)
tree959e5b636140d6d1ab07d33a58bb5660c3232a04
parentcf4c1b94d63c656e91b7304edb215ccceb303399 (diff)
* lib/encodings.c (find_charset_locale): Attempt fallback locales
even if /usr/share/i18n/SUPPORTED exists. (It may exist but none of the UTF-8 locales mentioned it in may be present; nevertheless, C.UTF-8 may be available.)
-rw-r--r--ChangeLog7
-rw-r--r--lib/encodings.c33
2 files changed, 22 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 82c77025..6a1647d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jun 28 06:13:17 BST 2013 Colin Watson <cjwatson@debian.org>
+
+ * lib/encodings.c (find_charset_locale): Attempt fallback locales
+ even if /usr/share/i18n/SUPPORTED exists. (It may exist but none
+ of the UTF-8 locales mentioned it in may be present; nevertheless,
+ C.UTF-8 may be available.)
+
Thu Jun 27 11:38:56 BST 2013 Colin Watson <cjwatson@debian.org>
* Version: 2.6.5.
diff --git a/lib/encodings.c b/lib/encodings.c
index db616967..d982827d 100644
--- a/lib/encodings.c
+++ b/lib/encodings.c
@@ -591,23 +591,7 @@ char *find_charset_locale (const char *charset)
saved_locale = xstrdup (saved_locale);
supported = fopen (supported_path, "r");
- if (!supported) {
- if (strlen (canonical_charset) >= 5 &&
- STRNEQ (canonical_charset, "UTF-8", 5)) {
- locale = xstrdup ("C.UTF-8");
- if (setlocale (LC_CTYPE, locale))
- goto out;
- free (locale);
- locale = xstrdup ("en_US.UTF-8");
- if (setlocale (LC_CTYPE, locale))
- goto out;
- free (locale);
- locale = NULL;
- }
- goto out;
- }
-
- while (getline (&line, &n, supported) >= 0) {
+ while (supported && getline (&line, &n, supported) >= 0) {
const char *space = strchr (line, ' ');
if (space) {
char *encoding = xstrdup (space + 1);
@@ -620,7 +604,6 @@ char *find_charset_locale (const char *charset)
/* Is this locale actually installed? */
if (setlocale (LC_CTYPE, locale)) {
free (encoding);
- free (line);
goto out;
} else
locale = NULL;
@@ -631,7 +614,21 @@ char *find_charset_locale (const char *charset)
line = NULL;
}
+ if (strlen (canonical_charset) >= 5 &&
+ STRNEQ (canonical_charset, "UTF-8", 5)) {
+ locale = xstrdup ("C.UTF-8");
+ if (setlocale (LC_CTYPE, locale))
+ goto out;
+ free (locale);
+ locale = xstrdup ("en_US.UTF-8");
+ if (setlocale (LC_CTYPE, locale))
+ goto out;
+ free (locale);
+ locale = NULL;
+ }
+
out:
+ free (line);
setlocale (LC_CTYPE, saved_locale);
free (saved_locale);
if (supported)