From de0f02e3b7cd27d981f14b6dea4859953e240390 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 26 Nov 1996 02:49:53 +0000 Subject: 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() --- lib/libc/locale/setrunelocale.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/libc/locale/setrunelocale.c') 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); -- cgit v1.1