From 599ad608ee3297bc1e2bb11656a97335e303877a Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Wed, 3 Jul 2002 17:24:17 +0000 Subject: Enable WCHAR support for C/POSIX stub locales. Implemented unformatted wide i/o functions. (ungetwc still needs testing) Fix a few bugs in wchar.c. Modifications for bcc/elks support. --- libc/misc/locale/locale.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'libc/misc/locale') diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c index fd52782c1..689257b41 100644 --- a/libc/misc/locale/locale.c +++ b/libc/misc/locale/locale.c @@ -30,13 +30,7 @@ #include #include -#ifdef __LOCALE_C_ONLY - -#ifdef __WCHAR_ENABLED -#error wide char support requires full locale support -#endif - -#else /* __LOCALE_C_ONLY */ +#ifndef __LOCALE_C_ONLY #define CUR_LOCALE_SPEC (__global_locale.cur_locale) #undef CODESET_LIST @@ -496,14 +490,15 @@ void _locale_set(const unsigned char *p) * ctype, numeric, monetary, time, collate, messages, all */ +#define C_LC_ALL 6 /* Combine the data to avoid size penalty for seperate char arrays when * compiler aligns objects. The original code is left in as documentation. */ #define cat_start nl_data -#define C_locale_data nl_data + LC_ALL + 1 + 78 +#define C_locale_data (nl_data + C_LC_ALL + 1 + 78) -static const unsigned char nl_data[LC_ALL + 1 + 78 + 300] = { -/* static const unsigned char cat_start[LC_ALL + 1] = { */ +static const unsigned char nl_data[C_LC_ALL + 1 + 78 + 300] = { +/* static const unsigned char cat_start[C_LC_ALL + 1] = { */ '\x00', '\x01', '\x04', '\x1a', '\x4c', '\x4c', '\x4e', /* }; */ /* static const unsigned char item_offset[78] = { */ @@ -564,10 +559,10 @@ char *nl_langinfo(nl_item item) unsigned int c; unsigned int i; - if ((c = _NL_ITEM_CATEGORY(item)) < LC_ALL) { + if ((c = _NL_ITEM_CATEGORY(item)) < C_LC_ALL) { if ((i = cat_start[c] + _NL_ITEM_INDEX(item)) < cat_start[c+1]) { /* return (char *) C_locale_data + item_offset[i] + (i & 64); */ - return (char *) C_locale_data + nl_data[LC_ALL+1+i] + (i & 64); + return (char *) C_locale_data + nl_data[C_LC_ALL+1+i] + (i & 64); } } return (char *) cat_start; /* Conveniently, this is the empty string. */ -- cgit v1.2.3