From 99cef2aaa79c69732233a84462345b30bef389fc Mon Sep 17 00:00:00 2001 From: wollman Date: Fri, 4 Aug 1995 18:43:01 +0000 Subject: Implement locale-sensitive strftime () from ADO (heavily modified by me). This probably loses for multibyte characters, but I have no way of telling. I'll let ache decide whether to add this support to startup_setlocale. Note that for this to make any sense at all, the symlinks in /usr/share/locale must go. (For the moment, this doesn't make any difference since there are no locales supplied.) Obtained from: Arthur David Olson --- lib/libc/locale/setlocale.3 | 7 ++++++- lib/libc/locale/setlocale.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/libc/locale') diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 index e0068f4..f6b75b6 100644 --- a/lib/libc/locale/setlocale.3 +++ b/lib/libc/locale/setlocale.3 @@ -302,7 +302,12 @@ The current implementation supports only the .Li "\&""C"" and .Li "\&""POSIX"" -locales for all but the LC_CTYPE and LC_COLLATE locale. +locales for all but the +.Dv LC_COLLATE , +.Dv LC_CTYPE , +and +.Dv LC_TIME +categories. .Pp In spite of the gnarly currency support in .Fn localeconv , diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index 20bcb6a..8066943 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -166,6 +166,14 @@ loadlocale(category) return (current_categories[LC_COLLATE]); } + if (category == LC_TIME) { + if (__time_load_locale(new_categories[LC_TIME]) < 0) + return (NULL); + strcpy(current_categories[LC_COLLATE], + new_categories[LC_COLLATE]); + return (current_categories[LC_COLLATE]); + } + if (!strcmp(new_categories[category], "C") || !strcmp(new_categories[category], "POSIX")) { @@ -188,7 +196,6 @@ loadlocale(category) switch (category) { case LC_MONETARY: case LC_NUMERIC: - case LC_TIME: return (NULL); } } -- cgit v1.1