summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/setrunelocale.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-11-26 02:49:53 +0000
committerache <ache@FreeBSD.org>1996-11-26 02:49:53 +0000
commitde0f02e3b7cd27d981f14b6dea4859953e240390 (patch)
treea6517b924f385d091b11e9ff009dfec8cd705f08 /lib/libc/locale/setrunelocale.c
parentdcd629b514014b18a3c683df3e53ece7f0b6e4d7 (diff)
downloadFreeBSD-src-de0f02e3b7cd27d981f14b6dea4859953e240390.zip
FreeBSD-src-de0f02e3b7cd27d981f14b6dea4859953e240390.tar.gz
PATH_LOCALE: use this non-standard env variable first time only, i.e.
strdup() it to prevent unsetenv() or setenv() effects. Check its length to not allow user to overflow internal locale buffer. Move PATH_LOCALE handling code into one place. POSIX: make better stub for LC_MONETARY & LC_NUMERIC, now it check locale directory existance instead of refusing all non-C non-POSIX locales. POSIX treats empty locale env variable as unset variable while our old code treats it as "C" locale, fix it. Implement previous locale restoring, if locale setting fails. Old code assumes success if some of LC_ALL subset is successed even other fails, POSIX treats it as failure with previous locale restoring, fix it. Remove unneccessary length checking in currentlocale()
Diffstat (limited to 'lib/libc/locale/setrunelocale.c')
-rw-r--r--lib/libc/locale/setrunelocale.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 4889667..228efe29 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -78,14 +78,13 @@ _xpg4_setrunelocale(encoding)
/*
* The "C" and "POSIX" locale are always here.
*/
- if (!*encoding || !strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) {
+ if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) {
_CurrentRuneLocale = &_DefaultRuneLocale;
return(0);
}
- if (!_PathLocale && !(_PathLocale = getenv("PATH_LOCALE")))
- _PathLocale = _PATH_LOCALE;
-
+ if (!_PathLocale)
+ return(EFAULT);
(void) strcpy(name, _PathLocale);
(void) strcat(name, "/");
(void) strcat(name, encoding);
OpenPOWER on IntegriCloud