summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/Makefile3
-rw-r--r--libc/misc/ctype/Makefile5
-rw-r--r--libc/misc/ctype/ctype.c486
-rw-r--r--libc/misc/ctype/ctype_C.c517
-rw-r--r--libc/misc/internals/__uClibc_main.c12
-rw-r--r--libc/misc/locale/Makefile15
-rw-r--r--libc/misc/locale/_locale.h22
-rw-r--r--libc/misc/locale/locale.c719
-rw-r--r--libc/misc/locale/localeconv.c52
-rw-r--r--libc/misc/wctype/Makefile47
-rw-r--r--libc/misc/wctype/wctype.c480
11 files changed, 1237 insertions, 1121 deletions
diff --git a/libc/misc/Makefile b/libc/misc/Makefile
index 9040e7e0b..8dcf5486a 100644
--- a/libc/misc/Makefile
+++ b/libc/misc/Makefile
@@ -34,6 +34,9 @@ endif
ifeq ($(strip $(INCLUDE_THREADS)),true)
DIRS += pthread
endif
+ifeq ($(strip $(HAS_WCHAR)),true)
+DIRS += wctype # wchar
+endif
all: libc.a
diff --git a/libc/misc/ctype/Makefile b/libc/misc/ctype/Makefile
index fb099012a..1d7c24535 100644
--- a/libc/misc/ctype/Makefile
+++ b/libc/misc/ctype/Makefile
@@ -28,10 +28,7 @@ MSRC=ctype.c
MOBJ= isalnum.o isalpha.o isascii.o iscntrl.o isdigit.o isgraph.o \
islower.o isprint.o ispunct.o isspace.o isupper.o isxdigit.o \
isxlower.o isxupper.o toascii.o tolower.o toupper.o isblank.o \
-
-ifeq ($(HAS_LOCALE),true)
- MOBJ += ctype_C.o
-endif
+ __isctype_loc.o
CSRC=junk.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index a3d3d4354..dedd5c00a 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -1,341 +1,329 @@
-/* ctype.c
- * Character classification and conversion
- * Copyright (C) 2000 Lineo, Inc.
- * Written by Erik Andersen
- * This file is part of the uClibc C library and is distributed
- * under the GNU Library General Public License.
+/* Copyright (C) 2002 Manuel Novoa III
*
- * not C-locale only code
- * written by Vladimir Oleynik (c) vodz@usa.net
- * and Manuel Novoa III <mnovoa3@bellsouth.net>
- * used ideas is part of the GNU C Library.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#define __USE_CTYPE_MACROS
+/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
+ *
+ * Besides uClibc, I'm using this code in my libc for elks, which is
+ * a 16-bit environment with a fairly limited compiler. It would make
+ * things much easier for me if this file isn't modified unnecessarily.
+ * In particular, please put any new or replacement functions somewhere
+ * else, and modify the makefile to use your version instead.
+ * Thanks. Manuel
+ *
+ * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
+
+#define _GNU_SOURCE
+#define __NO_CTYPE
+
#include <ctype.h>
+#include <stdio.h>
+#include <limits.h>
+#include <assert.h>
+#include <locale.h>
-#ifdef L_isascii
-#undef isascii
-int
-isascii( int c )
-{
- return (c > 0 && c <= 0x7f);
-}
-#endif
+/**********************************************************************/
-#ifdef L_isdigit
-#undef isdigit
-int
-isdigit( int c )
-{
- return (c >= '0' && c <= '9');
-}
-#endif
+extern int __isctype_loc(int c, int ct);
-#ifdef L_toascii
-#undef toascii
-int
-toascii( int c )
-{
- return (c & 0x7f);
-}
-#endif
+/* Some macros used throughout the file. */
+#define U ((unsigned char)c)
+/* #define LCT (__cur_locale->ctype) */
+#define LCT (&__global_locale)
-#ifdef L_isblank
-#undef isblank
-int
-isblank( int c )
-{
- return ((c == ' ') || (c == '\t'));
-}
+/**********************************************************************/
+
+#ifndef __PASTE
+#define __PASTE(X,Y) X ## Y
#endif
-/* locale depended */
-#ifndef __UCLIBC_HAS_LOCALE__
+#define C_MACRO(X) __PASTE(__C_,X)(c)
-#ifdef L_isalpha
-#undef isalpha
-int
-isalpha( int c )
-{
- return (isupper(c) || islower(c));
-}
-#endif
+#define CT_MACRO(X) __PASTE(__ctype_,X)(c)
-#ifdef L_isalnum
-#undef isalnum
-int
-isalnum( int c )
-{
- return (isalpha(c) || isdigit(c));
-}
-#endif
+/**********************************************************************/
-#ifdef L_iscntrl
-#undef iscntrl
-int
-iscntrl( int c )
-{
- return ((c >= 0) && ((c <= 0x1f) || (c == 0x7f)));
-}
-#endif
+#ifndef __CTYPE_HAS_8_BIT_LOCALES
-#ifdef L_isgraph
-#undef isgraph
-int
-isgraph( int c )
-{
- return (c > ' ' && isprint(c));
+#define IS_FUNC_BODY(NAME) \
+int NAME (int c) \
+{ \
+ return C_MACRO(NAME); \
}
-#endif
-#ifdef L_islower
-#undef islower
-int
-islower( int c )
-{
- return (c >= 'a' && c <= 'z');
-}
-#endif
+#else
-#ifdef L_isprint
-#undef isprint
-int
-isprint( int c )
-{
- return (c >= ' ' && c <= '~');
-}
-#endif
+/* It may be worth defining __isctype_loc over the whole range of char. */
+/* #define IS_FUNC_BODY(NAME) \ */
+/* int NAME (int c) \ */
+/* { \ */
+/* return __isctype_loc(c, __PASTE(_CTYPE_,NAME)); \ */
+/* } */
-#ifdef L_ispunct
-#undef ispunct
-int
-ispunct( int c )
-{
- return ((c > ' ' && c <= '~') && !isalnum(c));
+#define IS_FUNC_BODY(NAME) \
+int NAME (int c) \
+{ \
+ if (((unsigned int) c) <= 0x7f) { \
+ return C_MACRO(NAME); \
+ } \
+ return __isctype_loc(c, __PASTE(_CTYPE_,NAME)); \
}
-#endif
-#ifdef L_isspace
-#undef isspace
-int
-isspace( int c )
-{
- return (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||
- c == '\t' || c == '\v');
-}
-#endif
+#endif /* __CTYPE_HAS_8_BIT_LOCALES */
-#ifdef L_isupper
-#undef isupper
-int
-isupper( int c )
-{
- return (c >= 'A' && c <= 'Z');
-}
-#endif
+/**********************************************************************/
+#ifdef L_isalnum
+
+IS_FUNC_BODY(isalnum);
-#ifdef L_isxdigit
-#undef isxdigit
-int
-isxdigit( int c )
-{
- return (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
-}
#endif
+/**********************************************************************/
+#ifdef L_isalpha
+
+IS_FUNC_BODY(isalpha);
-#ifdef L_isxlower
-#undef isxlower
-int
-isxlower( int c )
-{
- return (isdigit(c) || (c >= 'a' && c <= 'f'));
-}
#endif
+/**********************************************************************/
+#ifdef L_isblank
-#ifdef L_isxupper
-#undef isxupper
-int
-isxupper( int c )
+/* Warning!!! This is correct for all the currently supported 8-bit locales.
+ * If any are added though, this will need to be verified. */
+
+int isblank(int c)
{
- return (isdigit(c) || (c >= 'A' && c <= 'F'));
+ return __isblank(c);
}
+
#endif
+/**********************************************************************/
+#ifdef L_iscntrl
+
+IS_FUNC_BODY(iscntrl);
-#ifdef L_tolower
-#undef tolower
-int
-tolower( int c )
-{
- return (isupper(c) ? (c - 'A' + 'a') : (c));
-}
#endif
+/**********************************************************************/
+#ifdef L_isdigit
-#ifdef L_toupper
-#undef toupper
-int
-toupper( int c )
+int isdigit(int c)
{
- return (islower(c) ? (c - 'a' + 'A') : (c));
+ return __isdigit(c);
}
+
#endif
+/**********************************************************************/
+#ifdef L_isgraph
-#else /* __UCLIBC_HAS_LOCALE__ */
+IS_FUNC_BODY(isgraph);
-#include <limits.h>
-#include "../locale/_locale.h"
+#endif
+/**********************************************************************/
+#ifdef L_islower
-#define _UC_ISCTYPE(c, type) \
-((c != -1) && ((_uc_ctype_b[(int)((unsigned char)c)] & type) != 0))
+IS_FUNC_BODY(islower);
-#define _UC_ISCTYPE2(c, type, type2) \
-((c != -1) && ((_uc_ctype_b[(int)((unsigned char)c)] & type) == type2))
+#endif
+/**********************************************************************/
+#ifdef L_isprint
+IS_FUNC_BODY(isprint);
-#ifdef L_ctype_C
+#endif
+/**********************************************************************/
+#ifdef L_ispunct
-/* startup setlocale(LC_TYPE, "C"); */
-#include "ctype_C.c"
+IS_FUNC_BODY(ispunct);
-const unsigned char *_uc_ctype_b = _uc_ctype_b_C;
-const unsigned char *_uc_ctype_trans = _uc_ctype_b_C+LOCALE_BUF_SIZE/2;
+#endif
+/**********************************************************************/
+#ifdef L_isspace
-#endif /* L_ctype_C */
+/* Warning!!! This is correct for all the currently supported 8-bit locales.
+ * If any are added though, this will need to be verified. */
-#ifdef L_isalpha
-#undef isalpha
-int
-isalpha( int c )
+int isspace(int c)
{
- return _UC_ISCTYPE(c, ISalpha);
+ return __isspace(c);
}
-#endif
-#ifdef L_isalnum
-#undef isalnum
-int
-isalnum( int c )
-{
- return _UC_ISCTYPE(c, (ISalpha|ISxdigit));
-}
#endif
+/**********************************************************************/
+#ifdef L_isupper
+
+IS_FUNC_BODY(isupper);
-#ifdef L_iscntrl
-#undef iscntrl
-int
-iscntrl( int c )
-{
- return _UC_ISCTYPE(c, IScntrl);
-}
#endif
+/**********************************************************************/
+#ifdef L_isxdigit
-#ifdef L_isgraph
-#undef isgraph
-int
-isgraph( int c )
+int isxdigit(int c)
{
- return _UC_ISCTYPE2(c, (ISprint|ISspace), ISprint);
+ return __isxdigit(c);
}
+
#endif
+/**********************************************************************/
+#ifdef L_tolower
-#ifdef L_islower
-#undef islower
-int
-islower( int c )
+#ifdef __CTYPE_HAS_8_BIT_LOCALES
+
+int tolower(int c)
{
- return _UC_ISCTYPE(c, ISlower);
+ return ((((unsigned int) c) <= 0x7f)
+ || (LCT->encoding != __ctype_encoding_8_bit))
+ ? __C_tolower(c)
+ : ( __isctype_loc(c, _CTYPE_isupper)
+ ? (unsigned char)
+ ( U - LCT->tbl8uplow[ ((int)
+ (LCT->idx8uplow[(U & 0x7f)
+ >> Cuplow_IDX_SHIFT])
+ << Cuplow_IDX_SHIFT)
+ + (U & ((1 << Cuplow_IDX_SHIFT) - 1)) ])
+ : c );
}
-#endif
-#ifdef L_isprint
-#undef isprint
-int
-isprint( int c )
+#else /* __CTYPE_HAS_8_BIT_LOCALES */
+
+int tolower(int c)
{
- return _UC_ISCTYPE(c, ISprint);
+ return __C_tolower(c);
}
+
+#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+
#endif
+/**********************************************************************/
+#ifdef L_toupper
-#ifdef L_ispunct
-#undef ispunct
-int
-ispunct( int c )
+#ifdef __CTYPE_HAS_8_BIT_LOCALES
+
+int toupper(int c)
{
- return _UC_ISCTYPE(c, ISpunct);
+ return ((((unsigned int) c) <= 0x7f)
+ || (LCT->encoding != __ctype_encoding_8_bit))
+ ? __C_toupper(c)
+ : ( __isctype_loc(c, _CTYPE_islower)
+ ? (unsigned char)
+ ( U + LCT->tbl8uplow[ ((int)
+ (LCT->idx8uplow[(U & 0x7f)
+ >> Cuplow_IDX_SHIFT])
+ << Cuplow_IDX_SHIFT)
+ + (U & ((1 << Cuplow_IDX_SHIFT) - 1)) ])
+ : c );
}
-#endif
-#ifdef L_isspace
-#undef isspace
-int
-isspace( int c )
+#else /* __CTYPE_HAS_8_BIT_LOCALES */
+
+int toupper(int c)
{
- return _UC_ISCTYPE(c, ISspace);
+ return __C_toupper(c);
}
+
+#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+
#endif
+/**********************************************************************/
+#ifdef L_isascii
-#ifdef L_isupper
-#undef isupper
-int
-isupper( int c )
+int isascii(int c)
{
- return _UC_ISCTYPE(c, ISupper);
+ return __isascii(c);
}
+
#endif
+/**********************************************************************/
+#ifdef L_toascii
-#ifdef L_isxdigit
-#undef isxdigit
-int
-isxdigit( int c )
+int toascii(int c)
{
- return _UC_ISCTYPE(c, ISxdigit);
+ return __toascii(c);
}
-#endif
+#endif
+/**********************************************************************/
#ifdef L_isxlower
-#undef isxlower
-int
-isxlower( int c )
+
+int isxlower(int c)
{
- return _UC_ISCTYPE2(c, (ISxdigit|ISupper), ISxdigit);
+ return __isxlower(c);
}
-#endif
+#endif
+/**********************************************************************/
#ifdef L_isxupper
-#undef isxupper
-int
-isxupper( int c )
+
+int isxupper(int c)
{
- return _UC_ISCTYPE2(c, (ISxdigit|ISlower), ISxdigit);
+ return __isxupper(c);
}
+
#endif
+/**********************************************************************/
+#ifdef L___isctype_loc
+#ifdef __CTYPE_HAS_8_BIT_LOCALES
-#ifdef L_tolower
-#undef tolower
-int
-tolower( int c )
+/* This internal routine is similar to iswctype(), but it doesn't
+ * work for any non-standard types, itdoesn't work for "xdigit"s,
+ * and it doesn't work for chars between 0 and 0x7f (although that
+ * may change). */
+
+static const char ctype_range[] = {
+ __CTYPE_RANGES
+};
+
+int __isctype_loc(int c, int ct)
{
- if((c < CHAR_MIN) || (c > UCHAR_MAX))
- return c;
- if(isupper(c))
- return _uc_ctype_trans[(int)((unsigned char)c)];
- else
- return c;
-}
+ unsigned char d;
+
+ assert(((unsigned int)ct) < _CTYPE_isxdigit);
+ assert(((unsigned int)c) > 0x7f);
+
+#if (CHAR_MIN == 0) /* We don't have signed chars... */
+ if ((LCT->encoding != __ctype_encoding_8_bit)
+ || (((unsigned int) c) > UCHAR_MAX)
+ ) {
+ return 0;
+ }
+#else
+ /* Allow non-EOF negative char values for glibc compatiblity. */
+ if ((LCT->encoding != __ctype_encoding_8_bit) || (c == EOF)
+ || ( ((unsigned int)(c - CHAR_MIN)) > (UCHAR_MAX - CHAR_MIN))
+ ) {
+ return 0;
+ }
#endif
-#ifdef L_toupper
-#undef toupper
-int
-toupper( int c )
-{
- if((c < CHAR_MIN) || (c > UCHAR_MAX))
- return c;
- if(islower(c))
- return _uc_ctype_trans[(int)((unsigned char)c)];
- else
- return c;
-}
+ /* TODO - test assumptions??? 8-bit chars -- or ensure in generator. */
+
+#define Cctype_TBL_MASK ((1 << Cctype_IDX_SHIFT) - 1)
+#define Cctype_IDX_OFFSET (128 >> Cctype_IDX_SHIFT)
+
+ c &= 0x7f;
+#ifdef Cctype_PACKED
+ d = LCT->tbl8ctype[ ((int)(LCT->idx8ctype[(U >> Cctype_IDX_SHIFT) ])
+ << (Cctype_IDX_SHIFT - 1))
+ + ((U & Cctype_TBL_MASK) >> 1)];
+ d = (U & 1) ? (d >> 4) : (d & 0xf);
+#else
+ d = LCT->tbl8ctype[ ((int)(LCT->idx8ctype[(U >> Cctype_IDX_SHIFT) ])
+ << Cctype_IDX_SHIFT)
+ + (U & Cctype_TBL_MASK) ];
#endif
+ return ( ((unsigned char)(d - ctype_range[2*ct])) <= ctype_range[2*ct+1] );
+}
+#endif /* __CTYPE_HAS_8_BIT_LOCALES */
#endif
+/**********************************************************************/
diff --git a/libc/misc/ctype/ctype_C.c b/libc/misc/ctype/ctype_C.c
deleted file mode 100644
index 2aa2690b6..000000000
--- a/libc/misc/ctype/ctype_C.c
+++ /dev/null
@@ -1,517 +0,0 @@
-const unsigned char _uc_ctype_b_C[LOCALE_BUF_SIZE] = {
- /* 0x00, 0, 00 */ IScntrl,
- /* 0x01, 1, 01 */ IScntrl,
- /* 0x02, 2, 02 */ IScntrl,
- /* 0x03, 3, 03 */ IScntrl,
- /* 0x04, 4, 04 */ IScntrl,
- /* 0x05, 5, 05 */ IScntrl,
- /* 0x06, 6, 06 */ IScntrl,
- /* 0x07, 7, 07 */ IScntrl,
- /* 0x08, 8, 010 */ IScntrl,
- /* 0x09, 9, 011 */ IScntrl|ISspace,
- /* 0x0a, 10, 012 */ IScntrl|ISspace,
- /* 0x0b, 11, 013 */ IScntrl|ISspace,
- /* 0x0c, 12, 014 */ IScntrl|ISspace,
- /* 0x0d, 13, 015 */ IScntrl|ISspace,
- /* 0x0e, 14, 016 */ IScntrl,
- /* 0x0f, 15, 017 */ IScntrl,
- /* 0x10, 16, 020 */ IScntrl,
- /* 0x11, 17, 021 */ IScntrl,
- /* 0x12, 18, 022 */ IScntrl,
- /* 0x13, 19, 023 */ IScntrl,
- /* 0x14, 20, 024 */ IScntrl,
- /* 0x15, 21, 025 */ IScntrl,
- /* 0x16, 22, 026 */ IScntrl,
- /* 0x17, 23, 027 */ IScntrl,
- /* 0x18, 24, 030 */ IScntrl,
- /* 0x19, 25, 031 */ IScntrl,
- /* 0x1a, 26, 032 */ IScntrl,
- /* 0x1b, 27, 033 */ IScntrl,
- /* 0x1c, 28, 034 */ IScntrl,
- /* 0x1d, 29, 035 */ IScntrl,
- /* 0x1e, 30, 036 */ IScntrl,
- /* 0x1f, 31, 037 */ IScntrl,
- /* 0x20, 32, 040 */ ISprint|ISspace,
- /* 0x21, 33, 041 */ ISprint|ISpunct,
- /* 0x22, 34, 042 */ ISprint|ISpunct,
- /* 0x23, 35, 043 */ ISprint|ISpunct,
- /* 0x24, 36, 044 */ ISprint|ISpunct,
- /* 0x25, 37, 045 */ ISprint|ISpunct,
- /* 0x26, 38, 046 */ ISprint|ISpunct,
- /* 0x27, 39, 047 */ ISprint|ISpunct,
- /* 0x28, 40, 050 */ ISprint|ISpunct,
- /* 0x29, 41, 051 */ ISprint|ISpunct,
- /* 0x2a, 42, 052 */ ISprint|ISpunct,
- /* 0x2b, 43, 053 */ ISprint|ISpunct,
- /* 0x2c, 44, 054 */ ISprint|ISpunct,
- /* 0x2d, 45, 055 */ ISprint|ISpunct,
- /* 0x2e, 46, 056 */ ISprint|ISpunct,
- /* 0x2f, 47, 057 */ ISprint|ISpunct,
- /* 0x30, 48, 060 */ ISprint|ISxdigit,
- /* 0x31, 49, 061 */ ISprint|ISxdigit,
- /* 0x32, 50, 062 */ ISprint|ISxdigit,
- /* 0x33, 51, 063 */ ISprint|ISxdigit,
- /* 0x34, 52, 064 */ ISprint|ISxdigit,
- /* 0x35, 53, 065 */ ISprint|ISxdigit,
- /* 0x36, 54, 066 */ ISprint|ISxdigit,
- /* 0x37, 55, 067 */ ISprint|ISxdigit,
- /* 0x38, 56, 070 */ ISprint|ISxdigit,
- /* 0x39, 57, 071 */ ISprint|ISxdigit,
- /* 0x3a, 58, 072 */ ISprint|ISpunct,
- /* 0x3b, 59, 073 */ ISprint|ISpunct,
- /* 0x3c, 60, 074 */ ISprint|ISpunct,
- /* 0x3d, 61, 075 */ ISprint|ISpunct,
- /* 0x3e, 62, 076 */ ISprint|ISpunct,
- /* 0x3f, 63, 077 */ ISprint|ISpunct,
- /* 0x40, 64, 0100 */ ISprint|ISpunct,
- /* 0x41, 65, 0101 */ ISprint|ISupper|ISalpha|ISxdigit,
- /* 0x42, 66, 0102 */ ISprint|ISupper|ISalpha|ISxdigit,
- /* 0x43, 67, 0103 */ ISprint|ISupper|ISalpha|ISxdigit,
- /* 0x44, 68, 0104 */ ISprint|ISupper|ISalpha|ISxdigit,
- /* 0x45, 69, 0105 */ ISprint|ISupper|ISalpha|ISxdigit,
- /* 0x46, 70, 0106 */ ISprint|ISupper|ISalpha|ISxdigit,
- /* 0x47, 71, 0107 */ ISprint|ISupper|ISalpha,
- /* 0x48, 72, 0110 */ ISprint|ISupper|ISalpha,
- /* 0x49, 73, 0111 */ ISprint|ISupper|ISalpha,
- /* 0x4a, 74, 0112 */ ISprint|ISupper|ISalpha,
- /* 0x4b, 75, 0113 */ ISprint|ISupper|ISalpha,
- /* 0x4c, 76, 0114 */ ISprint|ISupper|ISalpha,
- /* 0x4d, 77, 0115 */ ISprint|ISupper|ISalpha,
- /* 0x4e, 78, 0116 */ ISprint|ISupper|ISalpha,
- /* 0x4f, 79, 0117 */ ISprint|ISupper|ISalpha,
- /* 0x50, 80, 0120 */ ISprint|ISupper|ISalpha,
- /* 0x51, 81, 0121 */ ISprint|ISupper|ISalpha,
- /* 0x52, 82, 0122 */ ISprint|ISupper|ISalpha,
- /* 0x53, 83, 0123 */ ISprint|ISupper|ISalpha,
- /* 0x54, 84, 0124 */ ISprint|ISupper|ISalpha,
- /* 0x55, 85, 0125 */ ISprint|ISupper|ISalpha,
- /* 0x56, 86, 0126 */ ISprint|ISupper|ISalpha,
- /* 0x57, 87, 0127 */ ISprint|ISupper|ISalpha,
- /* 0x58, 88, 0130 */ ISprint|ISupper|ISalpha,
- /* 0x59, 89, 0131 */ ISprint|ISupper|ISalpha,
- /* 0x5a, 90, 0132 */ ISprint|ISupper|ISalpha,
- /* 0x5b, 91, 0133 */ ISprint|ISpunct,
- /* 0x5c, 92, 0134 */ ISprint|ISpunct,
- /* 0x5d, 93, 0135 */ ISprint|ISpunct,
- /* 0x5e, 94, 0136 */ ISprint|ISpunct,
- /* 0x5f, 95, 0137 */ ISprint|ISpunct,
- /* 0x60, 96, 0140 */ ISprint|ISpunct,
- /* 0x61, 97, 0141 */ ISprint|ISlower|ISalpha|ISxdigit,
- /* 0x62, 98, 0142 */ ISprint|ISlower|ISalpha|ISxdigit,
- /* 0x63, 99, 0143 */ ISprint|ISlower|ISalpha|ISxdigit,
- /* 0x64, 100, 0144 */ ISprint|ISlower|ISalpha|ISxdigit,
- /* 0x65, 101, 0145 */ ISprint|ISlower|ISalpha|ISxdigit,
- /* 0x66, 102, 0146 */ ISprint|ISlower|ISalpha|ISxdigit,
- /* 0x67, 103, 0147 */ ISprint|ISlower|ISalpha,
- /* 0x68, 104, 0150 */ ISprint|ISlower|ISalpha,
- /* 0x69, 105, 0151 */ ISprint|ISlower|ISalpha,
- /* 0x6a, 106, 0152 */ ISprint|ISlower|ISalpha,
- /* 0x6b, 107, 0153 */ ISprint|ISlower|ISalpha,
- /* 0x6c, 108, 0154 */ ISprint|ISlower|ISalpha,
- /* 0x6d, 109, 0155 */ ISprint|ISlower|ISalpha,
- /* 0x6e, 110, 0156 */ ISprint|ISlower|ISalpha,
- /* 0x6f, 111, 0157 */ ISprint|ISlower|ISalpha,
- /* 0x70, 112, 0160 */ ISprint|ISlower|ISalpha,
- /* 0x71, 113, 0161 */ ISprint|ISlower|ISalpha,
- /* 0x72, 114, 0162 */ ISprint|ISlower|ISalpha,
- /* 0x73, 115, 0163 */ ISprint|ISlower|ISalpha,
- /* 0x74, 116, 0164 */ ISprint|ISlower|ISalpha,
- /* 0x75, 117, 0165 */ ISprint|ISlower|ISalpha,
- /* 0x76, 118, 0166 */ ISprint|ISlower|ISalpha,
- /* 0x77, 119, 0167 */ ISprint|ISlower|ISalpha,
- /* 0x78, 120, 0170 */ ISprint|ISlower|ISalpha,
- /* 0x79, 121, 0171 */ ISprint|ISlower|ISalpha,
- /* 0x7a, 122, 0172 */ ISprint|ISlower|ISalpha,
- /* 0x7b, 123, 0173 */ ISprint|ISpunct,
- /* 0x7c, 124, 0174 */ ISprint|ISpunct,
- /* 0x7d, 125, 0175 */ ISprint|ISpunct,
- /* 0x7e, 126, 0176 */ ISprint|ISpunct,
- /* 0x7f, 127, 0177 */ IScntrl,
- /* 0x80, 128, 0200 */ 0,
- /* 0x81, 129, 0201 */ 0,
- /* 0x82, 130, 0202 */ 0,
- /* 0x83, 131, 0203 */ 0,
- /* 0x84, 132, 0204 */ 0,
- /* 0x85, 133, 0205 */ 0,
- /* 0x86, 134, 0206 */ 0,
- /* 0x87, 135, 0207 */ 0,
- /* 0x88, 136, 0210 */ 0,
- /* 0x89, 137, 0211 */ 0,
- /* 0x8a, 138, 0212 */ 0,
- /* 0x8b, 139, 0213 */ 0,
- /* 0x8c, 140, 0214 */ 0,
- /* 0x8d, 141, 0215 */ 0,
- /* 0x8e, 142, 0216 */ 0,
- /* 0x8f, 143, 0217 */ 0,
- /* 0x90, 144, 0220 */ 0,
- /* 0x91, 145, 0221 */ 0,
- /* 0x92, 146, 0222 */ 0,
- /* 0x93, 147, 0223 */ 0,
- /* 0x94, 148, 0224 */ 0,
- /* 0x95, 149, 0225 */ 0,
- /* 0x96, 150, 0226 */ 0,
- /* 0x97, 151, 0227 */ 0,
- /* 0x98, 152, 0230 */ 0,
- /* 0x99, 153, 0231 */ 0,
- /* 0x9a, 154, 0232 */ 0,
- /* 0x9b, 155, 0233 */ 0,
- /* 0x9c, 156, 0234 */ 0,
- /* 0x9d, 157, 0235 */ 0,
- /* 0x9e, 158, 0236 */ 0,
- /* 0x9f, 159, 0237 */ 0,
- /* 0xa0, 160, 0240 */ 0,
- /* 0xa1, 161, 0241 */ 0,
- /* 0xa2, 162, 0242 */ 0,
- /* 0xa3, 163, 0243 */ 0,
- /* 0xa4, 164, 0244 */ 0,
- /* 0xa5, 165, 0245 */ 0,
- /* 0xa6, 166, 0246 */ 0,
- /* 0xa7, 167, 0247 */ 0,
- /* 0xa8, 168, 0250 */ 0,
- /* 0xa9, 169, 0251 */ 0,
- /* 0xaa, 170, 0252 */ 0,
- /* 0xab, 171, 0253 */ 0,
- /* 0xac, 172, 0254 */ 0,
- /* 0xad, 173, 0255 */ 0,
- /* 0xae, 174, 0256 */ 0,
- /* 0xaf, 175, 0257 */ 0,
- /* 0xb0, 176, 0260 */ 0,
- /* 0xb1, 177, 0261 */ 0,
- /* 0xb2, 178, 0262 */ 0,
- /* 0xb3, 179, 0263 */ 0,
- /* 0xb4, 180, 0264 */ 0,
- /* 0xb5, 181, 0265 */ 0,
- /* 0xb6, 182, 0266 */ 0,
- /* 0xb7, 183, 0267 */ 0,
- /* 0xb8, 184, 0270 */ 0,
- /* 0xb9, 185, 0271 */ 0,
- /* 0xba, 186, 0272 */ 0,
- /* 0xbb, 187, 0273 */ 0,
- /* 0xbc, 188, 0274 */ 0,
- /* 0xbd, 189, 0275 */ 0,
- /* 0xbe, 190, 0276 */ 0,
- /* 0xbf, 191, 0277 */ 0,
- /* 0xc0, 192, 0300 */ 0,
- /* 0xc1, 193, 0301 */ 0,
- /* 0xc2, 194, 0302 */ 0,
- /* 0xc3, 195, 0303 */ 0,
- /* 0xc4, 196, 0304 */ 0,
- /* 0xc5, 197, 0305 */ 0,
- /* 0xc6, 198, 0306 */ 0,
- /* 0xc7, 199, 0307 */ 0,
- /* 0xc8, 200, 0310 */ 0,
- /* 0xc9, 201, 0311 */ 0,
- /* 0xca, 202, 0312 */ 0,
- /* 0xcb, 203, 0313 */ 0,
- /* 0xcc, 204, 0314 */ 0,
- /* 0xcd, 205, 0315 */ 0,
- /* 0xce, 206, 0316 */ 0,
- /* 0xcf, 207, 0317 */ 0,
- /* 0xd0, 208, 0320 */ 0,
- /* 0xd1, 209, 0321 */ 0,
- /* 0xd2, 210, 0322 */ 0,
- /* 0xd3, 211, 0323 */ 0,
- /* 0xd4, 212, 0324 */ 0,
- /* 0xd5, 213, 0325 */ 0,
- /* 0xd6, 214, 0326 */ 0,
- /* 0xd7, 215, 0327 */ 0,
- /* 0xd8, 216, 0330 */ 0,
- /* 0xd9, 217, 0331 */ 0,
- /* 0xda, 218, 0332 */ 0,
- /* 0xdb, 219, 0333 */ 0,
- /* 0xdc, 220, 0334 */ 0,
- /* 0xdd, 221, 0335 */ 0,
- /* 0xde, 222, 0336 */ 0,
- /* 0xdf, 223, 0337 */ 0,
- /* 0xe0, 224, 0340 */ 0,
- /* 0xe1, 225, 0341 */ 0,
- /* 0xe2, 226, 0342 */ 0,
- /* 0xe3, 227, 0343 */ 0,
- /* 0xe4, 228, 0344 */ 0,
- /* 0xe5, 229, 0345 */ 0,
- /* 0xe6, 230, 0346 */ 0,
- /* 0xe7, 231, 0347 */ 0,
- /* 0xe8, 232, 0350 */ 0,
- /* 0xe9, 233, 0351 */ 0,
- /* 0xea, 234, 0352 */ 0,
- /* 0xeb, 235, 0353 */ 0,
- /* 0xec, 236, 0354 */ 0,
- /* 0xed, 237, 0355 */ 0,
- /* 0xee, 238, 0356 */ 0,
- /* 0xef, 239, 0357 */ 0,
- /* 0xf0, 240, 0360 */ 0,
- /* 0xf1, 241, 0361 */ 0,
- /* 0xf2, 242, 0362 */ 0,
- /* 0xf3, 243, 0363 */ 0,
- /* 0xf4, 244, 0364 */ 0,
- /* 0xf5, 245, 0365 */ 0,
- /* 0xf6, 246, 0366 */ 0,
- /* 0xf7, 247, 0367 */ 0,
- /* 0xf8, 248, 0370 */ 0,
- /* 0xf9, 249, 0371 */ 0,
- /* 0xfa, 250, 0372 */ 0,
- /* 0xfb, 251, 0373 */ 0,
- /* 0xfc, 252, 0374 */ 0,
- /* 0xfd, 253, 0375 */ 0,
- /* 0xfe, 254, 0376 */ 0,
- /* 0xff, 255, 0377 */ 0,
-
-/* _uc_ctype_trans_C */
-
- /* 0x00, 0, 00 */ 0x00,
- /* 0x01, 1, 01 */ 0x01,
- /* 0x02, 2, 02 */ 0x02,
- /* 0x03, 3, 03 */ 0x03,
- /* 0x04, 4, 04 */ 0x04,
- /* 0x05, 5, 05 */ 0x05,
- /* 0x06, 6, 06 */ 0x06,
- /* 0x07, 7, 07 */ 0x07,
- /* 0x08, 8, 010 */ 0x08,
- /* 0x09, 9, 011 */ 0x09,
- /* 0x0a, 10, 012 */ 0x0a,
- /* 0x0b, 11, 013 */ 0x0b,
- /* 0x0c, 12, 014 */ 0x0c,
- /* 0x0d, 13, 015 */ 0x0d,
- /* 0x0e, 14, 016 */ 0x0e,
- /* 0x0f, 15, 017 */ 0x0f,
- /* 0x10, 16, 020 */ 0x10,
- /* 0x11, 17, 021 */ 0x11,
- /* 0x12, 18, 022 */ 0x12,
- /* 0x13, 19, 023 */ 0x13,
- /* 0x14, 20, 024 */ 0x14,
- /* 0x15, 21, 025 */ 0x15,
- /* 0x16, 22, 026 */ 0x16,
- /* 0x17, 23, 027 */ 0x17,
- /* 0x18, 24, 030 */ 0x18,
- /* 0x19, 25, 031 */ 0x19,
- /* 0x1a, 26, 032 */ 0x1a,
- /* 0x1b, 27, 033 */ 0x1b,
- /* 0x1c, 28, 034 */ 0x1c,
- /* 0x1d, 29, 035 */ 0x1d,
- /* 0x1e, 30, 036 */ 0x1e,
- /* 0x1f, 31, 037 */ 0x1f,
- /* 0x20, 32, 040 */ 0x20,
- /* 0x21, 33, 041 */ 0x21,
- /* 0x22, 34, 042 */ 0x22,
- /* 0x23, 35, 043 */ 0x23,
- /* 0x24, 36, 044 */ 0x24,
- /* 0x25, 37, 045 */ 0x25,
- /* 0x26, 38, 046 */ 0x26,
- /* 0x27, 39, 047 */ 0x27,
- /* 0x28, 40, 050 */ 0x28,
- /* 0x29, 41, 051 */ 0x29,
- /* 0x2a, 42, 052 */ 0x2a,
- /* 0x2b, 43, 053 */ 0x2b,
- /* 0x2c, 44, 054 */ 0x2c,
- /* 0x2d, 45, 055 */ 0x2d,
- /* 0x2e, 46, 056 */ 0x2e,
- /* 0x2f, 47, 057 */ 0x2f,
- /* 0x30, 48, 060 */ 0x30,
- /* 0x31, 49, 061 */ 0x31,
- /* 0x32, 50, 062 */ 0x32,
- /* 0x33, 51, 063 */ 0x33,
- /* 0x34, 52, 064 */ 0x34,
- /* 0x35, 53, 065 */ 0x35,
- /* 0x36, 54, 066 */ 0x36,
- /* 0x37, 55, 067 */ 0x37,
- /* 0x38, 56, 070 */ 0x38,
- /* 0x39, 57, 071 */ 0x39,
- /* 0x3a, 58, 072 */ 0x3a,
- /* 0x3b, 59, 073 */ 0x3b,
- /* 0x3c, 60, 074 */ 0x3c,
- /* 0x3d, 61, 075 */ 0x3d,
- /* 0x3e, 62, 076 */ 0x3e,
- /* 0x3f, 63, 077 */ 0x3f,
- /* 0x40, 64, 0100 */ 0x40,
- /* 0x41, 65, 0101 */ 0x61,
- /* 0x42, 66, 0102 */ 0x62,
- /* 0x43, 67, 0103 */ 0x63,
- /* 0x44, 68, 0104 */ 0x64,
- /* 0x45, 69, 0105 */ 0x65,
- /* 0x46, 70, 0106 */ 0x66,
- /* 0x47, 71, 0107 */ 0x67,
- /* 0x48, 72, 0110 */ 0x68,
- /* 0x49, 73, 0111 */ 0x69,
- /* 0x4a, 74, 0112 */ 0x6a,
- /* 0x4b, 75, 0113 */ 0x6b,
- /* 0x4c, 76, 0114 */ 0x6c,
- /* 0x4d, 77, 0115 */ 0x6d,
- /* 0x4e, 78, 0116 */ 0x6e,
- /* 0x4f, 79, 0117 */ 0x6f,
- /* 0x50, 80, 0120 */ 0x70,
- /* 0x51, 81, 0121 */ 0x71,
- /* 0x52, 82, 0122 */ 0x72,
- /* 0x53, 83, 0123 */ 0x73,
- /* 0x54, 84, 0124 */ 0x74,
- /* 0x55, 85, 0125 */ 0x75,
- /* 0x56, 86, 0126 */ 0x76,
- /* 0x57, 87, 0127 */ 0x77,
- /* 0x58, 88, 0130 */ 0x78,
- /* 0x59, 89, 0131 */ 0x79,
- /* 0x5a, 90, 0132 */ 0x7a,
- /* 0x5b, 91, 0133 */ 0x5b,
- /* 0x5c, 92, 0134 */ 0x5c,
- /* 0x5d, 93, 0135 */ 0x5d,
- /* 0x5e, 94, 0136 */ 0x5e,
- /* 0x5f, 95, 0137 */ 0x5f,
- /* 0x60, 96, 0140 */ 0x60,
- /* 0x61, 97, 0141 */ 0x41,
- /* 0x62, 98, 0142 */ 0x42,
- /* 0x63, 99, 0143 */ 0x43,
- /* 0x64, 100, 0144 */ 0x44,
- /* 0x65, 101, 0145 */ 0x45,
- /* 0x66, 102, 0146 */ 0x46,
- /* 0x67, 103, 0147 */ 0x47,
- /* 0x68, 104, 0150 */ 0x48,
- /* 0x69, 105, 0151 */ 0x49,
- /* 0x6a, 106, 0152 */ 0x4a,
- /* 0x6b, 107, 0153 */ 0x4b,
- /* 0x6c, 108, 0154 */ 0x4c,
- /* 0x6d, 109, 0155 */ 0x4d,
- /* 0x6e, 110, 0156 */ 0x4e,
- /* 0x6f, 111, 0157 */ 0x4f,
- /* 0x70, 112, 0160 */ 0x50,
- /* 0x71, 113, 0161 */ 0x51,
- /* 0x72, 114, 0162 */ 0x52,
- /* 0x73, 115, 0163 */ 0x53,
- /* 0x74, 116, 0164 */ 0x54,
- /* 0x75, 117, 0165 */ 0x55,
- /* 0x76, 118, 0166 */ 0x56,
- /* 0x77, 119, 0167 */ 0x57,
- /* 0x78, 120, 0170 */ 0x58,
- /* 0x79, 121, 0171 */ 0x59,
- /* 0x7a, 122, 0172 */ 0x5a,
- /* 0x7b, 123, 0173 */ 0x7b,
- /* 0x7c, 124, 0174 */ 0x7c,
- /* 0x7d, 125, 0175 */ 0x7d,
- /* 0x7e, 126, 0176 */ 0x7e,
- /* 0x7f, 127, 0177 */ 0x7f,
- /* 0x80, 128, 0200 */ 0x80,
- /* 0x81, 129, 0201 */ 0x81,
- /* 0x82, 130, 0202 */ 0x82,
- /* 0x83, 131, 0203 */ 0x83,
- /* 0x84, 132, 0204 */ 0x84,
- /* 0x85, 133, 0205 */ 0x85,
- /* 0x86, 134, 0206 */ 0x86,
- /* 0x87, 135, 0207 */ 0x87,
- /* 0x88, 136, 0210 */ 0x88,
- /* 0x89, 137, 0211 */ 0x89,
- /* 0x8a, 138, 0212 */ 0x8a,
- /* 0x8b, 139, 0213 */ 0x8b,
- /* 0x8c, 140, 0214 */ 0x8c,
- /* 0x8d, 141, 0215 */ 0x8d,
- /* 0x8e, 142, 0216 */ 0x8e,
- /* 0x8f, 143, 0217 */ 0x8f,
- /* 0x90, 144, 0220 */ 0x90,
- /* 0x91, 145, 0221 */ 0x91,
- /* 0x92, 146, 0222 */ 0x92,
- /* 0x93, 147, 0223 */ 0x93,
- /* 0x94, 148, 0224 */ 0x94,
- /* 0x95, 149, 0225 */ 0x95,
- /* 0x96, 150, 0226 */ 0x96,
- /* 0x97, 151, 0227 */ 0x97,
- /* 0x98, 152, 0230 */ 0x98,
- /* 0x99, 153, 0231 */ 0x99,
- /* 0x9a, 154, 0232 */ 0x9a,
- /* 0x9b, 155, 0233 */ 0x9b,
- /* 0x9c, 156, 0234 */ 0x9c,
- /* 0x9d, 157, 0235 */ 0x9d,
- /* 0x9e, 158, 0236 */ 0x9e,
- /* 0x9f, 159, 0237 */ 0x9f,
- /* 0xa0, 160, 0240 */ 0xa0,
- /* 0xa1, 161, 0241 */ 0xa1,
- /* 0xa2, 162, 0242 */ 0xa2,
- /* 0xa3, 163, 0243 */ 0xa3,
- /* 0xa4, 164, 0244 */ 0xa4,
- /* 0xa5, 165, 0245 */ 0xa5,
- /* 0xa6, 166, 0246 */ 0xa6,
- /* 0xa7, 167, 0247 */ 0xa7,
- /* 0xa8, 168, 0250 */ 0xa8,
- /* 0xa9, 169, 0251 */ 0xa9,
- /* 0xaa, 170, 0252 */ 0xaa,
- /* 0xab, 171, 0253 */ 0xab,
- /* 0xac, 172, 0254 */ 0xac,
- /* 0xad, 173, 0255 */ 0xad,
- /* 0xae, 174, 0256 */ 0xae,
- /* 0xaf, 175, 0257 */ 0xaf,
- /* 0xb0, 176, 0260 */ 0xb0,
- /* 0xb1, 177, 0261 */ 0xb1,
- /* 0xb2, 178, 0262 */ 0xb2,
- /* 0xb3, 179, 0263 */ 0xb3,
- /* 0xb4, 180, 0264 */ 0xb4,
- /* 0xb5, 181, 0265 */ 0xb5,
- /* 0xb6, 182, 0266 */ 0xb6,
- /* 0xb7, 183, 0267 */ 0xb7,
- /* 0xb8, 184, 0270 */ 0xb8,
- /* 0xb9, 185, 0271 */ 0xb9,
- /* 0xba, 186, 0272 */ 0xba,
- /* 0xbb, 187, 0273 */ 0xbb,
- /* 0xbc, 188, 0274 */ 0xbc,
- /* 0xbd, 189, 0275 */ 0xbd,
- /* 0xbe, 190, 0276 */ 0xbe,
- /* 0xbf, 191, 0277 */ 0xbf,
- /* 0xc0, 192, 0300 */ 0xc0,
- /* 0xc1, 193, 0301 */ 0xc1,
- /* 0xc2, 194, 0302 */ 0xc2,
- /* 0xc3, 195, 0303 */ 0xc3,
- /* 0xc4, 196, 0304 */ 0xc4,
- /* 0xc5, 197, 0305 */ 0xc5,
- /* 0xc6, 198, 0306 */ 0xc6,
- /* 0xc7, 199, 0307 */ 0xc7,
- /* 0xc8, 200, 0310 */ 0xc8,
- /* 0xc9, 201, 0311 */ 0xc9,
- /* 0xca, 202, 0312 */ 0xca,
- /* 0xcb, 203, 0313 */ 0xcb,
- /* 0xcc, 204, 0314 */ 0xcc,
- /* 0xcd, 205, 0315 */ 0xcd,
- /* 0xce, 206, 0316 */ 0xce,
- /* 0xcf, 207, 0317 */ 0xcf,
- /* 0xd0, 208, 0320 */ 0xd0,
- /* 0xd1, 209, 0321 */ 0xd1,
- /* 0xd2, 210, 0322 */ 0xd2,
- /* 0xd3, 211, 0323 */ 0xd3,
- /* 0xd4, 212, 0324 */ 0xd4,
- /* 0xd5, 213, 0325 */ 0xd5,
- /* 0xd6, 214, 0326 */ 0xd6,
- /* 0xd7, 215, 0327 */ 0xd7,
- /* 0xd8, 216, 0330 */ 0xd8,
- /* 0xd9, 217, 0331 */ 0xd9,
- /* 0xda, 218, 0332 */ 0xda,
- /* 0xdb, 219, 0333 */ 0xdb,
- /* 0xdc, 220, 0334 */ 0xdc,
- /* 0xdd, 221, 0335 */ 0xdd,
- /* 0xde, 222, 0336 */ 0xde,
- /* 0xdf, 223, 0337 */ 0xdf,
- /* 0xe0, 224, 0340 */ 0xe0,
- /* 0xe1, 225, 0341 */ 0xe1,
- /* 0xe2, 226, 0342 */ 0xe2,
- /* 0xe3, 227, 0343 */ 0xe3,
- /* 0xe4, 228, 0344 */ 0xe4,
- /* 0xe5, 229, 0345 */ 0xe5,
- /* 0xe6, 230, 0346 */ 0xe6,
- /* 0xe7, 231, 0347 */ 0xe7,
- /* 0xe8, 232, 0350 */ 0xe8,
- /* 0xe9, 233, 0351 */ 0xe9,
- /* 0xea, 234, 0352 */ 0xea,
- /* 0xeb, 235, 0353 */ 0xeb,
- /* 0xec, 236, 0354 */ 0xec,
- /* 0xed, 237, 0355 */ 0xed,
- /* 0xee, 238, 0356 */ 0xee,
- /* 0xef, 239, 0357 */ 0xef,
- /* 0xf0, 240, 0360 */ 0xf0,
- /* 0xf1, 241, 0361 */ 0xf1,
- /* 0xf2, 242, 0362 */ 0xf2,
- /* 0xf3, 243, 0363 */ 0xf3,
- /* 0xf4, 244, 0364 */ 0xf4,
- /* 0xf5, 245, 0365 */ 0xf5,
- /* 0xf6, 246, 0366 */ 0xf6,
- /* 0xf7, 247, 0367 */ 0xf7,
- /* 0xf8, 248, 0370 */ 0xf8,
- /* 0xf9, 249, 0371 */ 0xf9,
- /* 0xfa, 250, 0372 */ 0xfa,
- /* 0xfb, 251, 0373 */ 0xfb,
- /* 0xfc, 252, 0374 */ 0xfc,
- /* 0xfd, 253, 0375 */ 0xfd,
- /* 0xfe, 254, 0376 */ 0xfe,
- /* 0xff, 255, 0377 */ 0xff
-};
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 23e024e15..ab3ee2fd7 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -34,6 +34,9 @@ extern void weak_function _stdio_init(void);
extern void weak_function _stdio_term(void);
extern int *weak_const_function __errno_location(void);
extern int *weak_const_function __h_errno_location(void);
+#ifdef __UCLIBC_HAS_LOCALE__
+extern void weak_function _locale_init(void);
+#endif
#else
/*
* Define an empty function and use it as a weak alias for the stdio
@@ -62,6 +65,9 @@ extern int atexit(void (*function)(void));
extern int *__errno_location(void);
//weak_alias(__uClibc_empty_func, __h_errno_location);
extern int *__h_errno_location(void);
+#ifdef __UCLIBC_HAS_LOCALE__
+extern void _locale_init(void);
+#endif
#endif
/*
@@ -93,6 +99,12 @@ __uClibc_main(int argc, char **argv, char **envp)
if (unlikely (__libc_enable_secure))
__libc_check_standard_fds ();
#endif
+
+#ifdef __UCLIBC_HAS_LOCALE__
+ /* Initialize the global locale structure. */
+ if (likely(_locale_init)) _locale_init();
+#endif
+
/*
* Initialize stdio here. In the static library case, this will
* be bypassed if not needed because of the weak alias above.
diff --git a/libc/misc/locale/Makefile b/libc/misc/locale/Makefile
index 77a54bdc4..393336c50 100644
--- a/libc/misc/locale/Makefile
+++ b/libc/misc/locale/Makefile
@@ -24,9 +24,14 @@
TOPDIR=../../../
include $(TOPDIR)Rules.mak
-CSRC=locale.c localeconv.c
-COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(COBJS)
+MSRC= locale.c
+MOBJ= setlocale.o localeconv.o _locale_init.o nl_langinfo.o
+
+OBJS= $(MOBJ)
+
+ifeq ($(HAS_LOCALE),true)
+ OBJS += locale_data.o
+endif
all: $(OBJS) $(LIBC)
@@ -35,8 +40,8 @@ $(LIBC): ar-target
ar-target: $(OBJS)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
-$(COBJS): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
+$(MOBJ): $(MSRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(OBJS): Makefile
diff --git a/libc/misc/locale/_locale.h b/libc/misc/locale/_locale.h
deleted file mode 100644
index 139a862f9..000000000
--- a/libc/misc/locale/_locale.h
+++ /dev/null
@@ -1,22 +0,0 @@
-extern const unsigned char *_uc_ctype_b;
-extern const unsigned char *_uc_ctype_trans;
-
-extern const unsigned char _uc_ctype_b_C[256+256];
-
-#define LOCALE_BUF_SIZE (sizeof(_uc_ctype_b_C))
-
-#define ISbit(bit) (1 << bit)
-
-enum
-{
- ISprint = ISbit (0), /* 1 Printable. */
- ISupper = ISbit (1), /* 2 UPPERCASE. */
- ISlower = ISbit (2), /* 4 lowercase. */
- IScntrl = ISbit (3), /* 8 Control character. */
- ISspace = ISbit (4), /* 16 Whitespace. */
- ISpunct = ISbit (5), /* 32 Punctuation. */
- ISalpha = ISbit (6), /* 64 Alphabetic. */
- ISxdigit = ISbit (7), /* 128 Hexnumeric. */
-};
-
-extern const unsigned char *_uc_collate_b;
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index d978ae37c..fd587429b 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -1,332 +1,507 @@
-/* setlocale.c
- * Load LC_CTYPE and LC_COLLATE locale only special for uclibc
+/* Copyright (C) 2002 Manuel Novoa III
*
- * Written by Vladimir Oleynik (c) vodz@usa.net
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This file is part of the uClibc C library and is distributed
- * under the GNU Library General Public License.
- * used ideas is part of the GNU C Library.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* TODO:
+ * Implement the shared mmap code so non-mmu platforms can use this.
+ * Implement nl_langinfo() for the stub locale support.
+ * Add some basic collate functionality similar to what the previous
+ * locale support had (8-bit codesets only).
*/
+#define _GNU_SOURCE
#include <locale.h>
-#include <stdio.h> /* NULL, fopen */
-#include <stdlib.h> /* malloc */
#include <string.h>
-#include <limits.h> /* PATH_MAX */
-#include <errno.h> /* EINVAL */
-#include <unistd.h> /* get(e)[u|g]id */
+#include <stdlib.h>
+#include <stddef.h>
+#include <limits.h>
+#include <stdint.h>
+#include <assert.h>
-#include "_locale.h"
+#ifdef __LOCALE_C_ONLY
-static char C_LOCALE_NAME []="C";
-static char POSIX_LOCALE_NAME[]="POSIX";
-static char composite_name_C []=
-"LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C";
+#ifdef __WCHAR_ENABLED
+#error wide char support requires full locale support
+#endif
-#ifdef __UCLIBC_HAS_LOCALE__
+#else /* __LOCALE_C_ONLY */
-#ifdef TEST_LOCALE
-static const char PATH_LOCALE[]="./";
-#else
-static const char PATH_LOCALE[]=__UCLIBC_LOCALE_DIR;
-#endif
+#define CUR_LOCALE_SPEC (__global_locale.cur_locale)
+#undef CODESET_LIST
+#define CODESET_LIST (__locale_mmap->codeset_list)
-struct SAV_LOADED_LOCALE {
- int category;
- char *locale;
- const unsigned char *buf;
- struct SAV_LOADED_LOCALE *next;
-};
+/* TODO: Optional... See below. */
+#define __LOCALE_STRICTER_SETLOCALE
-static struct SAV_LOADED_LOCALE sll_C_LC_MESSAGES = {
- LC_MESSAGES, C_LOCALE_NAME, 0, 0
-};
+#endif /* __LOCALE_C_ONLY */
-static struct SAV_LOADED_LOCALE sll_C_LC_MONETARY = {
- LC_MONETARY, C_LOCALE_NAME, 0, &sll_C_LC_MESSAGES
-};
+/**********************************************************************/
+#ifdef L_setlocale
-static struct SAV_LOADED_LOCALE sll_C_LC_COLLATE = {
- LC_COLLATE, C_LOCALE_NAME, 0, &sll_C_LC_MONETARY
-};
+#ifdef __LOCALE_C_ONLY
-static struct SAV_LOADED_LOCALE sll_C_LC_TIME = {
- LC_TIME, C_LOCALE_NAME, 0, &sll_C_LC_COLLATE
-};
+link_warning(setlocale,"the 'setlocale' function supports only C|POSIX locales");
-static struct SAV_LOADED_LOCALE sll_C_LC_NUMERIC = {
- LC_NUMERIC, C_LOCALE_NAME, 0, &sll_C_LC_TIME
-};
+static const char C_string[] = "C";
-static struct SAV_LOADED_LOCALE sll_C_LC_CTYPE = {
- LC_CTYPE, C_LOCALE_NAME, _uc_ctype_b_C, &sll_C_LC_NUMERIC
-};
+char *setlocale(int category, register const char *locale)
+{
+ return ( (((unsigned int)(category)) <= LC_ALL)
+ && ( (!locale) /* Request for locale category string. */
+ || (!*locale) /* Implementation-defined default is C. */
+ || ((*locale == 'C') && !locale[1])
+ || (!strcmp(locale, "POSIX"))) )
+ ? (char *) C_string /* Always in C/POSIX locale. */
+ : NULL;
+}
-static struct SAV_LOADED_LOCALE *sll = &sll_C_LC_CTYPE;
+#else /* ---------------------------------------------- __LOCALE_C_ONLY */
+#if !defined(NUM_LOCALES) || (NUM_LOCALES <= 1)
+#error locales enabled, but not data other than for C locale!
+#endif
-#endif /* __UCLIBC_HAS_LOCALE__ */
+static unsigned char setlocale_buf[LOCALE_STRING_SIZE];
-static char *nl_current[LC_ALL+1] = {
- C_LOCALE_NAME, C_LOCALE_NAME, C_LOCALE_NAME,
- C_LOCALE_NAME, C_LOCALE_NAME, C_LOCALE_NAME,
- composite_name_C
-};
+#define LOCALE_NAMES (__locale_mmap->locale_names5)
+#define LOCALES (__locale_mmap->locales)
+#define LOCALE_AT_MODIFIERS (__locale_mmap->locale_at_modifiers)
+#define CATEGORY_NAMES (__locale_mmap->lc_names)
-static const char * const LC_strs[LC_ALL+1] = {
- "/LC_CTYPE",
- "/LC_NUMERIC",
- "/LC_TIME",
- "/LC_COLLATE",
- "/LC_MONETARY",
- "/LC_MESSAGES",
- "/LC_ALL"
-};
+static const char posix[] = "POSIX";
-static char *find_locale(int c, const char **plocale)
+static int find_locale(int category, const char *p, unsigned char *new_locale)
{
-#ifdef __UCLIBC_HAS_LOCALE__
- struct SAV_LOADED_LOCALE *cur;
+ int i;
+ const unsigned char *s;
+ uint16_t n;
+ unsigned char lang_cult, codeset;
+
+#if defined(LOCALE_AT_MODIFIERS_LENGTH) && 1
+ /* Support standard locale handling for @-modifiers. */
+ char buf[18]; /* TODO: 7+{max codeset name length} */
+ const char *q;
+
+ if ((q = strchr(p,'@')) != NULL) {
+ if ((((size_t)((q-p)-5)) > (sizeof(buf) - 5)) || (p[2] != '_')) {
+ return 0;
+ }
+ /* locale name at least 5 chars long and 3rd char is '_' */
+ s = LOCALE_AT_MODIFIERS;
+ do {
+ if (!strcmp(s+2, q+1)) {
+ break;
+ }
+ s += 2 + *s; /* TODO - fix this throughout */
+ } while (*s);
+ if (!*s) {
+ return 0;
+ }
+ memcpy(buf, p, q-p);
+ buf[q-p] = 0;
+ buf[2] = s[1];
+ p = buf;
+ }
#endif
- const char *name = *plocale;
-
- if (name[0] == '\0') {
- /* The user decides which locale to use by setting environment
- variables. */
- name = getenv (&LC_strs[LC_ALL][1]);
- if (name == NULL || name[0] == '\0')
- name = getenv (&LC_strs[c][1]);
- if (name == NULL || name[0] == '\0')
- name = getenv ("LANG");
- if (name == NULL || name[0] == '\0')
- name = C_LOCALE_NAME;
+
+ lang_cult = codeset = 0; /* Assume C and default codeset. */
+ if (((*p == 'C') && !p[1]) || !strcmp(p, posix)) {
+ goto FIND_LOCALE;
}
- if (strcmp (name, C_LOCALE_NAME) == 0 ||
- strcmp (name, POSIX_LOCALE_NAME) == 0 ||
- /* TODO! */ (c!=LC_CTYPE && c!=LC_COLLATE))
- name = C_LOCALE_NAME;
+ if (p[5] == '.') { /* Codeset specified in locale name? */
+ /* TODO: maybe CODESET_LIST + *s ??? */
+ /* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
+ codeset = 2;
+ if (strcmp("UTF-8",p+6) != 0) {/* TODO - fix! */
+ s = CODESET_LIST;
+ do {
+ ++codeset; /* Increment codeset first. */
+ if (!strcmp(CODESET_LIST+*s, p+6)) {
+ goto FIND_LANG_CULT;
+ }
+ } while (*++s);
+ return 0; /* No matching codeset! */
+ }
+ }
- *plocale = name;
+ FIND_LANG_CULT: /* Find language_culture number. */
+ s = LOCALE_NAMES;
+ do { /* TODO -- do a binary search? */
+ /* TODO -- fix gen_mmap!*/
+ ++lang_cult; /* Increment first since C/POSIX is 0. */
+ if (!strncmp(s,p,5)) { /* Found a matching locale name; */
+ goto FIND_LOCALE;
+ }
+ s += 5;
+ } while (lang_cult < NUM_LOCALE_NAMES);
+ return 0; /* No matching language_culture! */
+
+ FIND_LOCALE: /* Find locale row matching name and codeset */
+ s = LOCALES;
+ n = 1;
+ do { /* TODO -- do a binary search? */
+ if ((lang_cult == *s) && ((codeset == s[1]) || (codeset == s[2]))) {
+ i = ((category == LC_ALL) ? 0 : category);
+ s = new_locale + 2*i;
+ do {
+ /* Encode current locale row number. */
+ *((unsigned char *) ++s) = (n >> 8) | 0x80;
+ *((unsigned char *) ++s) = n & 0xff;
+ } while (++i < category);
+
+ return i; /* Return non-zero */
+ }
+ s += WIDTH_LOCALES;
+ ++n;
+ } while (n <= NUM_LOCALES); /* We started at 1!!! */
-#ifdef __UCLIBC_HAS_LOCALE__
- for(cur = sll; cur; cur = cur->next)
- if(cur->category == c && strcmp(cur->locale, name)==0)
- return cur->locale;
-#else
- if(name == C_LOCALE_NAME)
- return C_LOCALE_NAME;
-#endif
- return NULL;
+ return 0; /* Unsupported locale. */
}
-
-#ifdef __UCLIBC_HAS_LOCALE__
-static char *load_locale(int category, const char *locale)
+char *setlocale(int category, const char *locale)
{
- FILE * fl;
- char full_path[PATH_MAX];
- char * buf = 0;
- struct SAV_LOADED_LOCALE *cur;
- struct SAV_LOADED_LOCALE *bottom;
- int bufsize;
- int l = strlen(locale);
-
- if((l+sizeof(PATH_LOCALE)+strlen(LC_strs[category]))>=PATH_MAX)
- return NULL;
-
- /* Not allow acces suid/sgid binaries to outside PATH_LOCALE */
- if((geteuid()!=getuid() || getegid()!=getgid()) &&
- strchr(locale, '/')!=NULL)
- return NULL;
-
- strcpy(full_path, PATH_LOCALE);
- strcat(full_path, locale);
- strcat(full_path, LC_strs[category]);
- fl = fopen(full_path, "r");
- if(fl==0)
- return NULL;
+ const unsigned char *p;
+ unsigned char *s;
+ int i;
+ unsigned lc_mask;
+ unsigned char new_locale[LOCALE_STRING_SIZE];
+
+ if (((unsigned int)(category)) > LC_ALL) {
+ /* TODO - set errno? SUSv3 doesn't say too. */
+ return NULL; /* Illegal/unsupported category. */
+ }
- switch(category) {
- case LC_CTYPE:
- bufsize = LOCALE_BUF_SIZE;
- break;
- case LC_COLLATE:
- bufsize = 256;
- break;
- default: /* TODO */
- bufsize = 0;
- break;
+ lc_mask = 1 << category;
+ if (category == LC_ALL) {
+ --lc_mask;
}
- cur = malloc(sizeof(struct SAV_LOADED_LOCALE)+bufsize+l+2);
- if(cur) {
- buf = (char *)(cur+1);
- if(bufsize!=0 && fread(buf, 1, bufsize+1, fl)!=(bufsize)) {
- /* broken locale file */
- free(cur);
- buf = 0;
-#ifdef TEST_LOCALE
- fprintf(stderr, "\nbroken locale file\n");
-#endif
- }
+ if (!locale) { /* Request for locale category string... */
+ DONE:
+ strcpy(setlocale_buf, CUR_LOCALE_SPEC);
+#ifdef __LOCALE_STRICTER_SETLOCALE
+ /* The standard says you can only use the string returned to restore
+ * the category (categories) requested. This could be optional.
+ * See below as well. */
+ s = setlocale_buf + 1;
+ lc_mask |= (1 << LC_ALL);
+ do {
+ if (!(lc_mask & 1)) {
+ /* Encode non-selected locale flag. */
+ s[1] = *s = 0xff;
+ }
+ s += 2;
+ } while ((lc_mask >>= 1) > 1);
+#endif /* __LOCALE_STRICTER_SETLOCALE */
+ return (char *) setlocale_buf;
}
- fclose(fl);
- if(cur==0) /* not enough memory */
+ strcpy(new_locale, CUR_LOCALE_SPEC); /* Start with current. */
+
+ if (!*locale) { /* locale == "", so check environment. */
+ i = ((category == LC_ALL) ? 0 : category);
+ do {
+ /* Note: SUSv3 doesn't define a fallback mechanism here. So,
+ * if LC_ALL is invalid, we do _not_ continue trying the other
+ * environment vars. */
+ if (!(p = getenv("LC_ALL"))) {
+ if (!(p = getenv(CATEGORY_NAMES + CATEGORY_NAMES[i]))) {
+ if (!(p = getenv("LANG"))) {
+ p = posix;
+ }
+ }
+ }
+
+ /* The user set something... is it valid? */
+ /* Note: Since we don't support user-supplied locales and
+ * alternate paths, we don't need to worry about special
+ * handling for suid/sgid apps. */
+ if (!find_locale(i, p, new_locale)) {
+ return NULL;
+ }
+ } while (++i < category);
+ } else if (*locale == '#') { /* Previsouly returned value. */
+ assert(strlen(locale) == LOCALE_STRING_SIZE - 1);
+
+ i = ((category == LC_ALL) ? 0 : category);
+ p = locale + 2*i;
+ s = new_locale + 2*i;
+ do {
+#ifdef __LOCALE_STRICTER_SETLOCALE
+ /* Only set categories that were selected in the previous
+ * return value. Could be optional. See above as well.
+ * NOTE: This still isn't quite right for non-LC_ALL
+ * as it only checks the category selected to set. */
+ if ((*p == 0xff) && (p[1] == 0xff)) {
+ return NULL;
+ }
+#endif /* __LOCALE_STRICTER_SETLOCALE */
+ /* Note: Validate settings below. */
+ *++s = *++p;
+ *++s = *++p;
+ } while (++i < category);
+ } else if (!find_locale(category, locale, new_locale)) {
return NULL;
- if(buf==0) { /* broken locale file, set to "C" */
- return C_LOCALE_NAME;
}
- cur->next = 0;
- cur->buf = buf;
- cur->category = category;
- cur->locale = buf+bufsize;
- strcpy(cur->locale, locale);
- bottom = sll;
- while(bottom->next!=0)
- bottom = bottom->next;
- bottom->next = cur;
+ /* TODO: Ok, everything checks out, so install the new locale. */
+ _locale_set(new_locale);
- return cur->locale;
+ /* Everything ok, so make a copy in setlocale_buf and return. */
+ goto DONE;
}
-static char *set_composite(int category, char *locale)
+#endif /* __LOCALE_C_ONLY */
+
+#endif
+/**********************************************************************/
+#ifdef L_localeconv
+
+/* Note: We assume here that the compiler does the sane thing regarding
+ * placement of the fields in the struct. If necessary, we could ensure
+ * this usings an array of offsets but at some size cost. */
+
+#ifdef __LOCALE_C_ONLY
+
+#warning localeconv is hardwired for C/POSIX locale only
+link_warning(localeconv,"the 'localeconv' function is hardwired for C/POSIX locale only");
+
+static struct lconv the_lconv;
+
+static const char decpt[] = ".";
+
+struct lconv *localeconv(void)
{
- int i, l;
- char *old_composite_name = nl_current[LC_ALL];
- char *new_composite_name;
- struct SAV_LOADED_LOCALE *cur;
-
- for(l=i=0; i<LC_ALL; i++) {
- new_composite_name = i == category ? locale : nl_current[i];
- /* '=' + ';' or '\0' */
- l += strlen(&LC_strs[i][1])+strlen(new_composite_name)+2;
- }
+ register char *p = (char *)(&the_lconv);
- new_composite_name = malloc(l);
- if(new_composite_name==NULL)
- return NULL;
- if(old_composite_name!=composite_name_C)
- free(old_composite_name);
- nl_current[category] = locale; /* change after malloc */
-
- *new_composite_name = 0;
- for(i=0; i<LC_ALL; i++) {
- if(i)
- strcat(new_composite_name, ";");
- strcat(new_composite_name, &LC_strs[i][1]);
- strcat(new_composite_name, "=");
- strcat(new_composite_name, nl_current[i]);
- }
- nl_current[LC_ALL] = new_composite_name;
-
- /* set locale data for ctype and strcollate functions */
- for(cur = sll; ; cur = cur->next)
- if(cur->category == category && cur->locale == locale)
- break;
-
- switch(category) {
- case LC_CTYPE:
- _uc_ctype_b = cur->buf;
- _uc_ctype_trans = cur->buf+LOCALE_BUF_SIZE/2;
- break;
- case LC_COLLATE:
- _uc_collate_b = cur->buf;
- break;
- default: /* TODO */
- break;
- }
- return locale;
+ *((char **)p) = (char *) decpt;
+ do {
+ p += sizeof(char **);
+ *((char **)p) = (char *) (decpt+1);
+ } while (p < (char *) &the_lconv.negative_sign);
+
+ p = (&the_lconv.int_frac_digits);
+ do {
+ *p = CHAR_MAX;
+ ++p;
+ } while (p <= &the_lconv.int_n_sign_posn);
+
+ return &the_lconv;
}
-#endif /* __UCLIBC_HAS_LOCALE__ */
+#else /* __LOCALE_C_ONLY */
-char *setlocale(int category, const char *locale)
+static struct lconv the_lconv;
+
+struct lconv *localeconv(void)
{
- char * tl;
-#ifdef __UCLIBC_HAS_LOCALE__
- int i;
+ register char *p = (char *) &the_lconv;
+ register char **q = (char **) &__global_locale.decimal_point;
+
+ do {
+ *((char **)p) = *q;
+ p += sizeof(char **);
+ ++q;
+ } while (p < &the_lconv.int_frac_digits);
+
+ do {
+ *p = **q;
+ ++p;
+ ++q;
+ } while (p <= &the_lconv.int_n_sign_posn);
+
+ return &the_lconv;
+}
+
+#endif /* __LOCALE_C_ONLY */
+
#endif
+/**********************************************************************/
+#ifdef L__locale_init
- if (category < 0 || category > LC_ALL) {
-#ifdef __UCLIBC_HAS_LOCALE__
-einval:
+#ifndef __LOCALE_C_ONLY
+
+#define C_LOCALE_SELECTOR "\x23\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01"
+#define LOCALE_INIT_FAILED "locale init failed!\n"
+
+#define CUR_LOCALE_SPEC (__global_locale.cur_locale)
+
+__locale_t __global_locale;
+
+void _locale_init(void)
+{
+ /* TODO: mmap the locale file */
+
+ /* TODO - ??? */
+ memset(CUR_LOCALE_SPEC, 0, LOCALE_STRING_SIZE);
+ CUR_LOCALE_SPEC[0] = '#';
+
+ memcpy(__global_locale.category_item_count,
+ __locale_mmap->lc_common_item_offsets_LEN,
+ LC_ALL);
+
+ __global_locale.category_offsets[0] = offsetof(__locale_t, codeset);
+ __global_locale.category_offsets[1] = offsetof(__locale_t, decimal_point);
+ __global_locale.category_offsets[2] = offsetof(__locale_t, int_curr_symbol);
+ __global_locale.category_offsets[3] = offsetof(__locale_t, abday_1);
+/* __global_locale.category_offsets[4] = offsetof(__locale_t, collate???); */
+ __global_locale.category_offsets[5] = offsetof(__locale_t, yesexpr);
+
+#ifdef __CTYPE_HAS_8_BIT_LOCALES
+ __global_locale.tbl8ctype
+ = (const unsigned char *) &__locale_mmap->tbl8ctype;
+ __global_locale.tbl8uplow
+ = (const unsigned char *) &__locale_mmap->tbl8uplow;
+#ifdef __WCHAR_ENABLED
+ __global_locale.tbl8c2wc
+ = (const uint16_t *) &__locale_mmap->tbl8c2wc;
+ __global_locale.tbl8wc2c
+ = (const unsigned char *) &__locale_mmap->tbl8wc2c;
+ /* translit */
+#endif /* __WCHAR_ENABLED */
+#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#ifdef __WCHAR_ENABLED
+ __global_locale.tblwctype
+ = (const unsigned char *) &__locale_mmap->tblwctype;
+ __global_locale.tblwuplow
+ = (const unsigned char *) &__locale_mmap->tblwuplow;
+ __global_locale.tblwuplow_diff
+ = (const uint16_t *) &__locale_mmap->tblwuplow_diff;
+ __global_locale.tblwcomb
+ = (const unsigned char *) &__locale_mmap->tblwcomb;
+ /* width?? */
+#endif /* __WCHAR_ENABLED */
+
+ _locale_set(C_LOCALE_SELECTOR);
+}
+
+static const char ascii[] = "ASCII";
+static const char utf8[] = "UTF-8";
+
+void _locale_set(const unsigned char *p)
+{
+ const char **x;
+ unsigned char *s = CUR_LOCALE_SPEC + 1;
+ const size_t *stp;
+ const unsigned char *r;
+ const uint16_t *io;
+ const uint16_t *ii;
+ const unsigned char *d;
+ int row; /* locale row */
+ int crow; /* category row */
+ int len;
+ int c;
+ int i = 0;
+
+ ++p;
+ do {
+ if ((*p != *s) || (p[1] != s[1])) {
+ row = (((int)(*p & 0x7f)) << 8) + p[1] - 1;
+#ifndef NDEBUG
+ assert(row < NUM_LOCALES);
#endif
- errno = EINVAL;
- return NULL;
- }
+ *s = *p;
+ s[1] = p[1];
+
+ if (i == LC_CTYPE) {
+ c = __locale_mmap->locales[ WIDTH_LOCALES * row + 2 ]; /* codeset */
+ if (c <= 2) {
+ if (c == 2) {
+ __global_locale.codeset = utf8;
+ __global_locale.encoding = __ctype_encoding_utf8;
+ /* TODO - fix for bcc */
+ __global_locale.mb_cur_max = 6;
+ } else {
+ assert(c==1);
+ __global_locale.codeset = ascii;
+ __global_locale.encoding = __ctype_encoding_7_bit;
+ __global_locale.mb_cur_max = 1;
+ }
+ } else {
+ const codeset_8_bit_t *c8b;
+ r = CODESET_LIST;
+ __global_locale.codeset = r + r[c -= 3];
+ __global_locale.encoding = __ctype_encoding_8_bit;
+#warning REMINDER: update 8 bit mb_cur_max when trasnlit implemented!
+ /* TODO - update when translit implemented! */
+ __global_locale.mb_cur_max = 1;
+ c8b = __locale_mmap->codeset_8_bit + c;
+#ifdef __CTYPE_HAS_8_BIT_LOCALES
+ __global_locale.idx8ctype = c8b->idx8ctype;
+ __global_locale.idx8uplow = c8b->idx8uplow;
+#ifdef __WCHAR_ENABLED
+ __global_locale.idx8c2wc = c8b->idx8c2wc;
+ __global_locale.idx8wc2c = c8b->idx8wc2c;
+ /* translit */
+#endif /* __WCHAR_ENABLED */
+#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+ }
+
+ } else if ((len = __locale_mmap->lc_common_item_offsets_LEN[i]) != 0) {
+ crow = __locale_mmap->locales[ WIDTH_LOCALES * row + 3 + i ]
+ * len;
+ x = (const char **)(((char *) &__global_locale)
+ + __global_locale.category_offsets[i]);
+ stp = __locale_mmap->lc_common_tbl_offsets + 4*i;
+ r = (const unsigned char *)( ((char *)__locale_mmap) + *stp );
+ io = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
+ ii = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
+ d = (const unsigned char *)( ((char *)__locale_mmap) + *++stp );
+ for (c=0 ; c < len ; c++) {
+ *(x + c) = d + ii[ r[crow + c] + io[c] ];
+ }
+ }
- if(locale==NULL)
- return nl_current[category];
-
- if(category!=LC_ALL) {
- tl = find_locale(category, &locale);
-#ifdef __UCLIBC_HAS_LOCALE__
- if(tl==NULL)
- tl = load_locale(category, locale);
- if(tl) {
- if(nl_current[category] != tl)
- tl = set_composite(category, tl);
}
+ ++i;
+ p += 2;
+ s += 2;
+ } while (i < LC_ALL);
+}
+
+#endif /* __LOCALE_C_ONLY */
+
#endif
- return tl;
- }
- /* LC_ALL */
-#ifdef __UCLIBC_HAS_LOCALE__
- /* The user wants to set all categories. The desired locales
- for the individual categories can be selected by using a
- composite locale name. This is a semi-colon separated list
- of entries of the form `CATEGORY=VALUE'. */
- tl = strchr(locale, ';');
- if(tl==NULL) {
- /* This is not a composite name. Load the data for each category. */
- for(i=0; i<LC_ALL; i++)
- setlocale(i, locale); /* recursive */
- } else {
- /* This is a composite name. Make a copy and split it up. */
- const char *newnames[LC_ALL];
- char *np;
- char *cp;
-
- i = strlen(locale);
- np = alloca (i);
- if(np)
- strcpy(np, locale);
- else
- return NULL;
- for (i = 0; i < LC_ALL; ++i)
- newnames[i] = 0;
-
- while ((cp = strchr (np, '=')) != NULL) {
- for (i = 0; i < LC_ALL; ++i)
- if ((size_t) (cp - np) == strlen(&LC_strs[i][1])
- && memcmp (np, &LC_strs[i][1], (cp - np)) == 0)
- break;
-
- if (i == LC_ALL)
- /* Bogus category name. */
- goto einval;
-
- /* Found the category this clause sets. */
- newnames[i] = ++cp;
- cp = strchr (cp, ';');
- if (cp != NULL) {
- /* Examine the next clause. */
- *cp = '\0';
- np = cp + 1;
- } else
- /* This was the last clause. We are done. */
- break;
- }
-
- for (i = 0; i < LC_ALL; ++i)
- setlocale(i, newnames[i]); /* recursive */
+/**********************************************************************/
+#ifdef L_nl_langinfo
+
+#ifndef __LOCALE_C_ONLY
+
+#include <langinfo.h>
+#include <nl_types.h>
+
+static const char empty[] = "";
+
+char *nl_langinfo(nl_item item)
+{
+ unsigned int c = _NL_ITEM_CATEGORY(item);
+ unsigned int i = _NL_ITEM_INDEX(item);
+
+ if ((c < LC_ALL) && (i < __global_locale.category_item_count[c])) {
+ return ((char **)(((char *) &__global_locale)
+ + __global_locale.category_offsets[c]))[i];
+
}
+ return (char *) empty;
+}
+
+#endif /* __LOCALE_C_ONLY */
#endif
- return nl_current[LC_ALL];
-}
+/**********************************************************************/
diff --git a/libc/misc/locale/localeconv.c b/libc/misc/locale/localeconv.c
deleted file mode 100644
index ab447924a..000000000
--- a/libc/misc/locale/localeconv.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* localeconv.c
- *
- * Written by Erik Andersen <andersee@debian.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA. */
-
-#include <string.h>
-#include <locale.h>
-
-/* Return monetary and numeric information about the current locale. */
-struct lconv * localeconv __P ((void))
-{
- static struct lconv result;
- static char *blank = "";
- static char *decimal = ".";
- char junk = '\177';
-
- result.decimal_point = decimal;
- result.thousands_sep = blank;
- result.grouping = "\177";
- result.int_curr_symbol = blank;
- result.currency_symbol = blank;
- result.mon_decimal_point = blank;
- result.mon_thousands_sep = blank;
- result.mon_grouping = blank;
- result.positive_sign = blank;
- result.negative_sign = blank;
- result.int_frac_digits = junk;
- result.frac_digits = junk;
- result.p_cs_precedes = junk;
- result.p_sep_by_space = junk;
- result.n_cs_precedes = junk;
- result.n_sep_by_space = junk;
- result.p_sign_posn = junk;
- result.n_sign_posn = junk;
-
- return &result;
-}
-
diff --git a/libc/misc/wctype/Makefile b/libc/misc/wctype/Makefile
new file mode 100644
index 000000000..875ccef56
--- /dev/null
+++ b/libc/misc/wctype/Makefile
@@ -0,0 +1,47 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000 by Lineo, inc.
+# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Derived in part from the Linux-8086 C library, the GNU C Library, and several
+# other sundry sources. Files within this library are copyright by their
+# respective copyright holders.
+
+TOPDIR=../../../
+include $(TOPDIR)Rules.mak
+
+MSRC= wctype.c
+MOBJ= iswalnum.o iswalpha.o iswcntrl.o iswdigit.o iswgraph.o iswlower.o \
+ iswprint.o iswpunct.o iswspace.o iswupper.o iswxdigit.o towlower.o \
+ towupper.o iswblank.o wctype.o iswctype.o wctrans.o towctrans.o
+
+OBJS=$(MOBJ)
+
+all: $(OBJS) $(LIBC)
+
+$(LIBC): ar-target
+
+ar-target: $(OBJS)
+ $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+
+$(MOBJ): $(MSRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+
+clean:
+ rm -f *.[oa] *~ core
+
diff --git a/libc/misc/wctype/wctype.c b/libc/misc/wctype/wctype.c
new file mode 100644
index 000000000..39ed2cfd5
--- /dev/null
+++ b/libc/misc/wctype/wctype.c
@@ -0,0 +1,480 @@
+/* Copyright (C) 2002 Manuel Novoa III
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
+ *
+ * Besides uClibc, I'm using this code in my libc for elks, which is
+ * a 16-bit environment with a fairly limited compiler. It would make
+ * things much easier for me if this file isn't modified unnecessarily.
+ * In particular, please put any new or replacement functions somewhere
+ * else, and modify the makefile to use your version instead.
+ * Thanks. Manuel
+ *
+ * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
+
+#define _GNU_SOURCE
+#define __NO_CTYPE
+
+#include <wctype.h>
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <locale.h>
+
+/* We know wide char support is enabled. We wouldn't be here otherwise. */
+
+/* Define this if you want to unify the towupper and towlower code in the
+ * towctrans function. */
+/* #define SMALL_UPLOW */
+
+#define __WCTYPE_WITH_LOCALE
+
+/**********************************************************************/
+
+#ifndef __PASTE
+#define __PASTE(X,Y) X ## Y
+#endif
+
+#define C_MACRO(X) __PASTE(__C_,X)(wc)
+
+#define CT_MACRO(X) __PASTE(__ctype_,X)(wc)
+
+/**********************************************************************/
+
+/* TODO: fix this! */
+#ifdef __WCTYPE_WITH_LOCALE
+
+#define WCctype (__global_locale.tblwctype)
+#define WCuplow (__global_locale.tblwuplow)
+#define WCcmob (__global_locale.tblwcomb)
+#define WCuplow_diff (__global_locale.tblwuplow_diff)
+
+#define ENCODING (__global_locale.encoding)
+
+#define ISW_FUNC_BODY(NAME) \
+int NAME (wint_t wc) \
+{ \
+ return iswctype(wc, __PASTE(_CTYPE_,NAME)); \
+}
+
+#else /* __WCTYPE_WITH_LOCALE */
+
+#define ISW_FUNC_BODY(NAME) \
+int NAME (wint_t wc) \
+{ \
+ return C_MACRO(NAME); \
+}
+
+#endif /* __WCTYPE_WITH_LOCALE */
+
+/**********************************************************************/
+#ifdef L_iswalnum
+
+ISW_FUNC_BODY(iswalnum);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswalpha
+
+ISW_FUNC_BODY(iswalpha);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswblank
+
+ISW_FUNC_BODY(iswblank);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswcntrl
+
+ISW_FUNC_BODY(iswcntrl);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswdigit
+
+int iswdigit(wint_t wc)
+{
+ return __C_iswdigit(wc);
+}
+
+#endif
+/**********************************************************************/
+#ifdef L_iswgraph
+
+ISW_FUNC_BODY(iswgraph);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswlower
+
+ISW_FUNC_BODY(iswlower);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswprint
+
+ISW_FUNC_BODY(iswprint);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswpunct
+
+ISW_FUNC_BODY(iswpunct);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswspace
+
+ISW_FUNC_BODY(iswspace);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswupper
+
+ISW_FUNC_BODY(iswupper);
+
+#endif
+/**********************************************************************/
+#ifdef L_iswxdigit
+
+int iswxdigit(wint_t wc)
+{
+ return __C_iswxdigit(wc);
+}
+
+#endif
+/**********************************************************************/
+#ifdef L_towlower
+
+#ifdef __WCTYPE_WITH_LOCALE
+
+#ifdef SMALL_UPLOW
+
+wint_t towlower(wint_t wc)
+{
+ return towctrans(wc, _CTYPE_tolower);
+}
+
+#else
+
+wint_t towlower(wint_t wc)
+{
+ unsigned int sc, n, i;
+ __uwchar_t u = wc;
+
+ if (ENCODING == __ctype_encoding_7_bit) {
+ /* We're in the C/POSIX locale, so ignore the tables. */
+ return __C_towlower(wc);
+ }
+
+ if (u <= WC_TABLE_DOMAIN_MAX) {
+ sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
+ u >>= WCuplow_TI_SHIFT;
+ n = u & ((1 << WCuplow_II_SHIFT) - 1);
+ u >>= WCuplow_II_SHIFT;
+
+ i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
+ << WCuplow_TI_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
+ + i + sc]) << 1;
+ wc += WCuplow_diff[i + 1];
+ }
+ return wc;
+}
+
+#endif
+
+#else /* __WCTYPE_WITH_LOCALE */
+
+wint_t towlower(wint_t wc)
+{
+ return __C_towlower(wc);
+}
+
+#endif /* __WCTYPE_WITH_LOCALE */
+
+#endif
+/**********************************************************************/
+#ifdef L_towupper
+
+#ifdef __WCTYPE_WITH_LOCALE
+
+#ifdef SMALL_UPLOW
+
+wint_t towupper(wint_t wc)
+{
+ return towctrans(wc, _CTYPE_toupper);
+}
+
+#else
+
+wint_t towupper(wint_t wc)
+{
+ unsigned int sc, n, i;
+ __uwchar_t u = wc;
+
+ if (ENCODING == __ctype_encoding_7_bit) {
+ /* We're in the C/POSIX locale, so ignore the tables. */
+ return __C_towupper(wc);
+ }
+
+ if (u <= WC_TABLE_DOMAIN_MAX) {
+ sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
+ u >>= WCuplow_TI_SHIFT;
+ n = u & ((1 << WCuplow_II_SHIFT) - 1);
+ u >>= WCuplow_II_SHIFT;
+
+ i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
+ << WCuplow_TI_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
+ + i + sc]) << 1;
+ wc += WCuplow_diff[i];
+ }
+ return wc;
+}
+
+#endif
+
+#else /* __WCTYPE_WITH_LOCALE */
+
+wint_t towupper(wint_t wc)
+{
+ return __C_towupper(wc);
+}
+
+#endif /* __WCTYPE_WITH_LOCALE */
+
+#endif
+/**********************************************************************/
+#ifdef L_wctype
+
+static const unsigned char typestring[] = __CTYPE_TYPESTRING;
+/* extern const unsigned char typestring[]; */
+
+wctype_t wctype(const char *property)
+{
+ const unsigned char *p;
+ int i;
+
+ p = typestring;
+ i = 1;
+ do {
+ if (!strcmp(property, ++p)) {
+ return i;
+ }
+ ++i;
+ p += p[-1];
+ } while (*p);
+
+ /* TODO - Add locale-specific classifications. */
+ return 0;
+}
+
+#endif
+/**********************************************************************/
+#ifdef L_iswctype
+
+#warning TODO: need to fix locale ctype table lookup stuff
+#if 0
+extern const char ctype_range[];
+#else
+static const char ctype_range[] = {
+ __CTYPE_RANGES
+};
+#endif
+
+#warning TODO: need to handle combining class!
+
+#define WCctype_TI_MASK ((1 << WCctype_TI_SHIFT) - 1)
+#define WCctype_II_MASK ((1 << WCctype_II_SHIFT) - 1)
+
+int iswctype(wint_t wc, wctype_t desc)
+{
+ unsigned int sc, n, i0, i1;
+ unsigned char d = __CTYPE_unclassified;
+
+ if ((ENCODING != __ctype_encoding_7_bit) || (((__uwchar_t) wc) <= 0x7f)){
+ if (desc < _CTYPE_iswxdigit) {
+ if (((__uwchar_t) wc) <= WC_TABLE_DOMAIN_MAX) {
+ /* From here on, we know wc > 0. */
+ sc = wc & WCctype_TI_MASK;
+ wc >>= WCctype_TI_SHIFT;
+ n = wc & WCctype_II_MASK;
+ wc >>= WCctype_II_SHIFT;
+
+ i0 = WCctype[wc];
+ i0 <<= WCctype_II_SHIFT;
+ i1 = WCctype[WCctype_II_LEN + i0 + n];
+ i1 <<= (WCctype_TI_SHIFT-1);
+ d = WCctype[WCctype_II_LEN + WCctype_TI_LEN + i1 + (sc >> 1)];
+
+ d = (sc & 1) ? (d >> 4) : (d & 0xf);
+ } else if ( ((((__uwchar_t)(wc - 0xe0020UL)) <= 0x5f)
+ || (wc == 0xe0001UL))
+ || ( (((__uwchar_t)(wc - 0xf0000UL)) < 0x20000UL)
+ && ((wc & 0xffffU) <= 0xfffdU))
+ ) {
+ d = __CTYPE_punct;
+ }
+
+ return ( ((unsigned char)(d - ctype_range[2*desc]))
+ <= ctype_range[2*desc + 1] )
+ && ((desc != _CTYPE_iswblank) || (d & 1));
+ }
+
+ /* TODO - Add locale-specific classifications. */
+ return (desc == _CTYPE_iswxdigit) ? __C_iswxdigit(wc) : 0;
+ }
+ return 0;
+}
+
+#endif
+/**********************************************************************/
+#ifdef L_towctrans
+
+#ifdef __WCTYPE_WITH_LOCALE
+
+#ifdef SMALL_UPLOW
+
+wint_t towctrans(wint_t wc, wctrans_t desc)
+{
+ unsigned int sc, n, i;
+ __uwchar_t u = wc;
+
+ /* TODO - clean up */
+ if (ENCODING == __ctype_encoding_7_bit) {
+ if ((((__uwchar_t) wc) > 0x7f)
+ || (((unsigned int)(desc - _CTYPE_tolower))
+ > (_CTYPE_toupper - _CTYPE_tolower))
+ ){
+ /* We're in the C/POSIX locale, so ignore non-ASCII values
+ * as well an any mappings other than toupper or tolower. */
+ return wc;
+ }
+ }
+
+ if (((unsigned int)(desc - _CTYPE_tolower))
+ <= (_CTYPE_totitle - _CTYPE_tolower)
+ ) {
+ if (u <= WC_TABLE_DOMAIN_MAX) {
+ sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
+ u >>= WCuplow_TI_SHIFT;
+ n = u & ((1 << WCuplow_II_SHIFT) - 1);
+ u >>= WCuplow_II_SHIFT;
+
+ i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
+ << WCuplow_TI_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
+ + i + sc]) << 1;
+ if (desc == _CTYPE_tolower) {
+ ++i;
+ }
+ wc += WCuplow_diff[i];
+ if (desc == _CTYPE_totitle) {
+ /* WARNING! These special cases work for glibc 2.2.4. Changes
+ * may be needed if the glibc locale tables are updated. */
+ if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
+ || (wc == 0x1f1)
+ ) {
+ ++wc;
+ }
+ }
+ }
+ } else {
+ /* TODO - Deal with other transliterations. */
+ __set_errno(EINVAL);
+ }
+
+ return wc;
+}
+
+#else
+
+wint_t towctrans(wint_t wc, wctrans_t desc)
+{
+ if (ENCODING == __ctype_encoding_7_bit) {
+ if ((((__uwchar_t) wc) > 0x7f)
+ || (((unsigned int)(desc - _CTYPE_tolower))
+ > (_CTYPE_toupper - _CTYPE_tolower))
+ ){
+ /* We're in the C/POSIX locale, so ignore non-ASCII values
+ * as well an any mappings other than toupper or tolower. */
+ return wc;
+ }
+ }
+
+ if (desc == _CTYPE_tolower) {
+ return towlower(wc);
+ } else if (((unsigned int)(desc - _CTYPE_toupper))
+ <= (_CTYPE_totitle - _CTYPE_toupper)
+ ) {
+ wc = towupper(wc);
+ if (desc == _CTYPE_totitle) {
+ /* WARNING! These special cases work for glibc 2.2.4. Changes
+ * may be needed if the glibc locale tables are updated. */
+ if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
+ || (wc == 0x1f1)
+ ) {
+ ++wc;
+ }
+ }
+ } else {
+ /* TODO - Deal with other transliterations. */
+ __set_errno(EINVAL);
+ }
+ return wc;
+}
+
+#endif
+
+#else
+
+
+#endif
+
+#endif
+/**********************************************************************/
+#ifdef L_wctrans
+
+static const char transstring[] = __CTYPE_TRANSTRING;
+
+wctrans_t wctrans(const char *property)
+{
+ const unsigned char *p;
+ int i;
+
+ p = transstring;
+ i = 1;
+ do {
+ if (!strcmp(property, ++p)) {
+ return i;
+ }
+ ++i;
+ p += p[-1];
+ } while (*p);
+
+ /* TODO - Add locale-specific translations. */
+ return 0;
+}
+
+#endif
+/**********************************************************************/