summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2015-08-14 14:30:41 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2015-08-14 14:30:41 +0000
commitb129eecfaa5d12e5f009d4b8594128c29d52631b (patch)
treee4448f29c167064e949429033ebc99f70999cdeb /lib
parent8e54230bb91473f2f78395760cafdf130394a01a (diff)
Load LC_MESSAGES locale only if the character encoding is UTF-8.
ok mpi tedu phessler zhuk, and discussed with many at c2k15
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/locale/setlocale.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c
index ca0594671c5..9b0481df199 100644
--- a/lib/libc/locale/setlocale.c
+++ b/lib/libc/locale/setlocale.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setlocale.c,v 1.22 2015/07/02 16:07:43 semarie Exp $ */
+/* $OpenBSD: setlocale.c,v 1.23 2015/08/14 14:30:40 stsp Exp $ */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -207,9 +207,6 @@ revert_to_default(int category)
static int
set_lc_messages_locale(const char *locname)
{
- const char *charset;
- char charsets[sizeof(LOCALE_CHARSETS)];
- char *s = charsets;
const char *dot, *loc_encoding;
/* Assumes "language[_territory][.codeset]" locale name. */
@@ -218,19 +215,7 @@ set_lc_messages_locale(const char *locname)
return -1;
loc_encoding = dot + 1;
- /* Allow message catalogs in encodings supported by LC_CTYPE.
- * We don't care about the language name since it is application
- * specific. */
- memcpy(charsets, LOCALE_CHARSETS, sizeof(charsets));
- do {
- charset = strsep(&s, " \t");
- if (charset && charset[0]) {
- if (strcmp(loc_encoding, charset) == 0)
- return 0;
- }
- } while (charset);
-
- return -1;
+ return strcmp(loc_encoding, "UTF-8") == 0 ? 0 : -1;
}
static int