diff options
author | ache <ache@FreeBSD.org> | 1996-11-26 02:49:53 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-11-26 02:49:53 +0000 |
commit | de0f02e3b7cd27d981f14b6dea4859953e240390 (patch) | |
tree | a6517b924f385d091b11e9ff009dfec8cd705f08 /lib/libc/locale/collate.c | |
parent | dcd629b514014b18a3c683df3e53ece7f0b6e4d7 (diff) | |
download | FreeBSD-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/collate.c')
-rw-r--r-- | lib/libc/locale/collate.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c index 97522192..a74a1a3 100644 --- a/lib/libc/locale/collate.c +++ b/lib/libc/locale/collate.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: collate.c,v 1.7 1996/10/15 21:53:22 ache Exp $ + * $Id: collate.c,v 1.8 1996/10/23 15:35:43 ache Exp $ */ #include <rune.h> @@ -67,10 +67,12 @@ __collate_load_tables(encoding) __collate_load_error = save_load_error; return -1; } - if (!*encoding || !strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) + if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) return 0; - if (!_PathLocale && !(_PathLocale = getenv("PATH_LOCALE"))) - _PathLocale = _PATH_LOCALE; + if (!_PathLocale) { + __collate_load_error = save_load_error; + return -1; + } strcpy(buf, _PathLocale); strcat(buf, "/"); strcat(buf, encoding); |