summaryrefslogtreecommitdiff
path: root/lib/libc/locale
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2013-06-01 20:02:54 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2013-06-01 20:02:54 +0000
commitd854840c77e6560b6edb384e478e6ea19a930d63 (patch)
tree485aa4dadbc159ed5f4355cc9f9c87a53683148c /lib/libc/locale
parent46368757a8a5e3bfa082df4a8fab1ef30b13673a (diff)
Change the naming scheme used for directories in /usr/share/locale to
eliminate redundant copies of LC_CTYPE files. Instead of names using "language_territory.codeset" permutations, use just the codeset component to name directories storing LC_CTYPE files. Suggested by bluhm@ while discussing the idea of using symlinks in /usr/share/locale like FreeBSD does. Future locale features which store language and/or territory specific data can name directories after language or territory names.
Diffstat (limited to 'lib/libc/locale')
-rw-r--r--lib/libc/locale/setlocale.c10
-rw-r--r--lib/libc/locale/setrunelocale.c16
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c
index daba2fec108..3fe0b7345df 100644
--- a/lib/libc/locale/setlocale.c
+++ b/lib/libc/locale/setlocale.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setlocale.c,v 1.18 2011/03/15 22:27:48 stsp Exp $ */
+/* $OpenBSD: setlocale.c,v 1.19 2013/06/01 20:02:53 stsp Exp $ */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -211,9 +211,6 @@ revert_to_default(int category)
static int
load_locale_sub(int category, const char *locname, int isspecial)
{
- char name[PATH_MAX];
- int len;
-
/* check for the default locales */
if (!strcmp(new_categories[category], "C") ||
!strcmp(new_categories[category], "POSIX")) {
@@ -225,11 +222,6 @@ load_locale_sub(int category, const char *locname, int isspecial)
if (strchr(locname, '/') != NULL)
return -1;
- len = snprintf(name, sizeof(name), "%s/%s/%s",
- _PATH_LOCALE, locname, categories[category]);
- if (len < 0 || len >= sizeof(name))
- return -1;
-
switch (category) {
case LC_CTYPE:
if (_xpg4_setrunelocale(locname))
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 880eedebb0a..247f6854ee8 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setrunelocale.c,v 1.9 2013/05/30 18:35:55 stsp Exp $ */
+/* $OpenBSD: setrunelocale.c,v 1.10 2013/06/01 20:02:53 stsp Exp $ */
/* $NetBSD: setrunelocale.c,v 1.14 2003/08/07 16:43:07 agc Exp $ */
/*-
@@ -171,17 +171,27 @@ found:
}
int
-_xpg4_setrunelocale(const char *encoding)
+_xpg4_setrunelocale(const char *locname)
{
char path[PATH_MAX];
_RuneLocale *rl;
int error, len;
+ const char *dot, *encoding;
- if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) {
+ if (!strcmp(locname, "C") || !strcmp(locname, "POSIX")) {
rl = &_DefaultRuneLocale;
goto found;
}
+ /* Assumes "language[_territory][.codeset]" locale name. */
+ dot = strrchr(locname, '.');
+ if (dot == NULL) {
+ /* No encoding specified. Fall back to ASCII. */
+ rl = &_DefaultRuneLocale;
+ goto found;
+ }
+
+ encoding = dot + 1;
len = snprintf(path, sizeof(path),
"%s/%s/LC_CTYPE", _PATH_LOCALE, encoding);
if (len < 0 || len >= sizeof(path))