Index: trunk/src/emx/include/InnoTekLIBC/locale.h
===================================================================
--- trunk/src/emx/include/InnoTekLIBC/locale.h	(revision 1702)
+++ trunk/src/emx/include/InnoTekLIBC/locale.h	(revision 1705)
@@ -31,4 +31,5 @@
 
 #include <sys/cdefs.h>
+#include <sys/_types.h>
 #include <locale.h>
 #include <uconv.h>
@@ -45,4 +46,5 @@
     /** MBCS prefixes. Two bits per character. */
     unsigned char   au2MBCSPrefixs[256/4];
+#ifdef __OS2__
     /** The converter object to convert to and from selected codepage
       (used with MBCS codepages only). */
@@ -50,4 +52,5 @@
     /** The locale object. */
     LocaleObject    lobj;
+#endif
     /** Non-zero if there are any MBCS prefix characters in codepage. */
     char            mbcs;
@@ -56,4 +59,19 @@
 typedef __LIBC_LOCALECOLLATE *__LIBC_PLOCALECOLLATE;
 
+/**
+ * Multibyte to/from wide character conversion functions.
+ */
+typedef struct __libc_localeCTypeFuncs
+{
+    int     (*pfnmbsinit)(const __mbstate_t *);
+    size_t  (*pfnmbrtowc)(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict);
+    size_t  (*pfnmbsnrtowcs)(__wchar_t * __restrict, const char ** __restrict, size_t, size_t, __mbstate_t * __restrict);
+    size_t  (*pfnwcrtomb)(char * __restrict, __wchar_t, __mbstate_t * __restrict);
+    size_t  (*pfnwcsnrtombs)(char * __restrict, const __wchar_t ** __restrict, size_t, size_t, __mbstate_t * __restrict);
+} __LIBC_LOCALECTYPEFUNCS;
+/** Pointer to multibyte/wide character conversion functions. */
+typedef __LIBC_LOCALECTYPEFUNCS *__LIBC_PLOCALECTYPEFUNCS;
+/** Pointer to const multibyte/wide character conversion functions. */
+typedef const __LIBC_LOCALECTYPEFUNCS *__LIBC_PCLOCALECTYPEFUNCS;
 
 /**
@@ -63,18 +81,40 @@
 {
     /** All uppercased characters. */
-    unsigned char   auchUpper[256];
+    unsigned char           auchUpper[256];
     /** All lowercased characters. */
-    unsigned char   auchLower[256];
+    unsigned char           auchLower[256];
     /** Bit flags for every character (for isXXX() function series). */
-    unsigned short  ausfType[256];
+    unsigned                aufType[256];
+
+/* part which we don't 'expose': */
     /** MBCS prefixes. Two bits per character. */
-    unsigned char   au2MBCSPrefixs[256/4];
+    unsigned char           au2MBCSPrefixs[256/4];
+    /** Unicode translation. (0xffff means not translation.) */
+    unsigned short          aucUnicode[256];
+    /** Unicode -> SBCS conversion: 0..128. */
+    unsigned char           auchToSBCS0To128[128];
+    /** Unicode -> SBCS conversion: Custom regions. */
+    struct
+    {
+        /** First unicode code point. */
+        unsigned short      usStart;
+        /** Number of entries used. */
+        unsigned short      cChars;
+        /** Array SBCS chars corresponding to (wc - usStart). 0 means no conversion. */
+        unsigned char       auch[28];
+    }                       aSBCSs[8];
+    /** Number of aSBCS regions in use. */
+    unsigned                cSBCSs;
+    /** Conversion functions. */
+    __LIBC_LOCALECTYPEFUNCS CtypeFuncs;
+#ifdef __OS2__
     /** The converter object to convert to and from selected codepage
       (used with MBCS codepages only). */
-    UconvObject     uobj;
+    UconvObject             uobj;
     /** The locale object. */
-    LocaleObject    lobj;
+    LocaleObject            lobj;
+#endif
     /** Non-zero if there are any MBCS prefix characters in codepage. */
-    char            mbcs;
+    char                    mbcs;
 } __LIBC_LOCALECTYPE;
 /** Pointer to the Ctype locale struct. */
@@ -83,14 +123,18 @@
 
 /**
- * This structure contains the flags for the default (C/POSIX) locale.
- */
-typedef struct __libc_LocaleCtypeDefault
-{
-    /** Bit flags for every character (for isXXX() function series). */
-    unsigned short  ausfType[256];
-} __LIBC_LOCALECTYPEDEFAULT;
-/** Pointer to the Ctype locale struct. */
-typedef __LIBC_LOCALECTYPEDEFAULT *__LIBC_PLOCALECTYPEDEFAULT;
-
+ * Unicode CType data.
+ * The structure contains information for the first 256 unicode chars.
+ */
+typedef struct __libc_localeWCType
+{
+    /** All uppercased characters. */
+    __wchar_t       awcUpper[256];
+    /** All lowercased characters. */
+    __wchar_t       awcLower[256];
+    /** Bit flags for every character (for iswXXX() function series). */
+    unsigned        aufType[256];
+} __LIBC_LOCALEWCTYPE;
+/** Pointer to the Ctype unicode struct. */
+typedef __LIBC_LOCALEWCTYPE *__LIBC_PLOCALEWCTYPE;
 
 /**
@@ -101,23 +145,41 @@
 {
     /** Short month names. */
-    char *smonths[12];
+    char   *smonths[12];
     /** Long month names. */
-    char *lmonths[12];
+    char   *lmonths[12];
     /** Short weekday names. */
-    char *swdays[7];
+    char   *swdays[7];
     /** Long weekday names. */
-    char *lwdays[7];
+    char   *lwdays[7];
     /** Date and time format. */
-    char *date_time_fmt;
+    char   *date_time_fmt;
     /** Date format. */
-    char *date_fmt;
+    char   *date_fmt;
     /** Time format. */
-    char *time_fmt;
+    char   *time_fmt;
     /** AM strings. */
-    char *am;
+    char   *am;
     /** PM strings. */
-    char *pm;
+    char   *pm;
+    /** AM/PM format. (T_FMT_AMPM) */
+    char   *ampm_fmt;
+    /** ERA */
+    char   *era;
+    /** ERA_D_FMT. */
+    char   *era_date_fmt;
+    /** ERA_D_T_FMT. */
+    char   *era_date_time_fmt;
+    /** ERA_T_FMT. */
+    char   *era_time_fmt;
+    /** ALT_DIGITS. */
+    char   *alt_digits;
+    /** DATESEP. */
+    char   *datesep;
+    /** TIMESEP. */
+    char   *timesep;
+    /** LISTSEP. */
+    char   *listsep;
     /** If set all the strings are consts and shall not be free()ed. */
-    int             fConsts;
+    int     fConsts;
 } __LIBC_LOCALETIME;
 /** Pointer to time locale data. */
@@ -135,4 +197,6 @@
     /** The lconv structure. */
     struct lconv    s;
+    /** CRNCYSTR. */
+    char           *pszCrncyStr;
     /** Indicates that all the numeric members are readonly const strings. */
     int             fNumericConsts;
@@ -145,14 +209,26 @@
 
 /** String collation information. */
-extern __LIBC_LOCALECOLLATE     __libc_gLocaleCollate;
+extern __LIBC_LOCALECOLLATE         __libc_gLocaleCollate;
 /** Character case conversion tables. */
-extern __LIBC_LOCALECTYPE       __libc_GLocaleCtype;
+extern __LIBC_LOCALECTYPE           __libc_GLocaleCtype;
 /** Character case conversion tables for the default 'C'/'POSIX' locale. */
-extern const __LIBC_LOCALECTYPEDEFAULT __libc_GLocaleCtypeDefault;
+extern const __LIBC_LOCALECTYPE     __libc_GLocaleCtypeDefault;
+/** Cached Unicode (__wchar_t) case conversion tables and flags. */
+extern const __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype;
 /** Locale information structure. */
-extern __LIBC_LOCALELCONV       __libc_gLocaleLconv;
+extern __LIBC_LOCALELCONV           __libc_gLocaleLconv;
 /** Date / time formatting rules. */
-extern __LIBC_LOCALETIME        __libc_gLocaleTime;
-
+extern __LIBC_LOCALETIME            __libc_gLocaleTime;
+
+/** Macros to lock the different locale structures.
+ * @{
+ */
+#define LOCALE_LOCK()               do {} while (0)
+#define LOCALE_UNLOCK()             do {} while (0)
+#define LOCALE_CTYPE_RW_LOCK()      do {} while (0)
+#define LOCALE_CTYPE_RW_UNLOCK()    do {} while (0)
+#define LOCALE_CTYPE_RW_LOCK()      do {} while (0)
+#define LOCALE_CTYPE_RW_UNLOCK()    do {} while (0)
+/** @} */
 
 /** Convert a string to Unicode, apply some transform and convert back. */
@@ -165,4 +241,24 @@
 extern void __libc_TranslateCodepage(const char *cp, UniChar *ucp);
 
+extern int __libc_localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj);
+
+extern void __libc_localeFuncsSBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+extern void __libc_localeFuncsDBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+extern void __libc_localeFuncsMBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+extern void __libc_localeFuncsUCS2(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+extern void __libc_localeFuncsUTF8(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+extern void __libc_localeFuncsDefault(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+
+extern size_t  __libc_localeFuncsGeneric_mbsnrtowcs(size_t  (*pfnmbrtowc)(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict),
+                                                    __wchar_t * __restrict dst, const char ** __restrict src, size_t nms, size_t len, __mbstate_t * __restrict ps);
+extern size_t  __libc_localeFuncsGeneric_wcsnrtombs(size_t  (*pfnwcrtomb)(char * __restrict, __wchar_t, __mbstate_t * __restrict),
+                                                    char * __restrict dst, const __wchar_t ** __restrict src, size_t nwc, size_t len, __mbstate_t * __restrict ps);
+
+extern void     __libc_localeFuncsNone(__LIBC_PLOCALECTYPEFUNCS pFuncs);
+extern size_t   __libc_locale_none_mbrtowc(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict);
+extern int      __libc_locale_none_mbsinit(const __mbstate_t *);
+extern size_t   __libc_locale_none_mbsnrtowcs(__wchar_t * __restrict dst, const char ** __restrict src, size_t nms, size_t len, __mbstate_t * __restrict ps __unused);
+extern size_t   __libc_locale_none_wcrtomb(char * __restrict, __wchar_t, __mbstate_t * __restrict);
+extern size_t   __libc_locale_none_wcsnrtombs(char * __restrict, const __wchar_t ** __restrict, size_t, size_t, __mbstate_t * __restrict);
 
 
Index: trunk/src/emx/include/_ctype.h
===================================================================
--- trunk/src/emx/include/_ctype.h	(revision 1702)
+++ trunk/src/emx/include/_ctype.h	(revision 1705)
@@ -34,5 +34,5 @@
 __BEGIN_DECLS
 /**
- * Simplified Ctype structure for inline functions.
+ * Simplified Ctype structures for inline functions.
  */
 extern struct
@@ -43,109 +43,216 @@
     unsigned char   auchLower[256];
     /** Bit flags for every character (for isXXX() function series). */
-    unsigned short  ausfType[256];
+    unsigned        aufType[256];
 } __libc_GLocaleCtype;
 
 /**
- * Simplified Default Ctype structure for inline functions.
+ * Simplified Default Ctype structures for inline functions.
  */
 extern const struct
 {
+    /** All uppercased characters. */
+    unsigned char   auchUpper[256];
+    /** All lowercased characters. */
+    unsigned char   auchLower[256];
     /** Bit flags for every character (for isXXX() function series). */
-    unsigned short  ausfType[256];
+    unsigned        aufType[256];
 } __libc_GLocaleCtypeDefault;
+
+/**
+ * Unicode CType data.
+ * The structure contains information for the first 256 unicode chars.
+ */
+extern const struct __libc_localeWCType
+{
+    /** All uppercased characters. */
+    __wchar_t       awcUpper[256];
+    /** All lowercased characters. */
+    __wchar_t       awcLower[256];
+    /** Bit flags for every character (for iswXXX() function series). */
+    unsigned        aufType[256];
+} __libc_GLocaleWCtype;
 __END_DECLS
 #endif /* !__InnoTekLIBC_locale_h__ */
 
 
-/** Bit masks for the ausfType member of __libc_GLocaleCtype
+/** Bit masks for the aufType member of __libc_GLocaleCtype
  *  and __libc_GLocaleCtypeDefault
  *
- * @remark These have identical values to the CT_* to speed up setlocale().
+ * @remark These have values identical values to the CT_* << 8 to speed up
+ *         setlocale() and to make us compatible with the BSD scheme. In addition
+ *         values C3_IDEOGRAPH and the C2_* << 24 are converted into the value. The
+ *         screen width stuff is attempted derived from other info provided by the
+ *         unicode libraries.
  * @{
  */
-#define __UPPER     0x0001      /** Upper case alphabetic character. */
-#define __LOWER     0x0002      /** Lower case alphabetic character. */
-#define __DIGIT     0x0004      /** Digits 0-9. */
-#define __SPACE     0x0008      /** White space and line ends. */
-#define __PUNCT     0x0010      /** Punctuation marks. */
-#define __CNTRL     0x0020      /** Control and format characters. */
-#define __BLANK     0x0040      /** Space and tab. */
-#define __XDIGIT    0x0080      /** Hex digits. */
-#define __ALPHA     0x0100      /** Letters and linguistic marks. */
-#define __ALNUM     0x0200      /** Alphanumeric. */
-#define __GRAPH     0x0400      /** All except controls and space. */
-#define __PRINT     0x0800      /** Everything except controls. */
-#define __NUMBER    0x1000      /** Integral number. */
-#define __SYMBOL    0x2000      /** Symbol. */
-#define __ASCII     0x8000      /** In standard ASCII set. */
-
-/* BSD compatability */
-#define _CTYPE_A    __ALPHA
-#define _CTYPE_C    __CNTRL
-#define _CTYPE_D    __DIGIT
-#define _CTYPE_G    __GRAPH
-#define _CTYPE_L    __LOWER
-#define _CTYPE_P    __PUNCT
-#define _CTYPE_S    __SPACE
-#define _CTYPE_U    __UPPER
-#define _CTYPE_X    __XDIGIT
-#define _CTYPE_B    __BLANK
-#define _CTYPE_R    __PRINT
-#if 0 //later
-#define	_CTYPE_I    	0x00080000L		/* Ideogram */
-#define	_CTYPE_T    	0x00100000L		/* Special */
-#define	_CTYPE_Q	0x00200000L		/* Phonogram */
-
-#define	_CTYPE_SW0	0x20000000L		/* 0 width character */
-#define	_CTYPE_SW1	0x40000000L		/* 1 width character */
-#define	_CTYPE_SW2	0x80000000L		/* 2 width character */
-#define	_CTYPE_SW3	0xc0000000L		/* 3 width character */
-#define	_CTYPE_SWM	0xe0000000L		/* Mask for screen width data */
-#define	_CTYPE_SWS	30			/* Bits to shift to get width */
+#define __CT_NUM_MASK   0x000000ffU     /** Numberic value for digit to int conversion. */
+
+#define __CT_UPPER      0x00000100U     /** Upper case alphabetic character. */
+#define __CT_LOWER      0x00000200U     /** Lower case alphabetic character. */
+#define __CT_DIGIT      0x00000400U     /** Digits 0-9. */
+#define __CT_SPACE      0x00000800U     /** White space and line ends. */
+#define __CT_PUNCT      0x00001000U     /** Punctuation marks. */
+#define __CT_CNTRL      0x00002000U     /** Control and format characters. */
+#define __CT_BLANK      0x00004000U     /** Space and tab. */
+#define __CT_XDIGIT     0x00008000U     /** Hex digits. */
+#define __CT_ALPHA      0x00010000U     /** Letters and linguistic marks. */
+#define __CT_ALNUM      0x00020000U     /** Alphanumeric - obsolete (__CT_ALPHA | __CT_DIGIT) is the same. */
+#define __CT_GRAPH      0x00040000U     /** All except controls and space. */
+#define __CT_PRINT      0x00080000U     /** Everything except controls. */
+#define __CT_NUMBER     0x00100000U     /** Integral number. */
+#define __CT_SYMBOL     0x00200000U     /** Symbol. */
+#define __CT_ASCII      0x00800000U     /** In standard ASCII set. */
+
+#define __CT_IDEOGRAM   0x00400000U     /** Ideogram. (C3_IDEOGRAPH?) (Unused/known CT_ bit.) */
+
+/* #define __CT_BIDI_MASK  0x0f000000U - not implemented */     /** Bidi mask C2_*. */
+
+#define __CT_SCRW0      0x20000000U     /** 0 width character. (Just indicator for SW data when width is 0.) */
+#define __CT_SCRW1      0x40000000U     /** 1 width character. */
+#define __CT_SCRW2      0x80000000U     /** 2 width character. */
+#define __CT_SCRW3      0xc0000000U     /** 3 width character. */
+#define __CT_SCRW_MASK  0xe0000000U     /** Mask for screen width data. */
+#define __CT_SCRW_SHIFT 30              /** Bits to shift to get width. */
+
+/** BSD compatability.
+ * @{ */
+#define _CTYPE_A        __CT_ALPHA
+#define _CTYPE_C        __CT_CNTRL
+#define _CTYPE_D        __CT_DIGIT
+#define _CTYPE_G        __CT_GRAPH
+#define _CTYPE_L        __CT_LOWER
+#define _CTYPE_P        __CT_PUNCT
+#define _CTYPE_S        __CT_SPACE
+#define _CTYPE_U        __CT_UPPER
+#define _CTYPE_X        __CT_XDIGIT
+#define _CTYPE_B        __CT_BLANK
+#define _CTYPE_R        __CT_PRINT
+#define _CTYPE_I        __CT_IDEOGRAM
+#if 0 /* We don't have this info :/ */
+#define _CTYPE_T    	0x00100000L		/* Special */
+#define _CTYPE_Q	0x00200000L		/* Phonogram */
 #endif
-
-/** @} */
-
-
-__BEGIN_DECLS
-int ___istype(__ct_rune_t, unsigned);
-__ct_rune_t ___tolower(__ct_rune_t);
-__ct_rune_t ___toupper(__ct_rune_t);
-__END_DECLS
+#define _CTYPE_SW0      __CT_SCRW0
+#define _CTYPE_SW1      __CT_SCRW1
+#define _CTYPE_SW2      __CT_SCRW2
+#define _CTYPE_SW3      __CT_SCRW3
+#define _CTYPE_SWM      __CT_SCRW_MASK
+#define _CTYPE_SWS      __CT_SCRW_SHIFT
+/** @} */
+/** @} */
+
+
+/** Functions for handling runes outside the 0-255 range.
+ * @{ */
+__BEGIN_DECLS
+unsigned ___wctype(__wchar_t);
+__wchar_t ___towlower(__wchar_t);
+__wchar_t ___towupper(__wchar_t);
+__END_DECLS
+/** @} */
+
 
 #if !defined(_DONT_USE_CTYPE_INLINE_) && \
     (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
 
-__BEGIN_DECLS
-static inline int __istype(__ct_rune_t _c, unsigned _f)
-{
-    return !(_c & 0xffffff00) ? (__libc_GLocaleCtype.ausfType[_c & 0xff] & (_f)) != 0 : ___istype(_c, _f);
-}
-
-static inline int __isctype(__ct_rune_t _c, unsigned _f)
-{
-    return (__libc_GLocaleCtypeDefault.ausfType[_c & 0xff] & (_f)) != 0;
-}
-
-static inline int __toupper(__ct_rune_t _c)
-{
-    return !(_c & 0xffffff00) ? __libc_GLocaleCtype.auchUpper[_c & 0xff] : ___toupper(_c);
-}
-
-static inline int __tolower(__ct_rune_t _c)
-{
-    return !(_c & 0xffffff00) ? __libc_GLocaleCtype.auchLower[_c & 0xff] : ___tolower(_c);
-}
-__END_DECLS
+/** Inlined function versions.
+ * @{
+ */
+__BEGIN_DECLS
+static inline unsigned __ctype(__ct_rune_t __ch, unsigned __f)
+{
+    return !((__ch) & ~0xffU)
+        ? __libc_GLocaleCtype.aufType[(__ch)/* & 0xff*/] & (__f)
+        : 0;
+}
+
+static inline int __istype(__ct_rune_t __ch, unsigned __f)
+{
+    return !!__ctype((__ch), (__f));
+}
+
+static inline int __isctype(__ct_rune_t __ch, unsigned __f)
+{
+    return !((__ch) & ~0xffU)
+        ? !!(__libc_GLocaleCtypeDefault.aufType[(__ch)/* & 0xff*/] & (__f))
+        : 0;
+}
+
+static inline __ct_rune_t __toupper(__ct_rune_t __ch)
+{
+    return !((__ch) & ~0xffU)
+        ? __libc_GLocaleCtype.auchUpper[(__ch)/* & 0xff*/]
+        : (__ch);
+}
+
+static inline __ct_rune_t __tolower(__ct_rune_t __ch)
+{
+    return !((__ch) & ~0xffU)
+        ? __libc_GLocaleCtype.auchLower[(__ch)/* & 0xff*/]
+        : (__ch);
+}
+
+
+static inline unsigned __wctype(__wint_t __wc, unsigned __f)
+{
+    return !((__wc) & ~0xffU)
+        ? __libc_GLocaleWCtype.aufType[(__wc)] & (__f)
+        : ___wctype(__wc) & (__f);
+}
+
+static inline int __iswtype(__wint_t __wc, unsigned __f)
+{
+    return !!__wctype((__wc), (__f));
+}
+
+static inline __wint_t __towupper(__wint_t __wc)
+{
+    return !((__wc) & ~0xffU)
+        ? __libc_GLocaleWCtype.awcUpper[(__wc)]
+        : ___towupper(__wc);
+}
+
+static inline __wint_t __towlower(__wint_t __wc)
+{
+    return !((__wc) & ~0xffU)
+        ? __libc_GLocaleWCtype.awcLower[(__wc)]
+        : ___towlower(__wc);
+}
+
+
+static inline int __wcwidth(__wint_t __wc)
+{
+    if ((__wc) != 0)
+    {
+        unsigned __f = __wctype((__wc), __CT_SCRW_MASK | __CT_PRINT);
+        return ((__f) & __CT_SCRW_MASK)
+            ? ((__f) & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
+            : ((__f) & __CT_PRINT) ? 1 : -1;
+    }
+    else
+        return 0;
+}
+__END_DECLS
+/** @} */
 
 #else
 
-__BEGIN_DECLS
-int __istype(int, unsigned);
-int __isctype(int, unsigned);
-int __toupper(int);
-int __tolower(int);
-
-__END_DECLS
+/** Non-inlined function versions.
+ * @{
+ */
+__BEGIN_DECLS
+unsigned    __ctype(__ct_rune_t, unsigned);
+int         __istype(__ct_rune_t, unsigned);
+__ct_rune_t __isctype(__ct_rune_t, unsigned);
+__ct_rune_t __toupper(__ct_rune_t);
+int         __tolower(__ct_rune_t);
+
+unsigned    __wctype(__wint_t, unsigned);
+int         __iswtype(__wint_t, unsigned);
+__wint_t     __towupper(__wint_t);
+__wint_t     __towlower(__wint_t);
+int         __wcwidth(__wint_t);
+__END_DECLS
+/** @} */
 
 #endif
Index: trunk/src/emx/include/ctype.h
===================================================================
--- trunk/src/emx/include/ctype.h	(revision 1702)
+++ trunk/src/emx/include/ctype.h	(revision 1705)
@@ -4,5 +4,5 @@
  * InnoTek LIBC - Character type querying.
  *
- * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
+ * Copyright (ch) 2004 knut st. osmundsen <bird@innotek.de>
  *
  *
@@ -53,46 +53,48 @@
 
 #if __BSD_VISIBLE
-/* @todo int	digittoint(int); */
+int	digittoint(int);
 int     isblank(int);
 int	ishexnumber(int);
-/* @todo int	isideogram(int); */
+int	isideogram(int);
 int	isnumber(int);
 /* @todo int	isphonogram(int); */
-/* @todo int	isrune(int); */
+int	isrune(int);
 /* @todo int	isspecial(int); */
 #endif
 __END_DECLS
 
-#define isalnum(c)  __istype((c), (__UPPER)|(__LOWER)|(__DIGIT))
-#define isalpha(c)  __istype((c), (__UPPER)|(__LOWER))
-#define iscntrl(c)  __istype((c), (__CNTRL))
-#define isgraph(c)  __istype((c), (__PUNCT)|(__UPPER)|(__LOWER)|(__DIGIT))
-#define islower(c)  __istype((c), (__LOWER))
-#define isprint(c)  __istype((c), (__PRINT))
-#define ispunct(c)  __istype((c), (__PUNCT))
-#define isspace(c)  __istype((c), (__SPACE))
-#define isupper(c)  __istype((c), (__UPPER))
-#ifdef __UNIX_CHAR_CLASS__
-/* BSD and some other UNIXes have non-standard definitions of these two at least. */
-#define isdigit(c)  __isctype((c),(__DIGIT))
-#define isxdigit(c) __isctype((c),(__XDIGIT))
+#define isalnum(ch)     __istype((ch), (__CT_ALPHA)|(__CT_DIGIT))
+#define isalpha(ch)     __istype((ch), (__CT_ALPHA))
+#define iscntrl(ch)     __istype((ch), (__CT_CNTRL))
+#define isgraph(ch)     __istype((ch), (__CT_GRAPH))
+#define islower(ch)     __istype((ch), (__CT_LOWER))
+#define isprint(ch)     __istype((ch), (__CT_PRINT))
+#define ispunct(ch)     __istype((ch), (__CT_PUNCT))
+#define isspace(ch)     __istype((ch), (__CT_SPACE))
+#define isupper(ch)     __istype((ch), (__CT_UPPER))
+#ifdef __UNIX_CHAR_CLASS__ /* BSD and some other UNIXes have non-standard definitions of these two at least. */
+#define isdigit(ch)     __isctype((ch),(__CT_DIGIT))
+#define isxdigit(ch)    __isctype((ch),(__CT_XDIGIT))
 #else
-#define isdigit(c)  __istype((c),(__DIGIT))
-#define isxdigit(c) __istype((c),(__XDIGIT))
+#define isdigit(ch)     __istype((ch), (__CT_DIGIT))
+#define isxdigit(ch)    __istype((ch), (__CT_XDIGIT))
 #endif
-#define tolower(c)  __tolower(c)
-#define toupper(c)  __toupper(c)
+#define tolower(ch)     __tolower(ch)
+#define toupper(ch)     __toupper(ch)
 
 #if __XSI_VISIBLE
-#define _toupper(c) __toupper(c)
-#define _tolower(c) __tolower(c)
-#define	isascii(c)   (((c) & ~0x7F) == 0)
-#define	toascii(c)   ((c) & 0x7F)
+#define _toupper(ch)    __toupper(ch)
+#define _tolower(ch)    __tolower(ch)
+#define	isascii(ch)     (((ch) & ~0x7F) == 0)
+#define	toascii(ch)     ((ch) & 0x7F)
 #endif
 
 #if __BSD_VISIBLE
-#define isblank(c)      __istype((c), (__BLANK))
-#define ishexnumber(c)  __istype((c), (__XDIGIT))
-#define isnumber(c)     __istype((c), (__DIGIT))
+#define isblank(ch)     __istype((ch), (__CT_BLANK))
+#define ishexnumber(ch) __istype((ch), (__CT_XDIGIT))
+#define isideogram(ch)  __istype((ch), (__CT_IDEOGRAM))
+#define isnumber(ch)    __istype((ch), (__CT_DIGIT))
+#define	isrune(ch)      __istype((ch), ~(__CT_NUM_MASK))
+#define	digittoint(ch)  __ctype((ch), (__CT_NUM_MASK))
 #endif
 
Index: trunk/src/emx/include/langinfo.h
===================================================================
--- trunk/src/emx/include/langinfo.h	(revision 1705)
+++ trunk/src/emx/include/langinfo.h	(revision 1705)
@@ -0,0 +1,101 @@
+/* ulsitem.h,v 1.3 2004/09/14 22:27:36 bird Exp */
+/** @file
+ * IGCC.
+ */
+/*
+ * Based on header written by Andrew Zabolotny <bit@eltech.ru>
+ * See ulsitem.h for further info.
+ */
+
+#ifndef _LANGINFO_H_
+#define	_LANGINFO_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _NL_ITEM_DECLARED
+typedef	__nl_item	nl_item;
+#define	_NL_ITEM_DECLARED
+#endif
+
+/* The following constans are a replica of the ones in ulsitem.h
+   They *must* be defined exactly the same way to keep the compiler quiet. */
+
+#define D_T_FMT		1
+#define D_FMT		2
+#define T_FMT		3
+#define AM_STR		4
+#define PM_STR		5
+
+#define ABDAY_1		6
+#define ABDAY_2		7
+#define ABDAY_3		8
+#define ABDAY_4		9
+#define ABDAY_5		10
+#define ABDAY_6		11
+#define ABDAY_7		12
+
+#define DAY_1		13
+#define DAY_2		14
+#define DAY_3		15
+#define DAY_4		16
+#define DAY_5		17
+#define DAY_6		18
+#define DAY_7		19
+
+#define ABMON_1		20
+#define ABMON_2		21
+#define ABMON_3		22
+#define ABMON_4		23
+#define ABMON_5		24
+#define ABMON_6		25
+#define ABMON_7		26
+#define ABMON_8		27
+#define ABMON_9		28
+#define ABMON_10	29
+#define ABMON_11	30
+#define ABMON_12	31
+
+#define MON_1		32
+#define MON_2		33
+#define MON_3		34
+#define MON_4		35
+#define MON_5		36
+#define MON_6		37
+#define MON_7		38
+#define MON_8		39
+#define MON_9		40
+#define MON_10		41
+#define MON_11		42
+#define MON_12		43
+
+#define RADIXCHAR	44
+#define THOUSEP		45
+#if __BSD_VISIBLE || __XSI_VISIBLE <= 500
+#define YESSTR		46
+#define NOSTR		47
+#endif
+#define CRNCYSTR	48
+#define CODESET		49
+
+/* Additional constants defined in XPG4 */
+
+#define T_FMT_AMPM	55
+#define ERA		56
+#define ERA_D_FMT	57
+#define ERA_D_T_FMT	58
+#define ERA_T_FMT	59
+#define ALT_DIGITS	60
+#define YESEXPR		61
+#define NOEXPR		62
+
+/* LSA feature */
+#define DATESEP		63
+#define TIMESEP		64
+#define LISTSEP		65
+
+__BEGIN_DECLS
+char *nl_langinfo(nl_item);
+__END_DECLS
+
+#endif /* !_LANGINFO_H_ */
Index: trunk/src/emx/include/stdlib.h
===================================================================
--- trunk/src/emx/include/stdlib.h	(revision 1702)
+++ trunk/src/emx/include/stdlib.h	(revision 1705)
@@ -84,6 +84,6 @@
 #define	RAND_MAX	0x7fffffff
 
-extern int _mb_cur_max;                 /* bird: one underscore, not two for us. */
-#define	MB_CUR_MAX	_mb_cur_max     /* bird: one underscore, not two for us. */
+extern int __mb_cur_max;
+#define	MB_CUR_MAX	__mb_cur_max
 
 __BEGIN_DECLS
Index: trunk/src/emx/include/sys/cdefs.h
===================================================================
--- trunk/src/emx/include/sys/cdefs.h	(revision 1702)
+++ trunk/src/emx/include/sys/cdefs.h	(revision 1705)
@@ -31,5 +31,5 @@
  *
  *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/cdefs.h,v 1.81 2004/04/07 04:19:49 imp Exp $
+ * $FreeBSD: src/sys/sys/cdefs.h,v 1.84 2004/08/13 00:53:40 julian Exp $
  */
 
@@ -155,4 +155,5 @@
 #define	__pure2		__attribute__((__const__))
 #define	__unused	__attribute__((__unused__))
+#define	__used		__attribute__((__used__))
 #define	__packed	__attribute__((__packed__))
 #define	__aligned(x)	__attribute__((__aligned__(x)))
@@ -163,8 +164,15 @@
 #define __pure2		__attribute__((__const__))
 #define __unused	__attribute__((__unused__))
+#define __used		__attribute__((__used__))
 #define __packed	__attribute__((__packed__))
 #define __aligned(x)	__attribute__((__aligned__(x)))
 #define __section(x)	__attribute__((__section__(x)))
 #endif
+#endif
+
+#if __GNUC_PREREQ__(2, 96)
+#define	__pure		__attribute__((__pure__))
+#else
+#define	__pure
 #endif
 
@@ -245,4 +253,6 @@
  */
 #define	__offsetof(type, field)	((size_t)(&((type *)0)->field))
+#define	__rangeof(type, start, end) \
+	(__offsetof(type, end) - __offsetof(type, start))
 
 /*
@@ -310,5 +320,5 @@
  * more recent ELF binutils, we use .ident allowing the ID to be stripped.
  * Usage:
- *	__FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.81 2004/04/07 04:19:49 imp Exp $");
+ *	__FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.84 2004/08/13 00:53:40 julian Exp $");
  */
 #ifndef	__FBSDID
Index: trunk/src/emx/include/wchar.h
===================================================================
--- trunk/src/emx/include/wchar.h	(revision 1702)
+++ trunk/src/emx/include/wchar.h	(revision 1705)
@@ -1,5 +1,5 @@
 /** @file
  * FreeBSD 5.3
- * @changed bird: Disabled most of it.
+ * @changed bird: Disabled all stream related and some other stuff we don't do yet.
  */
 /*-
@@ -76,7 +76,5 @@
 #include <sys/_types.h>
 #include <machine/_limits.h>
-#if 0  /* bird */
 #include <_ctype.h>
-#endif /* bird */
 
 #ifndef _MBSTATE_T_DECLARED
@@ -112,44 +110,37 @@
 #endif
 
-#if 0 /* bird */
-struct __sFILE;
-#endif /* bird */
+/** @todo struct __sFILE;  */
 struct tm;
 
 __BEGIN_DECLS
-#if 0 /* bird */
 wint_t	btowc(int);
-wint_t	fgetwc(struct __sFILE *);
-wchar_t	*
-	fgetws(wchar_t * __restrict, int, struct __sFILE * __restrict);
-wint_t	fputwc(wchar_t, struct __sFILE *);
-int	fputws(const wchar_t * __restrict, struct __sFILE * __restrict);
-int	fwide(struct __sFILE *, int);
-int	fwprintf(struct __sFILE * __restrict, const wchar_t * __restrict, ...);
-int	fwscanf(struct __sFILE * __restrict, const wchar_t * __restrict, ...);
-wint_t	getwc(struct __sFILE *);
-wint_t	getwchar(void);
+/** @todo wint_t	fgetwc(struct __sFILE *); */
+/** @todo wchar_t	*
+	fgetws(wchar_t * __restrict, int, struct __sFILE * __restrict); */
+/** @todo wint_t	fputwc(wchar_t, struct __sFILE *); */
+/** @todo int	fputws(const wchar_t * __restrict, struct __sFILE * __restrict); */
+/** @todo int	fwide(struct __sFILE *, int); */
+/** @todo int	fwprintf(struct __sFILE * __restrict, const wchar_t * __restrict, ...); */
+/** @todo int	fwscanf(struct __sFILE * __restrict, const wchar_t * __restrict, ...); */
+/** @todo wint_t	getwc(struct __sFILE *); */
+/** @todo wint_t	getwchar(void); */
 size_t	mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
-#endif /* bird */
 size_t	mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
 	    mbstate_t * __restrict);
-#if 0 /* bird */
 int	mbsinit(const mbstate_t *);
 size_t	mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
 	    mbstate_t * __restrict);
-wint_t	putwc(wchar_t, struct __sFILE *);
-wint_t	putwchar(wchar_t);
-int	swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
-	    ...);
-int	swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
-wint_t	ungetwc(wint_t, struct __sFILE *);
-int	vfwprintf(struct __sFILE * __restrict, const wchar_t * __restrict,
-	    __va_list);
-int	vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
-	    __va_list);
-int	vwprintf(const wchar_t * __restrict, __va_list);
-#endif /* bird */
+/** @todo wint_t	putwc(wchar_t, struct __sFILE *); */
+/** @todo wint_t	putwchar(wchar_t); */
+/** @todo int	swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
+	    ...); */
+/** @todo int	swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); */
+/** @todo wint_t	ungetwc(wint_t, struct __sFILE *); */
+/** @todo int	vfwprintf(struct __sFILE * __restrict, const wchar_t * __restrict,
+	    __va_list); */
+/** @todo int	vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
+	    __va_list); */
+/** @todo int	vwprintf(const wchar_t * __restrict, __va_list); */
 size_t	wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
-#if 0 /* bird */
 wchar_t	*wcscat(wchar_t * __restrict, const wchar_t * __restrict);
 wchar_t	*wcschr(const wchar_t *, wchar_t) __pure;
@@ -185,25 +176,25 @@
 wchar_t	*wmemmove(wchar_t *, const wchar_t *, size_t);
 wchar_t	*wmemset(wchar_t *, wchar_t, size_t);
-int	wprintf(const wchar_t * __restrict, ...);
-int	wscanf(const wchar_t * __restrict, ...);
-
-#ifndef _STDSTREAM_DECLARED
-extern struct __sFILE *__stdinp;
-extern struct __sFILE *__stdoutp;
-extern struct __sFILE *__stderrp;
-#define	_STDSTREAM_DECLARED
-#endif
-
-#define	getwc(fp)	fgetwc(fp)
-#define	getwchar()	fgetwc(__stdinp)
-#define	putwc(wc, fp)	fputwc(wc, fp)
-#define	putwchar(wc)	fputwc(wc, __stdoutp)
+/** @todo int	wprintf(const wchar_t * __restrict, ...); */
+/** @todo int	wscanf(const wchar_t * __restrict, ...); */
+
+/** @todo #ifndef _STDSTREAM_DECLARED */
+/** @todo extern struct __sFILE *__stdinp; */
+/** @todo extern struct __sFILE *__stdoutp; */
+/** @todo extern struct __sFILE *__stderrp; */
+/** @todo #define	_STDSTREAM_DECLARED */
+/** @todo #endif */
+
+/** @todo #define	getwc(fp)	fgetwc(fp) */
+/** @todo #define	getwchar()	fgetwc(__stdinp) */
+/** @todo #define	putwc(wc, fp)	fputwc(wc, fp) */
+/** @todo #define	putwchar(wc)	fputwc(wc, __stdoutp) */
 
 #if __ISO_C_VISIBLE >= 1999
-int	vfwscanf(struct __sFILE * __restrict, const wchar_t * __restrict,
-	    __va_list);
-int	vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
-	    __va_list);
-int	vwscanf(const wchar_t * __restrict, __va_list);
+/** @todo int	vfwscanf(struct __sFILE * __restrict, const wchar_t * __restrict,
+	    __va_list); */
+/** @todo int	vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
+	    __va_list); */
+/** @todo int	vwscanf(const wchar_t * __restrict, __va_list); */
 float	wcstof(const wchar_t * __restrict, wchar_t ** __restrict);
 long double
@@ -226,5 +217,5 @@
 
 #if __BSD_VISIBLE
-wchar_t	*fgetwln(struct __sFILE * __restrict, size_t * __restrict);
+/** @todo wchar_t	*fgetwln(struct __sFILE * __restrict, size_t * __restrict); */
 size_t	mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
 	    size_t, mbstate_t * __restrict);
@@ -234,5 +225,4 @@
 size_t	wcslcpy(wchar_t *, const wchar_t *, size_t);
 #endif
-#endif /* bird */
 __END_DECLS
 
Index: trunk/src/emx/include/wctype.h
===================================================================
--- trunk/src/emx/include/wctype.h	(revision 1702)
+++ trunk/src/emx/include/wctype.h	(revision 1705)
@@ -1,5 +1,7 @@
 /** @file
  * FreeBSD 5.3
- * @changed bird: Disabled most of it.
+ * @changed bird: hid a few bsd things and changed it to __isw* & __tow*.
+ *                No __iscwtype on OS/2 since it's all unicode.
+ * @remark  Take greate care when merging new versions into this file.
  */
 /*-
@@ -63,33 +65,22 @@
 int	iswalnum(wint_t);
 int	iswalpha(wint_t);
-#if 0 /* bird */
 int	iswblank(wint_t);
 int	iswcntrl(wint_t);
-#endif /* bird */
 int	iswctype(wint_t, wctype_t);
-#if 0 /* bird */
 int	iswdigit(wint_t);
 int	iswgraph(wint_t);
-#endif /* bird */
 int	iswlower(wint_t);
-#if 0 /* bird */
 int	iswprint(wint_t);
 int	iswpunct(wint_t);
 int	iswspace(wint_t);
-#endif /* bird */
 int	iswupper(wint_t);
-#if 0 /* bird */
 int	iswxdigit(wint_t);
 wint_t	towctrans(wint_t, wctrans_t);
-#endif /* bird */
 wint_t	towlower(wint_t);
 wint_t	towupper(wint_t);
-#if 0 /* bird */
 wctrans_t
 	wctrans(const char *);
-#endif /* bird */
 wctype_t
 	wctype(const char *);
-#if 0 /* bird */
 
 #if __BSD_VISIBLE
@@ -98,46 +89,37 @@
 wint_t	iswideogram(wint_t);
 wint_t	iswnumber(wint_t);
-wint_t	iswphonogram(wint_t);
+/** @todo wint_t	iswphonogram(wint_t); */
 wint_t	iswrune(wint_t);
-wint_t	iswspecial(wint_t);
-wint_t	nextwctype(wint_t, wctype_t);
+/** @todo wint_t	iswspecial(wint_t); */
+/** @todo wint_t	nextwctype(wint_t, wctype_t); */
 #endif
-#endif /* bird */
 __END_DECLS
 
-#define	iswalnum(wc)		__istype((wc), _CTYPE_A|_CTYPE_D)
-#define	iswalpha(wc)		__istype((wc), _CTYPE_A)
-#if 0 /* bird */
-#define	iswblank(wc)		__istype((wc), _CTYPE_B)
-#define	iswcntrl(wc)		__istype((wc), _CTYPE_C)
-#endif /* bird */
-#define	iswctype(wc, charclass)	__istype((wc), (charclass))
-#if 0 /* bird */
-#define	iswdigit(wc)		__isctype((wc), _CTYPE_D)
-#define	iswgraph(wc)		__istype((wc), _CTYPE_G)
-#endif /* bird */
-#define	iswlower(wc)		__istype((wc), _CTYPE_L)
-#if 0 /* bird */
-#define	iswprint(wc)		__istype((wc), _CTYPE_R)
-#define	iswpunct(wc)		__istype((wc), _CTYPE_P)
-#define	iswspace(wc)		__istype((wc), _CTYPE_S)
-#endif /* bird */
-#define	iswupper(wc)		__istype((wc), _CTYPE_U)
-#if 0 /* bird */
-#define	iswxdigit(wc)		__isctype((wc), _CTYPE_X)
-#endif /* bird */
-#define	towlower(wc)		__tolower(wc)
-#define	towupper(wc)		__toupper(wc)
-#if 0 /* bird */
+#define	iswalnum(wc)		__iswtype((wc), _CTYPE_A|_CTYPE_D)
+#define	iswalpha(wc)		__iswtype((wc), _CTYPE_A)
+#define	iswblank(wc)		__iswtype((wc), _CTYPE_B)
+#define	iswcntrl(wc)		__iswtype((wc), _CTYPE_C)
+#define	iswctype(wc, charclass)	__iswtype((wc), (charclass))
+#define	iswdigit(wc)		__iswtype((wc), _CTYPE_D)
+#define	iswgraph(wc)		__iswtype((wc), _CTYPE_G)
+#define	iswlower(wc)		__iswtype((wc), _CTYPE_L)
+#define	iswprint(wc)		__iswtype((wc), _CTYPE_R)
+#define	iswpunct(wc)		__iswtype((wc), _CTYPE_P)
+#define	iswspace(wc)		__iswtype((wc), _CTYPE_S)
+#define	iswupper(wc)		__iswtype((wc), _CTYPE_U)
+
+#define	iswxdigit(wc)		__iswtype((wc), _CTYPE_X)
+#define	towlower(wc)		__towlower(wc)
+#define	towupper(wc)		__towupper(wc)
 
 #if __BSD_VISIBLE
 #define	iswascii(wc)		(((wc) & ~0x7F) == 0)
-#define	iswhexnumber(wc)	__istype((wc), _CTYPE_X)
-#define	iswideogram(wc)		__istype((wc), _CTYPE_I)
-#define	iswnumber(wc)		__istype((wc), _CTYPE_D)
-#define	iswphonogram(wc)	__istype((wc), _CTYPE_Q)
-#define	iswrune(wc)		__istype((wc), 0xFFFFFF00L)
-#define	iswspecial(wc)		__istype((wc), _CTYPE_T)
+#define	iswhexnumber(wc)	__iswtype((wc), _CTYPE_X)
+#define	iswideogram(wc)		__iswtype((wc), _CTYPE_I)
+#define	iswnumber(wc)		__iswtype((wc), _CTYPE_D)
+/** @todo #define	iswphonogram(wc)	__iswtype((wc), _CTYPE_Q) */
+#define	iswrune(wc)		__iswtype((wc), 0xFFFFFF00L)
+/** @todo #define	iswspecial(wc)		__iswtype((wc), _CTYPE_T) */
 #endif
-#endif /* bird */
+
 #endif		/* _WCTYPE_H_ */
Index: trunk/src/emx/src/lib/bsd/locale/btowc.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/btowc.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/btowc.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/btowc.c,v 1.4 2004/05/12 14:26:54 tjr Exp $");
@@ -33,5 +35,5 @@
 
 wint_t
-btowc(int c)
+_STD(btowc)(int c)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/mblen.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mblen.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mblen.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mblen.c,v 1.9 2004/07/29 06:18:40 tjr Exp $");
@@ -33,5 +35,5 @@
 
 int
-mblen(const char *s, size_t n)
+_STD(mblen)(const char *s, size_t n)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/mblocal.h
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mblocal.h	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mblocal.h	(revision 1705)
@@ -35,4 +35,5 @@
  * Conversion function pointers for current encoding.
  */
+#ifndef __INNOTEK_LIBC__
 extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
     size_t, mbstate_t * __restrict);
@@ -43,4 +44,11 @@
 extern size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
     size_t, size_t, mbstate_t * __restrict);
+#else /* !__INNOTEK_LIBC__ */
+#define __mbrtowc(a,b,c,d)      __libc_GLocaleCtype.CtypeFuncs.pfnmbrtowc(a,b,c,d)
+#define __mbsinit(a)            __libc_GLocaleCtype.CtypeFuncs.pfnmbsinit(a)
+#define __mbsnrtowcs(a,b,c,d,e) __libc_GLocaleCtype.CtypeFuncs.pfnmbsnrtowcs(a,b,c,d,e)
+#define __wcrtomb(a,b,c)        __libc_GLocaleCtype.CtypeFuncs.pfnwcrtomb(a,b,c)
+#define __wcsnrtombs(a,b,c,d,e) __libc_GLocaleCtype.CtypeFuncs.pfnwcsnrtombs(a,b,c,d,e)
+#endif
 
 /*
Index: trunk/src/emx/src/lib/bsd/locale/mbrlen.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbrlen.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbrlen.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbrlen.c,v 1.4 2004/05/12 14:26:54 tjr Exp $");
@@ -32,5 +34,5 @@
 
 size_t
-mbrlen(const char * __restrict s, size_t n, mbstate_t * __restrict ps)
+_STD(mbrlen)(const char * __restrict s, size_t n, mbstate_t * __restrict ps)
 {
 	static mbstate_t mbs;
Index: trunk/src/emx/src/lib/bsd/locale/mbrtowc.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbrtowc.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbrtowc.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbrtowc.c,v 1.7 2004/05/12 14:09:04 tjr Exp $");
@@ -32,5 +34,5 @@
 
 size_t
-mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
+_STD(mbrtowc)(wchar_t * __restrict pwc, const char * __restrict s,
     size_t n, mbstate_t * __restrict ps)
 {
Index: trunk/src/emx/src/lib/bsd/locale/mbsinit.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbsinit.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbsinit.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbsinit.c,v 1.3 2004/05/12 14:09:04 tjr Exp $");
@@ -32,5 +34,5 @@
 
 int
-mbsinit(const mbstate_t *ps)
+_STD(mbsinit)(const mbstate_t *ps)
 {
 
Index: trunk/src/emx/src/lib/bsd/locale/mbsnrtowcs.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbsnrtowcs.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbsnrtowcs.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbsnrtowcs.c,v 1.1 2004/07/21 10:54:57 tjr Exp $");
@@ -35,5 +37,5 @@
 
 size_t
-mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src,
+_STD(mbsnrtowcs)(wchar_t * __restrict dst, const char ** __restrict src,
     size_t nms, size_t len, mbstate_t * __restrict ps)
 {
Index: trunk/src/emx/src/lib/bsd/locale/mbsrtowcs.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbsrtowcs.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbsrtowcs.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbsrtowcs.c,v 1.6 2004/07/21 10:54:57 tjr Exp $");
@@ -35,5 +37,5 @@
 
 size_t
-mbsrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t len,
+_STD(mbsrtowcs)(wchar_t * __restrict dst, const char ** __restrict src, size_t len,
     mbstate_t * __restrict ps)
 {
Index: trunk/src/emx/src/lib/bsd/locale/mbstowcs.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbstowcs.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbstowcs.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbstowcs.c,v 1.11 2004/07/21 10:54:57 tjr Exp $");
@@ -34,5 +36,5 @@
 
 size_t
-mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
+_STD(mbstowcs)(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/mbtowc.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/mbtowc.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/mbtowc.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/mbtowc.c,v 1.11 2004/07/29 06:18:40 tjr Exp $");
@@ -33,5 +35,5 @@
 
 int
-mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
+_STD(mbtowc)(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/utf8.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/utf8.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/utf8.c	(revision 1705)
@@ -25,4 +25,5 @@
  */
 
+#include "namespace.h"
 #include <sys/param.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/utf8.c,v 1.11 2004/07/27 06:29:48 tjr Exp $");
@@ -30,5 +31,9 @@
 #include <errno.h>
 #include <limits.h>
+#ifdef __INNOTEK_LIBC__
+#include <InnotekLIBC/locale.h>
+#else
 #include <runetype.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
@@ -51,4 +56,5 @@
 } _UTF8State;
 
+#ifndef __INNOTEK_LIBC__
 int
 _UTF8_init(_RuneLocale *rl)
@@ -65,4 +71,5 @@
 	return (0);
 }
+#endif /* !__INNOTEK_LIBC__ */
 
 int
@@ -78,6 +85,10 @@
 {
 	_UTF8State *us;
-	int ch, i, mask, want;
+	int ch, i, mask = 0, want;      /* bird: gcc shut */
+#ifdef __INNOTEK_LIBC__
+	wint_t lbound, wch;
+#else
 	wchar_t lbound, wch;
+#endif
 
 	us = (_UTF8State *)ps;
@@ -189,4 +200,8 @@
 		return ((size_t)-1);
 	}
+#ifdef __INNOTEK_LIBC__
+        if (wch > 0xffff || wch < 0)
+            wch = 0xffff;
+#endif
 	if (pwc != NULL)
 		*pwc = wch;
@@ -367,5 +382,5 @@
 	if (dst == NULL) {
 		while (nwc-- > 0) {
-			if (0 <= *s && *s < 0x80)
+			if (/*0 <= *s &&*/ (unsigned)*s < 0x80)
 				/* Fast path for plain ASCII characters. */
 				nb = 1;
@@ -383,5 +398,5 @@
 
 	while (len > 0 && nwc-- > 0) {
-		if (0 <= *s && *s < 0x80) {
+		if (/*0 <= *s &&*/ (unsigned)*s < 0x80) {
 			/* Fast path for plain ASCII characters. */
 			nb = 1;
Index: trunk/src/emx/src/lib/bsd/locale/wcrtomb.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcrtomb.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcrtomb.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcrtomb.c,v 1.8 2004/05/12 14:09:04 tjr Exp $");
@@ -32,5 +34,5 @@
 
 size_t
-wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
+_STD(wcrtomb)(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
 {
 	static mbstate_t mbs;
Index: trunk/src/emx/src/lib/bsd/locale/wcsftime.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcsftime.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcsftime.c	(revision 1705)
@@ -25,4 +25,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcsftime.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
@@ -48,5 +49,5 @@
  */
 size_t
-wcsftime(wchar_t * __restrict wcs, size_t maxsize,
+_STD(wcsftime)(wchar_t * __restrict wcs, size_t maxsize,
     const wchar_t * __restrict format, const struct tm * __restrict timeptr)
 {
Index: trunk/src/emx/src/lib/bsd/locale/wcsnrtombs.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcsnrtombs.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcsnrtombs.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcsnrtombs.c,v 1.2 2004/07/22 02:57:29 tjr Exp $");
@@ -35,5 +37,5 @@
 
 size_t
-wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t nwc,
+_STD(wcsnrtombs)(char * __restrict dst, const wchar_t ** __restrict src, size_t nwc,
     size_t len, mbstate_t * __restrict ps)
 {
Index: trunk/src/emx/src/lib/bsd/locale/wcsrtombs.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcsrtombs.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcsrtombs.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcsrtombs.c,v 1.6 2004/07/21 10:54:57 tjr Exp $");
@@ -35,5 +37,5 @@
 
 size_t
-wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t len,
+_STD(wcsrtombs)(char * __restrict dst, const wchar_t ** __restrict src, size_t len,
     mbstate_t * __restrict ps)
 {
Index: trunk/src/emx/src/lib/bsd/locale/wcstod.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstod.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstod.c	(revision 1705)
@@ -25,4 +25,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstod.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
@@ -42,5 +43,5 @@
  */
 double
-wcstod(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+_STD(wcstod)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/wcstof.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstof.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstof.c	(revision 1705)
@@ -25,4 +25,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstof.c,v 1.3 2004/04/07 09:47:56 tjr Exp $");
@@ -36,5 +37,5 @@
  */
 float
-wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+_STD(wcstof)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/wcstoimax.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstoimax.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstoimax.c	(revision 1705)
@@ -32,4 +32,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 #if 0
@@ -51,5 +52,5 @@
  */
 intmax_t
-wcstoimax(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+_STD(wcstoimax)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
     int base)
 {
@@ -94,5 +95,5 @@
 #ifdef notyet
 		if (iswdigit(c))
-			c = digittoint(c);
+			c = digittoint(c); /* bird: need w version. */
 		else
 #endif
Index: trunk/src/emx/src/lib/bsd/locale/wcstol.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstol.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstol.c	(revision 1705)
@@ -32,4 +32,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstol.c,v 1.1 2002/09/08 13:27:26 tjr Exp $");
@@ -45,5 +46,5 @@
  */
 long
-wcstol(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
+_STD(wcstol)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
 {
 	const wchar_t *s;
@@ -87,5 +88,5 @@
 #ifdef notyet
 		if (iswdigit(c))
-			c = digittoint(c);
+			c = digittoint(c); /* bird: need w version. */
 		else
 #endif
Index: trunk/src/emx/src/lib/bsd/locale/wcstold.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstold.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstold.c	(revision 1705)
@@ -25,4 +25,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstold.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
@@ -36,5 +37,5 @@
  */
 long double
-wcstold(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+_STD(wcstold)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/wcstoll.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstoll.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstoll.c	(revision 1705)
@@ -32,4 +32,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 #if 0
@@ -51,5 +52,5 @@
  */
 long long
-wcstoll(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
+_STD(wcstoll)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
 {
 	const wchar_t *s;
@@ -93,5 +94,5 @@
 #ifdef notyet
 		if (iswdigit(c))
-			c = digittoint(c);
+			c = digittoint(c); /* bird: need w version! */
 		else
 #endif
Index: trunk/src/emx/src/lib/bsd/locale/wcstombs.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstombs.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstombs.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstombs.c,v 1.10 2004/07/21 10:54:57 tjr Exp $");
@@ -34,5 +36,5 @@
 
 size_t
-wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
+_STD(wcstombs)(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/wcstoul.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstoul.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstoul.c	(revision 1705)
@@ -32,4 +32,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstoul.c,v 1.1 2002/09/08 13:27:26 tjr Exp $");
@@ -45,5 +46,5 @@
  */
 unsigned long
-wcstoul(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
+_STD(wcstoul)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
 {
 	const wchar_t *s;
Index: trunk/src/emx/src/lib/bsd/locale/wcstoull.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstoull.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstoull.c	(revision 1705)
@@ -32,4 +32,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 #if 0
@@ -51,5 +52,5 @@
  */
 unsigned long long
-wcstoull(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+_STD(wcstoull)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
     int base)
 {
Index: trunk/src/emx/src/lib/bsd/locale/wcstoumax.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wcstoumax.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wcstoumax.c	(revision 1705)
@@ -32,4 +32,5 @@
  */
 
+#include "namespace.h" /* bird */
 #include <sys/cdefs.h>
 #if 0
@@ -51,5 +52,5 @@
  */
 uintmax_t
-wcstoumax(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+_STD(wcstoumax)(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
     int base)
 {
Index: trunk/src/emx/src/lib/bsd/locale/wctob.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wctob.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wctob.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h"
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wctob.c,v 1.4 2004/05/12 14:26:54 tjr Exp $");
@@ -34,5 +36,5 @@
 
 int
-wctob(wint_t c)
+_STD(wctob)(wint_t c)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/wctomb.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wctomb.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wctomb.c	(revision 1705)
@@ -25,4 +25,6 @@
  */
 
+#include "namespace.h" /* bird */
+#include <InnoTekLIBC/locale.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wctomb.c,v 1.8 2004/07/29 06:18:40 tjr Exp $");
@@ -33,5 +35,5 @@
 
 int
-wctomb(char *s, wchar_t wchar)
+_STD(wctomb)(char *s, wchar_t wchar)
 {
 	static const mbstate_t initial;
Index: trunk/src/emx/src/lib/bsd/locale/wctrans.c
===================================================================
--- trunk/src/emx/src/lib/bsd/locale/wctrans.c	(revision 1702)
+++ trunk/src/emx/src/lib/bsd/locale/wctrans.c	(revision 1705)
@@ -25,4 +25,5 @@
  */
 
+#include "namespace.h"
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wctrans.c,v 1.3 2003/11/01 08:20:58 tjr Exp $");
@@ -39,5 +40,5 @@
 
 wint_t
-towctrans(wint_t wc, wctrans_t desc)
+_STD(towctrans)(wint_t wc, wctrans_t desc)
 {
 
@@ -59,5 +60,5 @@
 
 wctrans_t
-wctrans(const char *charclass)
+_STD(wctrans)(const char *charclass)
 {
 	struct {
Index: trunk/src/emx/src/lib/libc.def
===================================================================
--- trunk/src/emx/src/lib/libc.def	(revision 1702)
+++ trunk/src/emx/src/lib/libc.def	(revision 1705)
@@ -40,5 +40,5 @@
     "__emx_optswchar" @18
     "__fmode_bin" @19
-    "__mb_cur_max" @20
+    "___mb_cur_max" @20
     "__org_environ" @21
     "__osmajor" @22
@@ -71,4 +71,6 @@
     "_optreset" @49
     "_pwdb_versions" @50
+    "___libc_GLocaleWCtype" @51
+    "__std_suboptarg" @52
 
 
@@ -1279,5 +1281,5 @@
     "__std_getsubopt" @1296
     "__std_rand_r" @1297
-    "__std_suboptarg" @1298
+    "___wcwidth" @1298
     "__std_llabs" @1299
     "__std_lldiv" @1300
@@ -1286,2 +1288,68 @@
     "__std_pread" @1303
     "__std_pwrite" @1304
+    "__UTF8_mbrtowc" @1305
+    "__UTF8_mbsinit" @1306
+    "__UTF8_mbsnrtowcs" @1307
+    "__UTF8_wcrtomb" @1308
+    "__UTF8_wcsnrtombs" @1309
+    "___ctype" @1310
+    "_digittoint" @1311
+    "_isideogram" @1312
+    "_isrune" @1313
+    "_iswalnum" @1314
+    "_iswalpha" @1315
+    "_iswascii" @1316
+    "_iswblank" @1317
+    "_iswcntrl" @1318
+    "_iswctype" @1319
+    "_iswdigit" @1320
+    "_iswgraph" @1321
+    "_iswhexnumber" @1322
+    "_iswideogram" @1323
+    "_iswlower" @1324
+    "_iswnumber" @1325
+    "_iswprint" @1326
+    "_iswpunct" @1327
+    "_iswrune" @1328
+    "_iswspace" @1329
+    "___iswtype" @1330
+    "_iswupper" @1331
+    "_iswxdigit" @1332
+    "___mbsnrtowcs_std" @1333
+    "__std_btowc" @1334
+    "__std_mbrlen" @1335
+    "__std_mbrtowc" @1336
+    "__std_mbsinit" @1337
+    "__std_mbsnrtowcs" @1338
+    "__std_mbsrtowcs" @1339
+    "__std_nl_langinfo" @1340
+    "__std_towctrans" @1341
+    "__std_wcrtomb" @1342
+    "__std_wcsftime" @1343
+    "__std_wcsnrtombs" @1344
+    "__std_wcsrtombs" @1345
+    "__std_wcstod" @1346
+    "__std_wcstof" @1347
+    "__std_wcstoimax" @1348
+    "__std_wcstol" @1349
+    "__std_wcstold" @1350
+    "__std_wcstoll" @1351
+    "__std_wcstoul" @1352
+    "__std_wcstoull" @1353
+    "__std_wcstoumax" @1354
+    "__std_wctob" @1355
+    "__std_wctrans" @1356
+    "__std_wctype" @1357
+    "__tolower" @1358
+    "__toupper" @1359
+    "_towlower" @1360
+    "___towlower" @1361
+    "____towlower" @1362
+    "_towupper" @1363
+    "___towupper" @1364
+    "____towupper" @1365
+    "___wcsnrtombs_std" @1366
+    "___wctype" @1367
+    "____wctype" @1368
+    "main" @1369
+    "_main" @1370
Index: trunk/src/emx/src/lib/locale/isxxx.c
===================================================================
--- trunk/src/emx/src/lib/locale/isxxx.c	(revision 1702)
+++ trunk/src/emx/src/lib/locale/isxxx.c	(revision 1705)
@@ -2,12 +2,7 @@
 /** @file
  *
- * ctype functions.
+ * ctype and wctype simple query functions.
  *
- * Usually these routines are not needed (they are inline), but
- * for cases when a program instead of including ctype.h blindly
- * declares them with "extern", they will be linked in.
- *
- * Copyright (c) 2003 InnoTek Systemberatung GmbH
- * Copyright (c) 2003-2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
  *
  *
@@ -30,70 +25,103 @@
  */
 
+#include "libc-alias.h"
+#include <sys/cdefs.h>
 #define _DONT_USE_CTYPE_INLINE_
-#include "libc-alias.h"
 #include <ctype.h>
+#include <wctype.h>
 
-#undef isalnum
-int isalnum(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__UPPER|__LOWER|__DIGIT); }
+int     (isalnum)(int ch)       { return isalnum(ch); }
+int     (isalpha)(int ch)       { return isalpha(ch); }
+int     (iscntrl)(int ch)       { return iscntrl(ch); }
+int     (isdigit)(int ch)       { return isdigit(ch); }
+int     (isgraph)(int ch)       { return isgraph(ch); }
+int     (islower)(int ch)       { return islower(ch); }
+int     (isprint)(int ch)       { return isprint(ch); }
+int     (ispunct)(int ch)       { return ispunct(ch); }
+int     (isspace)(int ch)       { return isspace(ch); }
+int     (isupper)(int ch)       { return isupper(ch); }
+int     (isxdigit)(int ch)      { return isxdigit(ch); }
+int     (toupper)(int ch)       { return toupper(ch); }
+int     (tolower)(int ch)       { return tolower(ch); }
+int     (_toupper)(int ch)      { return _toupper(ch); }
+int     (_tolower)(int ch)      { return _toupper(ch); }
+int     (isascii)(int ch)       { return isascii(ch); }
+int     (toascii)(int ch)       { return isascii(ch); }
+int	(digittoint)(int ch)    { return digittoint(ch); }
+int     (isblank)(int ch)       { return isblank(ch); }
+int	(ishexnumber)(int ch)   { return ishexnumber(ch); }
+int	(isideogram)(int ch)    { return isideogram(ch); }
+int	(isnumber)(int ch)      { return isnumber(ch); }
+int	(isrune)(int ch)        { return isrune(ch); }
 
-#undef isalpha
-int isalpha(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__UPPER|__LOWER); }
+#if !defined(isalnum) \
+ || !defined(isalpha) \
+ || !defined(iscntrl) \
+ || !defined(isdigit) \
+ || !defined(isgraph) \
+ || !defined(islower) \
+ || !defined(isprint) \
+ || !defined(ispunct) \
+ || !defined(isspace) \
+ || !defined(isupper) \
+ || !defined(isxdigit) \
+ || !defined(toupper) \
+ || !defined(tolower) \
+ || !defined(_toupper) \
+ || !defined(_tolower) \
+ || !defined(isascii) \
+ || !defined(toascii) \
+ || !defined(digittoint) \
+ || !defined(isblank) \
+ || !defined(ishexnumber) \
+ || !defined(isideogram) \
+ || !defined(isnumber) \
+ || !defined(isrune)
+#error "One or more of the ctype.h macros are undefined!"
+#endif
 
-#undef iscntrl
-int iscntrl(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__CNTRL); }
 
-#undef isdigit
-int isdigit(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__DIGIT); }
+int	(iswalnum)(int wc)       { return iswalnum(wc); }
+int	(iswalpha)(int wc)       { return iswalpha(wc); }
+int	(iswblank)(int wc)       { return iswblank(wc); }
+int	(iswcntrl)(int wc)       { return iswcntrl(wc); }
+int	(iswctype)(wint_t wc, wctype_t wctype)    { return iswctype(wc, wctype); }
+int	(iswdigit)(int wc)       { return iswdigit(wc); }
+int	(iswgraph)(int wc)       { return iswgraph(wc); }
+int	(iswlower)(int wc)       { return iswlower(wc); }
+int	(iswprint)(int wc)       { return iswprint(wc); }
+int	(iswpunct)(int wc)       { return iswpunct(wc); }
+int	(iswspace)(int wc)       { return iswspace(wc); }
+int	(iswupper)(int wc)       { return iswupper(wc); }
+int	(iswxdigit)(int wc)      { return iswxdigit(wc); }
+wint_t	(towlower)(int wc)       { return towlower(wc); }
+wint_t	(towupper)(int wc)       { return towupper(wc); }
+wint_t	(iswascii)(int wc)       { return iswascii(wc); }
+wint_t	(iswhexnumber)(int wc)   { return iswhexnumber(wc); }
+wint_t	(iswideogram)(int wc)    { return iswideogram(wc); }
+wint_t	(iswnumber)(int wc)      { return iswnumber(wc); }
+wint_t	(iswrune)(int wc)        { return iswrune(wc); }
 
-#undef isgraph
-int isgraph(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__PUNCT|__UPPER|__LOWER|__DIGIT); }
+#if !defined(iswalnum) \
+ || !defined(iswalpha) \
+ || !defined(iswblank) \
+ || !defined(iswcntrl) \
+ || !defined(iswctype) \
+ || !defined(iswdigit) \
+ || !defined(iswgraph) \
+ || !defined(iswlower) \
+ || !defined(iswprint) \
+ || !defined(iswpunct) \
+ || !defined(iswspace) \
+ || !defined(iswupper) \
+ || !defined(iswxdigit) \
+ || !defined(towlower) \
+ || !defined(towupper) \
+ || !defined(iswascii) \
+ || !defined(iswhexnumber) \
+ || !defined(iswideogram) \
+ || !defined(iswnumber) \
+ || !defined(iswrune)
+#error "One or more of the wctype.h macros are undefined!"
+#endif
 
-#undef islower
-int islower(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__LOWER); }
-
-#undef isprint
-int isprint(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__PRINT); }
-
-#undef ispunct
-int ispunct(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__PUNCT); }
-
-#undef isspace
-int isspace(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__SPACE); }
-
-#undef isupper
-int isupper(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__UPPER); }
-
-#undef isxdigit
-int isxdigit(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__XDIGIT); }
-
-#undef isblank
-int isblank(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__BLANK); }
-
-#undef ishexnumber
-int ishexnumber(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__XDIGIT); }
-
-#undef isnumber
-int isnumber(int _c)
-{ return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__DIGIT); }
-
-#undef toascii
-int toascii(int _c)
-{ return _c & 0x7f; }
-
-#undef isascii
-int isascii(int _c)
-{ return (_c & 0x80) != 0; }
-
Index: trunk/src/emx/src/lib/locale/locale_ctype.c
===================================================================
--- trunk/src/emx/src/lib/locale/locale_ctype.c	(revision 1702)
+++ trunk/src/emx/src/lib/locale/locale_ctype.c	(revision 1705)
@@ -28,9 +28,11 @@
 #define _DONT_USE_CTYPE_INLINE_
 #include "libc-alias.h"
+#define INCL_FSMACROS
+#include <os2emx.h>
 #include <InnoTekLIBC/locale.h>
 #include <ctype.h>
 
 
-/* Character case conversion tables. */
+/** Character case conversion tables. */
 __LIBC_LOCALECTYPE       __libc_GLocaleCtype =
 {
@@ -51,6 +53,6 @@
         0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
         0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
-        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
-        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff,
     },
     .auchLower =
@@ -68,27 +70,27 @@
         0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
         0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
-        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf,
         0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
     },
-    .ausfType =
-    {
-        0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020,
-        0x8020, 0x8068, 0x8028, 0x8028, 0x8028, 0x8028, 0x8020, 0x8020,
-        0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020,
-        0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020,
-        0x8848, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10,
-        0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10, 0x8c10,
-        0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84,
-        0x9e84, 0x9e84, 0x8c10, 0x8c10, 0xac10, 0xac10, 0xac10, 0x8c10,
-        0x8c10, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f01,
-        0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01,
-        0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01,
-        0x8f01, 0x8f01, 0x8f01, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10,
-        0xac10, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f02,
-        0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02,
-        0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02,
-        0x8f02, 0x8f02, 0x8f02, 0x8c10, 0xac10, 0x8c10, 0xac10, 0x8020,
+    .aufType =
+    {
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00806800, 0x00802800, 0x00802800, 0x00802800, 0x00802800, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00884800, 0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000, 0x008c1000, 0x008c1000,
+        0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000, 0x008c1000, 0x008c1000, 0x008c1000,
+        0x009e8400, 0x009e8401, 0x009e8402, 0x009e8403, 0x009e8404, 0x009e8405, 0x009e8406, 0x009e8407,
+        0x009e8408, 0x009e8409, 0x008c1000, 0x008c1000, 0x00ac1000, 0x00ac1000, 0x00ac1000, 0x008c1000,
+        0x008c1000, 0x008f810a, 0x008f810b, 0x008f810c, 0x008f810d, 0x008f810e, 0x008f810f, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000,
+        0x00ac1000, 0x008f820a, 0x008f820b, 0x008f820c, 0x008f820d, 0x008f820e, 0x008f820f, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008c1000, 0x00ac1000, 0x008c1000, 0x00ac1000, 0x00802000,
     },
     .au2MBCSPrefixs =
@@ -99,4 +101,115 @@
         0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
     },
+    .aucUnicode =
+    {
+        0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+        0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+        0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+        0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+        0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+        0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+        0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+        0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+        0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+        0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
+        0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+        0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+        0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+        0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+        0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+        0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
+        0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+        0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+        0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+        0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+        0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+        0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+        0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+        0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+        0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+        0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+        0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+        0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
+        0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+        0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+        0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+        0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
+    },
+    .auchToSBCS0To128 =
+    {
+        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+        0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    },
+
+    .aSBCSs[0] =
+    {
+        .usStart = 0x0080,
+        .cChars = 28,
+        .auch =
+        {
+
+        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
+        }
+    },
+    .aSBCSs[1] =
+    {
+        .usStart = 0x009c,
+        .cChars = 28,
+        .auch =
+        {
+
+        0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab,
+        0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+        }
+    },
+    .aSBCSs[2] =
+    {
+        .usStart = 0x00b8,
+        .cChars = 28,
+        .auch =
+        {
+
+        0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+        0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3,
+        }
+    },
+    .aSBCSs[3] =
+    {
+        .usStart = 0x00d4,
+        .cChars = 28,
+        .auch =
+        {
+
+        0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
+        0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        }
+    },
+    .aSBCSs[4] =
+    {
+        .usStart = 0x00f0,
+        .cChars = 16,
+        .auch =
+        {
+
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        }
+    },
+    .cSBCSs = 5,
+    .CtypeFuncs =
+    {
+        .pfnmbsinit    = __libc_locale_none_mbsinit,
+        .pfnmbrtowc    = __libc_locale_none_mbrtowc,
+        .pfnmbsnrtowcs = __libc_locale_none_mbsnrtowcs,
+        .pfnwcrtomb    = __libc_locale_none_wcrtomb,
+        .pfnwcsnrtombs = __libc_locale_none_wcsnrtombs,
+    },
     .uobj = 0,
     .lobj = 0,
@@ -105,47 +218,267 @@
 
 
-
-#undef tolower
-int tolower(int _c)
-{
-    return __libc_GLocaleCtype.auchLower[_c & 0xff];
-}
-#undef __tolower
-int __tolower(int _c)
-{
-    return __libc_GLocaleCtype.auchLower[_c & 0xff];
-}
-
-#undef toupper
-int toupper(int _c)
-{
-    return __libc_GLocaleCtype.auchUpper[_c & 0xff];
-}
-#undef __toupper
-int __toupper(int _c)
-{
-    return __libc_GLocaleCtype.auchUpper[_c & 0xff];
-}
-
-#undef __istype
-int __istype(int _c, unsigned _f)
-{
-    return (__libc_GLocaleCtype.ausfType[_c & 0xff] & (_f)) != 0;
-}
-
-
-
-
-
-#if 0 /* code for regenerating that table - link staticly! */
+unsigned __ctype(__ct_rune_t __ch, unsigned __f)
+{
+    return !((__ch) & ~0xffU)
+        ? __libc_GLocaleCtype.aufType[(__ch)/* & 0xff*/] & (__f)
+        : 0;
+}
+
+int __istype(__ct_rune_t __ch, unsigned __f)
+{
+    return !!__ctype((__ch), (__f));
+}
+
+__ct_rune_t __toupper(__ct_rune_t __ch)
+{
+    return !((__ch) & ~0xffU)
+        ? __libc_GLocaleCtype.auchUpper[(__ch)/* & 0xff*/]
+        : (__ch);
+}
+
+__ct_rune_t __tolower(__ct_rune_t __ch)
+{
+    return !((__ch) & ~0xffU)
+        ? __libc_GLocaleCtype.auchLower[(__ch)/* & 0xff*/]
+        : (__ch);
+}
+
+
+
+/** Cached Unicode (__wchar_t) case conversion tables and flags. */
+const __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype =
+{
+    .awcUpper =
+    {
+
+        0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+        0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+        0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+        0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+        0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+        0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+        0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+        0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+        0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+        0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+        0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+        0x0078, 0x0079, 0x007a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+        0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+        0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+        0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+        0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
+        0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+        0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+        0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+        0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+        0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+        0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+        0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+        0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+        0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+        0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+        0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00d7,
+        0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00df,
+        0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+        0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+        0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+        0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
+    },
+    .awcUpper =
+    {
+
+        0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+        0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+        0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+        0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+        0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+        0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+        0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+        0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+        0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+        0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
+        0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+        0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+        0x0060, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+        0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
+        0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+        0x0058, 0x0059, 0x005a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
+        0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+        0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+        0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+        0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+        0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+        0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+        0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+        0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+        0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+        0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+        0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+        0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
+        0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+        0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+        0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00f7,
+        0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x0178,
+    },
+    .aufType =
+    {
+
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00806800, 0x00802800, 0x00802800, 0x00802800, 0x00802800, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00884800, 0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000, 0x008c1000, 0x008c1000,
+        0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000, 0x008c1000, 0x008c1000, 0x008c1000,
+        0x009e8400, 0x009e8401, 0x009e8402, 0x009e8403, 0x009e8404, 0x009e8405, 0x009e8406, 0x009e8407,
+        0x009e8408, 0x009e8409, 0x008c1000, 0x008c1000, 0x00ac1000, 0x00ac1000, 0x00ac1000, 0x008c1000,
+        0x008c1000, 0x008f810a, 0x008f810b, 0x008f810c, 0x008f810d, 0x008f810e, 0x008f810f, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000,
+        0x00ac1000, 0x008f820a, 0x008f820b, 0x008f820c, 0x008f820d, 0x008f820e, 0x008f820f, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008c1000, 0x00ac1000, 0x008c1000, 0x00ac1000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x002c1000, 0x000c1000, 0x002c1000, 0x002c1000, 0x002c1000, 0x002c1000, 0x002c1000, 0x002c1000,
+        0x002c1000, 0x002c1000, 0x000f0200, 0x000c1000, 0x002c1000, 0x000c1000, 0x002c1000, 0x002c1000,
+        0x002c1000, 0x002c1000, 0x002c1000, 0x002c1000, 0x002c1000, 0x000f0200, 0x002c1000, 0x000c1000,
+        0x002c1000, 0x002c1000, 0x000f0200, 0x000c1000, 0x002c1000, 0x002c1000, 0x002c1000, 0x000c1000,
+        0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100,
+        0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100,
+        0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x002c1000,
+        0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0100, 0x000f0200,
+        0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200,
+        0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200,
+        0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x002c1000,
+        0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200,
+    },
+};
+
+
+
+unsigned __wctype(__wint_t __wc, unsigned __f)
+{
+    return !((__wc) & ~0xffU)
+        ? __libc_GLocaleWCtype.aufType[(__wc)] & (__f)
+        : ___wctype(__wc) & (__f);
+}
+
+int __iswtype(__wint_t __wc, unsigned __f)
+{
+    return !!__wctype((__wc), (__f));
+}
+
+__wint_t __towupper(__wint_t __wc)
+{
+    return !((__wc) & ~0xffU)
+        ? __libc_GLocaleWCtype.awcUpper[(__wc)]
+        : ___towupper(__wc);
+}
+
+__wint_t __towlower(__wint_t __wc)
+{
+    return !((__wc) & ~0xffU)
+        ? __libc_GLocaleWCtype.awcLower[(__wc)]
+        : ___towlower(__wc);
+}
+
+
+int __wcwidth(__wint_t __wc)
+{
+    if ((__wc) != 0)
+    {
+        unsigned __f = __wctype((__wc), __CT_SCRW_MASK | __CT_PRINT);
+        return ((__f) & __CT_SCRW_MASK)
+            ? ((__f) & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
+            : ((__f) & __CT_PRINT) ? 1 : -1;
+    }
+    else
+        return 0;
+}
+
+
+/**
+ * Get unicode type.
+ * ASSUMES that none of the locals differs from the unicode spec
+ */
+unsigned ___wctype(__wchar_t uc)
+{
+    unsigned    ufType = 0;
+    UNICTYPE   *pUniType = UniQueryCharType(uc);
+    if (pUniType)
+    {
+        /* ASSUMES CT_* << 8 == __* ! */
+        ufType = ((unsigned)pUniType->itype << 8)
+               & (__CT_UPPER  | __CT_LOWER  | __CT_DIGIT | __CT_SPACE |
+                  __CT_PUNCT  | __CT_CNTRL  | __CT_BLANK | __CT_XDIGIT |
+                  __CT_ALPHA  | __CT_ALNUM  | __CT_GRAPH | __CT_PRINT |
+                  __CT_NUMBER | __CT_SYMBOL | __CT_ASCII);
+        if (pUniType->extend & C3_IDEOGRAPH)
+            ufType |= __CT_IDEOGRAM;
+        if (ufType & (__CT_XDIGIT | __CT_DIGIT))
+        {
+            if (     (unsigned)uc - 0x30U <= (0x39 - 0x30))
+                ufType |= (unsigned)uc - 0x30;
+            else if ((unsigned)uc - 0x41U <= (0x46 - 0x41))
+                ufType |= (unsigned)uc - 0x41 + 0xa;
+            else
+            {
+                unsigned uVal = UniQueryNumericValue(uc);
+                if (!(uVal & ~0xffU))
+                    ufType |= uVal;
+            }
+        }
+        ufType |= (pUniType->bidi & 0xf << 24);
+
+        /** @todo screen width. */
+    }
+    return ufType;
+}
+
+/**
+ * Fold char to lowercase.
+ * ASSUMES that none of the locals differs from the unicode spec.
+ */
+__wchar_t ___towlower(__wchar_t wc)
+{
+    FS_VAR_SAVE_LOAD();
+    UniChar ucRet = UniTolower(wc);
+    FS_RESTORE();
+    return ucRet;
+}
+
+/**
+ * Fold char to lowercase.
+ * ASSUMES that none of the locals differs from the unicode spec.
+ */
+__wchar_t ___towupper(__wchar_t wc)
+{
+    FS_VAR_SAVE_LOAD();
+    UniChar ucRet = UniToupper(wc);
+    FS_RESTORE();
+    return ucRet;
+}
+
+
+
+#if 1 /* code for regenerating that table - link staticly! */
 
 #include <InnoTekLIBC/locale.h>
 #include <stdio.h>
 
-int main()
+int main(int argc, char **argv)
 {
     int i;
-    setlocale(LC_CTYPE, "en_US");
-    setlocale(LC_CTYPE, "C");
+    const int iMax = argc != 2 ? 128 : 256;
+    if (!setlocale(LC_CTYPE, argc == 2 ? argv[1] : "en_US")) /* We use this because the "C" depends on the generated data! */
+    {
+        printf("setlocale failed!\n");
+        return 1;
+    }
+
     printf("{\n"
            "    .auchUpper =\n"
@@ -171,15 +504,17 @@
     printf("\n"
            "    },\n"
-           "    .ausfType = \n"
+           "    .aufType = \n"
            "    {");
-    for (i = 0; i < 128; i++)
+    for (i = 0; i < iMax; i++)
     {
         if (i % 8)
-            printf("0x%04x, ", (int)__libc_GLocaleCtype.ausfType[i]);
-        else
-            printf("\n        0x%04x, ", (int)__libc_GLocaleCtype.ausfType[i]);
-    }
-    printf("\n"
-           "    },\n"
+            printf("0x%08x, ", (int)__libc_GLocaleCtype.aufType[i]);
+        else
+            printf("\n        0x%08x, ", (int)__libc_GLocaleCtype.aufType[i]);
+    }
+    printf("\n");
+
+    /* prefixed */
+    printf("    },\n"
            "    .au2MBCSPrefixs =\n"
            "    {");
@@ -189,14 +524,132 @@
             printf("0x%02x, ", (int)__libc_GLocaleCtype.au2MBCSPrefixs[i]);
         else
-            printf("\n    0x%02x, ", (int)__libc_GLocaleCtype.au2MBCSPrefixs[i]);
-    }
-    printf("\n"
-           "    },\n"
-           "    .uobj = 0,\n"
+            printf("\n        0x%02x, ", (int)__libc_GLocaleCtype.au2MBCSPrefixs[i]);
+    }
+    printf("\n"
+           "    },\n");
+
+    /* -> unicode translation */
+    printf("    .aucUnicode =\n"
+           "    {");
+    for (i = 0; i < sizeof(__libc_GLocaleCtype.aucUnicode) / sizeof(__libc_GLocaleCtype.aucUnicode[0]); i++)
+    {
+        if (i % 8)
+            printf("0x%04x, ", (int)__libc_GLocaleCtype.aucUnicode[i]);
+        else
+            printf("\n        0x%04x, ", (int)__libc_GLocaleCtype.aucUnicode[i]);
+    }
+    printf("\n"
+           "    },\n");
+
+    /* <- unicode translation */
+    printf("    .auchToSBCS0To128 =\n"
+           "    {");
+    for (i = 0; i < sizeof(__libc_GLocaleCtype.auchToSBCS0To128) / sizeof(__libc_GLocaleCtype.auchToSBCS0To128[0]); i++)
+    {
+        if (i % 16)
+            printf("0x%02x, ", (int)__libc_GLocaleCtype.auchToSBCS0To128[i]);
+        else
+            printf("\n        0x%02x, ", (int)__libc_GLocaleCtype.auchToSBCS0To128[i]);
+    }
+    printf("\n"
+           "    },\n");
+
+    printf("    .cSBCSs = %d,\n", __libc_GLocaleCtype.cSBCSs);
+    int j;
+    for (j = 0; j < __libc_GLocaleCtype.cSBCSs; j++)
+    {
+        printf("    .aSBCSs[%d] =\n"
+               "    {\n"
+               "        .usStart = 0x%04x,\n"
+               "        .cChars = %d,\n"
+               "        .auch =\n"
+               "        {\n",
+               j,
+               __libc_GLocaleCtype.aSBCSs[j].usStart,
+               __libc_GLocaleCtype.aSBCSs[j].cChars);
+        for (i = 0; i < sizeof(__libc_GLocaleCtype.aSBCSs[j].auch) / sizeof(__libc_GLocaleCtype.aSBCSs[j].auch[0]); i++)
+        {
+            if (i % 16)
+                printf("0x%02x, ", (int)__libc_GLocaleCtype.aSBCSs[j].auch[i]);
+            else
+                printf("\n        0x%02x, ", (int)__libc_GLocaleCtype.aSBCSs[j].auch[i]);
+        }
+        printf("\n"
+               "        }\n"
+               "    },\n");
+    }
+
+    /* the functions. */
+    printf("    .CtypeFuncs =\n"
+           "    {\n"
+           "        .pfnmbsinit    =  __libc_locale_none_mbsinit,\n"
+           "        .pfnmbrtowc    =  __libc_locale_none_mbrtowc,\n"
+           "        .pfnmbsnrtowcs =  __libc_locale_none_mbsnrtowcs,\n"
+           "        .pfnwcrtomb    =  __libc_locale_none_wcrtomb,\n"
+           "        .pfnwcsnrtombs =  __libc_locale_none_wcsnrtombs\n"
+           "    },\n");
+
+
+    /* the rest */
+    printf("    .uobj = 0,\n"
            "    .lobj = 0,\n"
            "    .mbcs = %d\n"
-           "};\n",
+           "};\n"
+           "\n"
+           "\n"
+           "\n",
            (int)__libc_GLocaleCtype.mbcs);
 
+
+    /*
+     * The unicode table.
+     */
+    printf("{\n");
+
+    /* Lower */
+    printf("    .awcUpper =\n"
+           "    {\n");
+    for (i = 0; i < sizeof(__libc_GLocaleWCtype.awcLower) / sizeof(__libc_GLocaleWCtype.awcLower[0]); i++)
+    {
+        wchar_t wc = ___towlower(i);
+        if (i % 8)
+            printf("0x%04x, ", (int)wc);
+        else
+            printf("\n        0x%04x, ", (int)wc);
+    }
+    printf("\n"
+           "    },\n");
+
+    /* Upper */
+    printf("    .awcUpper =\n"
+           "    {\n");
+    for (i = 0; i < sizeof(__libc_GLocaleWCtype.awcUpper) / sizeof(__libc_GLocaleWCtype.awcUpper[0]); i++)
+    {
+        wchar_t wc = ___towupper(i);
+        if (i % 8)
+            printf("0x%04x, ", (int)wc);
+        else
+            printf("\n        0x%04x, ", (int)wc);
+    }
+    printf("\n"
+           "    },\n");
+
+    /* Type */
+    printf("    .aufType =\n"
+           "    {\n");
+    for (i = 0; i < sizeof(__libc_GLocaleWCtype.aufType) / sizeof(__libc_GLocaleWCtype.aufType[0]); i++)
+    {
+        unsigned ufType = ___wctype(i);
+        if (i % 8)
+            printf("0x%08x, ", ufType);
+        else
+            printf("\n        0x%08x, ", ufType);
+    }
+    printf("\n"
+           "    },\n");
+
+    /* done */
+    printf("};\n");
+
     return 0;
 }
Index: trunk/src/emx/src/lib/locale/locale_ctype_default.c
===================================================================
--- trunk/src/emx/src/lib/locale/locale_ctype_default.c	(revision 1702)
+++ trunk/src/emx/src/lib/locale/locale_ctype_default.c	(revision 1705)
@@ -31,31 +31,192 @@
 
 
-/* Character case conversion tables for the default 'C'/'POSIX' locale. */
-const __LIBC_LOCALECTYPEDEFAULT __libc_GLocaleCtypeDefault =
+/** Character case conversion tables for the default 'C'/'POSIX' locale. */
+const __LIBC_LOCALECTYPE     __libc_GLocaleCtypeDefault =
 {
-    .ausfType =
-    {
-        0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020,
-        0x8020, 0x8068, 0x8028, 0x8028, 0x8028, 0x8028, 0x8020, 0x8020,
-        0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020,
-        0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020,
-        0x8848, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10,
-        0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10, 0x8c10,
-        0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84,
-        0x9e84, 0x9e84, 0x8c10, 0x8c10, 0xac10, 0xac10, 0xac10, 0x8c10,
-        0x8c10, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f01,
-        0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01,
-        0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01,
-        0x8f01, 0x8f01, 0x8f01, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10,
-        0xac10, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f02,
-        0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02,
-        0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02,
-        0x8f02, 0x8f02, 0x8f02, 0x8c10, 0xac10, 0x8c10, 0xac10, 0x8020,
-    }
+    .auchUpper =
+    {
+        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+        0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+        0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+        0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+        0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff,
+    },
+    .auchLower =
+    {
+        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+        0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+        0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+        0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf,
+        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+    },
+    .aufType =
+    {
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00806800, 0x00802800, 0x00802800, 0x00802800, 0x00802800, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000, 0x00802000,
+        0x00884800, 0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000, 0x008c1000, 0x008c1000,
+        0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000, 0x008c1000, 0x008c1000, 0x008c1000,
+        0x009e8400, 0x009e8401, 0x009e8402, 0x009e8403, 0x009e8404, 0x009e8405, 0x009e8406, 0x009e8407,
+        0x009e8408, 0x009e8409, 0x008c1000, 0x008c1000, 0x00ac1000, 0x00ac1000, 0x00ac1000, 0x008c1000,
+        0x008c1000, 0x008f810a, 0x008f810b, 0x008f810c, 0x008f810d, 0x008f810e, 0x008f810f, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100, 0x008f0100,
+        0x008f0100, 0x008f0100, 0x008f0100, 0x008c1000, 0x008c1000, 0x008c1000, 0x00ac1000, 0x008c1000,
+        0x00ac1000, 0x008f820a, 0x008f820b, 0x008f820c, 0x008f820d, 0x008f820e, 0x008f820f, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200, 0x008f0200,
+        0x008f0200, 0x008f0200, 0x008f0200, 0x008c1000, 0x00ac1000, 0x008c1000, 0x00ac1000, 0x00802000,
+    },
+    .au2MBCSPrefixs =
+    {
+        0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+        0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+        0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+        0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+    },
+    .aucUnicode =
+    {
+        0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+        0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+        0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+        0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+        0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+        0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+        0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+        0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+        0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+        0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
+        0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+        0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+        0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+        0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+        0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+        0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
+        0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+        0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+        0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+        0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+        0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+        0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+        0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+        0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+        0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+        0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+        0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+        0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
+        0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+        0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+        0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+        0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
+    },
+    .auchToSBCS0To128 =
+    {
+        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+        0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    },
+    .cSBCSs = 5,
+    .aSBCSs[0] =
+    {
+        .usStart = 0x0080,
+        .cChars = 28,
+        .auch =
+        {
+
+        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
+        }
+    },
+    .aSBCSs[1] =
+    {
+        .usStart = 0x009c,
+        .cChars = 28,
+        .auch =
+        {
+
+        0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab,
+        0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+        }
+    },
+    .aSBCSs[2] =
+    {
+        .usStart = 0x00b8,
+        .cChars = 28,
+        .auch =
+        {
+
+        0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+        0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3,
+        }
+    },
+    .aSBCSs[3] =
+    {
+        .usStart = 0x00d4,
+        .cChars = 28,
+        .auch =
+        {
+
+        0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
+        0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        }
+    },
+    .aSBCSs[4] =
+    {
+        .usStart = 0x00f0,
+        .cChars = 16,
+        .auch =
+        {
+
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        }
+    },
+    .CtypeFuncs =
+    {
+        .pfnmbsinit    =  __libc_locale_none_mbsinit,
+        .pfnmbrtowc    =  __libc_locale_none_mbrtowc,
+        .pfnmbsnrtowcs =  __libc_locale_none_mbsnrtowcs,
+        .pfnwcrtomb    =  __libc_locale_none_wcrtomb,
+        .pfnwcsnrtombs =  __libc_locale_none_wcsnrtombs
+    },
+    .uobj = 0,
+    .lobj = 0,
+    .mbcs = 0
 };
-#undef __isctype
-int __isctype(int _c, unsigned _f)
+
+
+int __isctype(__ct_rune_t __ch, unsigned __f)
 {
-    return (__libc_GLocaleCtypeDefault.ausfType[_c & 0xff] & (_f)) != 0;
+    return !((__ch) & ~0xffU)
+        ? !!(__libc_GLocaleCtypeDefault.aufType[(__ch)/* & 0xff*/] & (__f))
+        : 0;
 }
 
Index: trunk/src/emx/src/lib/locale/mb_libuni.c
===================================================================
--- trunk/src/emx/src/lib/locale/mb_libuni.c	(revision 1705)
+++ trunk/src/emx/src/lib/locale/mb_libuni.c	(revision 1705)
@@ -0,0 +1,453 @@
+/* $Id$ */
+/** @file
+ *
+ * Generic MBSC <-> Unicode Converter using libuni.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "libc-alias.h"
+#include <InnoTekLIBC/locale.h>
+#define INCL_FSMACROS
+#include <os2emx.h>
+#include <uconv.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdint.h>
+#include <string.h>
+
+typedef struct LIBUNIState
+{
+    char        chState;
+} LIBUNISTATE, *PLIBUNISTATE;
+
+
+static void libuni_errno(int rc)
+{
+    switch (rc)
+    {
+        case 0:
+            break;
+        case UCONV_E2BIG:           errno = E2BIG; break;
+        case UCONV_EBADF:           errno = EBADF; break;
+        case UCONV_EILSEQ:          errno = EILSEQ; break;
+        case UCONV_EINVAL:          errno = EINVAL; break;
+        case UCONV_EMFILE:          errno = EMFILE; break;
+        case UCONV_ENFILE:          errno = ENFILE; break;
+        case UCONV_ENOMEM:          errno = ENOMEM; break;
+        case UCONV_BADATTR:
+        case UCONV_EOTHER:
+        case UCONV_NOTIMPLEMENTED:
+        default:                    errno = EINVAL; break;
+    }
+}
+
+
+static int     libuni_mbsinit(const __mbstate_t *ps)
+{
+    return ps == NULL
+        || ((PLIBUNISTATE)ps)->chState == 0;
+}
+
+
+static size_t  libuni_mbrtowc(__wchar_t * __restrict pwc, const char * __restrict s, size_t n, __mbstate_t * __restrict ps)
+{
+    PLIBUNISTATE pState = (PLIBUNISTATE)ps;
+
+    /*
+     * Check input.
+     */
+    /* !s => mbrtowc(NULL, "", 1, ps) */
+    if (s == NULL)
+    {
+        s = "";
+        n = 1;
+        pwc = NULL;
+    }
+
+    /* Incomplete multibyte sequence */
+    if (n == 0)
+        return ((size_t)-2);
+
+
+    /*
+     * Try the conversion table first.
+     */
+    __wchar_t wc;
+    unsigned char uch = *(const unsigned char *)s;
+    if (    !pState->chState
+        &&  (wc = __libc_GLocaleCtype.aucUnicode[uch]) != 0xffff)
+    {
+        if (pwc != NULL)
+            *pwc = wc;
+        return !wc;
+    }
+
+    /*
+     * We must now get exclusive access to the conversion object,
+     * and restore the state before we try convert anything.
+     */
+    if (!pwc)
+        pwc = &wc;                      /* The api crashes elsewise. */
+    size_t  cbInLeft = n;
+    size_t  cwcOutLeft = 1;
+    size_t  cIgnore = 0;
+    uconv_attribute_t attr;
+    FS_VAR_SAVE_LOAD();
+    LOCALE_LOCK();
+    int rc = 0;
+    if (!__libc_GLocaleCtype.uobj)
+        rc = __libc_localeCreateObjects("C", NULL, NULL, &__libc_GLocaleCtype.lobj, &__libc_GLocaleCtype.uobj);
+    if (!rc)
+        rc = UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL);
+    if (!rc)
+    {
+        attr.state = pState->chState;
+        attr.options = UCONV_OPTION_SUBSTITUTE_BOTH;
+        attr.converttype &= ~CVTTYPE_PATH;
+        attr.converttype = CVTTYPE_CDRA | CVTTYPE_CTRL7F;
+        rc = UniSetUconvObject(__libc_GLocaleCtype.uobj, &attr);
+        if (!rc)
+        {
+            rc = UniUconvToUcs(__libc_GLocaleCtype.uobj, (void **)(void *)&s, &cbInLeft, (UniChar **)&pwc, &cwcOutLeft, &cIgnore);
+            if (!rc)
+            {
+                if (!UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL))
+                    pState->chState = attr.state;
+            }
+        }
+    }
+    LOCALE_UNLOCK();
+    FS_RESTORE();
+
+    if (!rc)
+        return n - cbInLeft;
+    /* failure */
+    libuni_errno(rc);
+    return -1;
+}
+
+
+static size_t libuni_wcrtomb(char * __restrict s, __wchar_t wc, __mbstate_t * __restrict ps)
+{
+    PLIBUNISTATE pState = (PLIBUNISTATE)ps;
+
+    /*
+     * Check state.
+     */
+    if (s == NULL)
+    {
+        pState->chState = 0; //??
+        return 1; /* Reset to initial shift state (no-op) */
+    }
+
+
+    /*
+     * Try use the conversion tables.
+     */
+    char    ch;
+    if (!pState->chState)
+    {
+        if (wc < sizeof(__libc_GLocaleCtype.auchToSBCS0To128) / sizeof(__libc_GLocaleCtype.auchToSBCS0To128[0]))
+        {
+            ch = __libc_GLocaleCtype.auchToSBCS0To128[wc];
+            if (ch || !wc)
+            {
+                if (s)
+                    *s = ch;
+                return 1;
+            }
+        }
+        else
+        {
+            /** @todo make this a binary search! */
+            int i = __libc_GLocaleCtype.cSBCSs;
+            while (i-- > 0)
+            {
+                unsigned idx = (unsigned)wc - __libc_GLocaleCtype.aSBCSs[i].usStart;
+                if (idx < __libc_GLocaleCtype.aSBCSs[i].cChars)
+                {
+                    ch = __libc_GLocaleCtype.aSBCSs[i].auch[idx];
+                    if (ch)
+                    {
+                        if (s)
+                            *s = ch;
+                        return 1;
+                    }
+                    break;
+                }
+            }
+        }
+        /* not found */
+    }
+
+    /*
+     * We must now get exclusive access to the conversion object,
+     * and restore the state before we try convert anything.
+     */
+    if (!s)
+        s = alloca(MB_LEN_MAX);
+    size_t      cbInLeft = 1;
+    size_t      cIgnore = 0;
+    UniChar    *pucIn = &wc;
+    uconv_attribute_t attr;
+    FS_VAR_SAVE_LOAD();
+    LOCALE_LOCK();
+    size_t      cchMbCurMax = MB_CUR_MAX;
+    size_t      cchOutLeft = cchMbCurMax;
+    int rc = 0;
+    if (!__libc_GLocaleCtype.uobj)
+        rc = __libc_localeCreateObjects("C", NULL, NULL, &__libc_GLocaleCtype.lobj, &__libc_GLocaleCtype.uobj);
+    if (!rc)
+        rc = UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL);
+    if (!rc)
+    {
+        attr.state = pState->chState;
+        attr.options = UCONV_OPTION_SUBSTITUTE_BOTH;
+        attr.converttype = CVTTYPE_CDRA | CVTTYPE_CTRL7F;
+        rc = UniSetUconvObject(__libc_GLocaleCtype.uobj, &attr);
+        if (!rc)
+        {
+            rc = UniUconvFromUcs(__libc_GLocaleCtype.uobj, &pucIn, &cbInLeft, (void **)(void *)&s, &cchOutLeft, &cIgnore);
+            if (!rc)
+            {
+                if (!UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL))
+                    pState->chState = attr.state;
+            }
+        }
+    }
+    LOCALE_UNLOCK();
+    FS_RESTORE();
+
+    if (!rc)
+        return cchMbCurMax - cchOutLeft;
+    /* failure */
+    libuni_errno(rc);
+    return -1;
+}
+
+static size_t  libuni_mbsnrtowcs(__wchar_t * __restrict dst, const char ** __restrict src, size_t nms, size_t len, __mbstate_t * __restrict ps)
+{
+    return __libc_localeFuncsGeneric_mbsnrtowcs(libuni_mbrtowc, dst, src, nms, len, ps);
+}
+
+static size_t  libuni_wcsnrtombs(char * __restrict dst, const __wchar_t ** __restrict src, size_t nwc, size_t len, __mbstate_t * __restrict ps)
+{
+    return __libc_localeFuncsGeneric_wcsnrtombs(libuni_wcrtomb, dst, src, nwc, len, ps);
+}
+
+
+/**
+ * Fill in the default libuni base conversion functions.
+ */
+void __libc_localeFuncsDefault(__LIBC_PLOCALECTYPEFUNCS pFuncs)
+{
+    pFuncs->pfnmbsinit      = libuni_mbsinit;
+    pFuncs->pfnmbrtowc      = libuni_mbrtowc;
+    pFuncs->pfnmbsnrtowcs   = libuni_mbsnrtowcs;
+    pFuncs->pfnwcrtomb      = libuni_wcrtomb;
+    pFuncs->pfnwcsnrtombs   = libuni_wcsnrtombs;
+}
+
+
+
+size_t  __libc_localeFuncsGeneric_mbsnrtowcs(size_t  (*pfnmbrtowc)(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict),
+                                             __wchar_t * __restrict dst, const char ** __restrict src, size_t nms, size_t len, __mbstate_t * __restrict ps)
+{
+    const char *pch = *src;
+    size_t      cwc = 0;
+    if (dst == NULL)
+    {
+        __wchar_t wc;
+        for (;;)
+        {
+            size_t cb = pfnmbrtowc(&wc, pch, nms, ps);
+            if ((int)cb <= 0)
+            {
+                if (cb == (size_t)-1)
+                    return (size_t)-1;    /* Invalid sequence - mbrtowc() sets errno. */
+                else /* if (cb == 0 || cb == (size_t)-2) */
+                    return cwc;
+            }
+
+            /* advance */
+            pch += cb;
+            nms -= cb;
+            cwc++;
+        }
+        /* (won't ever get here.) */
+    }
+    else
+    {
+        while (len-- > 0)
+        {
+            size_t cb = pfnmbrtowc(dst, pch, nms, ps);
+            if ((int)cb <= 0)
+            {
+                if (!cb)
+                {
+                    *src = NULL;
+                    return cwc;
+                }
+                else if (cb == (size_t)-2)
+                {
+                    *src = pch + nms;
+                    return cwc;
+                }
+                else /*if (cb == (size_t)-1) */
+                {
+                    *src = pch;
+                    return (size_t)-1;    /* Invalid sequence - mbrtowc() sets errno. */
+                }
+            }
+
+            /* advance */
+            pch += cb;
+            nms -= cb;
+            cwc++;
+            dst++;
+        }
+
+        *src = pch;
+        return cwc;
+    }
+}
+
+
+size_t  __libc_localeFuncsGeneric_wcsnrtombs(size_t  (*pfnwcrtomb)(char * __restrict, __wchar_t, __mbstate_t * __restrict),
+                                             char * __restrict dst, const __wchar_t ** __restrict src, size_t nwc, size_t len, __mbstate_t * __restrict ps)
+{
+    char            achTmp[MB_LEN_MAX];
+    const __wchar_t  *pwcs = *src;
+    size_t          cbUsed = 0;
+    if (dst == NULL)
+    {
+        while (nwc-- > 0)
+        {
+            __wchar_t wc = *pwcs;
+            size_t cb = pfnwcrtomb(&achTmp[0], wc, ps);
+            if (cb == (size_t)-1)
+                return (size_t)-1; /* Invalid character - wcrtomb() sets errno. */
+            if (wc == L'\0')
+                return cbUsed + cb - 1;
+            /* advance */
+            pwcs++;
+            cbUsed += cb;
+        }
+        return cbUsed;
+    }
+    else
+    {
+        while (len > 0 && nwc-- > 0)
+        {
+            size_t cb;
+            __wchar_t wc = *pwcs;
+            if (len > (size_t)MB_CUR_MAX)
+            {
+                cb = pfnwcrtomb(dst, wc, ps);
+                if ((int)cb < 0)
+                {
+                    *src = pwcs;
+                    return (size_t)-1;
+                }
+            }
+            else
+            {
+                cb = pfnwcrtomb(&achTmp[0], wc, ps);
+                if ((int)cb < 0)
+                {
+                    *src = pwcs;
+                    return (size_t)-1;
+                }
+                if (cb > len)
+                    break;  /* MB sequence for character won't fit. */
+                switch (cb)
+                {
+                    case 4:
+                        *(uint32_t *)dst = *(uint32_t *)&achTmp[0];
+                        break;
+                    case 3:
+                        dst[2] = achTmp[2];
+                        /* fall thru */
+                    case 2:
+                        *(uint16_t *)dst = *(uint16_t *)&achTmp[0];
+                        break;
+                    case 1:
+                        dst[0] = achTmp[0];
+                        break;
+                    default:
+                        memcpy(dst, achTmp, cb);
+                        break;
+                }
+            }
+            if (wc == L'\0')
+            {
+                *src = 0;
+                return cbUsed + cb - 1;
+            }
+
+            /* advance */
+            dst += cb;
+            len -= cb;
+            cbUsed += cb;
+            pwcs++;
+        }
+        *src = pwcs;
+        return cbUsed;
+
+    }
+}
+
+/* later */
+void __libc_localeFuncsSBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs)
+{
+    __libc_localeFuncsDefault(pFuncs);
+}
+
+/* later */
+void __libc_localeFuncsDBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs)
+{
+    __libc_localeFuncsDefault(pFuncs);
+}
+
+/* later */
+void __libc_localeFuncsMBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs)
+{
+    __libc_localeFuncsDefault(pFuncs);
+}
+
+/* later */
+void __libc_localeFuncsUCS2(__LIBC_PLOCALECTYPEFUNCS pFuncs)
+{
+    __libc_localeFuncsDefault(pFuncs);
+}
+
+/* later */
+void __libc_localeFuncsUTF8(__LIBC_PLOCALECTYPEFUNCS pFuncs)
+{
+    __libc_localeFuncsDefault(pFuncs);
+}
+
Index: trunk/src/emx/src/lib/locale/mb_none.c
===================================================================
--- trunk/src/emx/src/lib/locale/mb_none.c	(revision 1705)
+++ trunk/src/emx/src/lib/locale/mb_none.c	(revision 1705)
@@ -0,0 +1,165 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Paul Borman at Krystal Technologies.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "libc-alias.h"
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)none.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/none.c,v 1.12 2004/07/21 10:54:57 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <InnoTekLIBC/locale.h>
+#include <wchar.h>
+
+int
+__libc_locale_none_mbsinit(const mbstate_t *ps __unused)
+{
+
+    /*
+     * Encoding is not state dependent - we are always in the
+     * initial state.
+     */
+    return(1);
+}
+
+size_t
+__libc_locale_none_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
+              mbstate_t * __restrict ps __unused)
+{
+
+    if (s == NULL)
+        /* Reset to initial shift state (no-op) */
+        return(0);
+    if (n == 0)
+        /* Incomplete multibyte sequence */
+        return((size_t)-2);
+    if (pwc != NULL)
+        *pwc = (unsigned char)*s;
+    return(*s == '\0' ? 0 : 1);
+}
+
+size_t
+__libc_locale_none_wcrtomb(char * __restrict s, wchar_t wc,
+              mbstate_t * __restrict ps __unused)
+{
+
+    if (s == NULL)
+        /* Reset to initial shift state (no-op) */
+        return(1);
+    if (/*wc < 0 ||*/ (unsigned)wc > UCHAR_MAX)
+    {
+        errno = EILSEQ;
+        return((size_t)-1);
+    }
+    *s = (unsigned char)wc;
+    return(1);
+}
+
+size_t
+__libc_locale_none_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src,
+                 size_t nms, size_t len, mbstate_t * __restrict ps __unused)
+{
+    const char *s;
+    size_t nchr;
+
+    if (dst == NULL)
+    {
+        s = memchr(*src, '\0', nms);
+        return(s != NULL ? s - *src : nms);
+    }
+
+    s = *src;
+    nchr = 0;
+    while (len-- > 0 && nms-- > 0)
+    {
+        if ((*dst++ = (unsigned char)*s++) == L'\0')
+        {
+            *src = NULL;
+            return(nchr);
+        }
+        nchr++;
+    }
+    *src = s;
+    return(nchr);
+}
+
+size_t
+__libc_locale_none_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src,
+                 size_t nwc, size_t len, mbstate_t * __restrict ps __unused)
+{
+    const wchar_t *s;
+    size_t nchr;
+
+    if (dst == NULL)
+    {
+        for (s = *src; nwc > 0 && *s != L'\0'; s++, nwc--)
+        {
+            if (/**s < 0 ||*/ (unsigned)*s > UCHAR_MAX)
+            {
+                errno = EILSEQ;
+                return((size_t)-1);
+            }
+        }
+        return(s - *src);
+    }
+
+    s = *src;
+    nchr = 0;
+    while (len-- > 0 && nwc-- > 0)
+    {
+        if (/**s < 0 ||*/ (unsigned)*s > UCHAR_MAX)
+        {
+            errno = EILSEQ;
+            return((size_t)-1);
+        }
+        if ((*dst++ = *s++) == '\0')
+        {
+            *src = NULL;
+            return(nchr);
+        }
+        nchr++;
+    }
+    *src = s;
+    return(nchr);
+}
+
Index: trunk/src/emx/src/lib/locale/mbcurmax.c
===================================================================
--- trunk/src/emx/src/lib/locale/mbcurmax.c	(revision 1705)
+++ trunk/src/emx/src/lib/locale/mbcurmax.c	(revision 1705)
@@ -0,0 +1,14 @@
+/*
+    Locale support implementation through OS/2 Unicode API.
+    Copyright (c) 2003 InnoTek Systemberatung GmbH
+
+    For conditions of distribution and use, see the file COPYING.
+
+    This file contains the _mb_cur_max variable which is the maximal
+    length of a multibyte character (depends on LC_CTYPE locale setting).
+    Accessed through MB_CUR_MAX macro defined in <stdlib.h>.
+*/
+
+#include <stdlib.h>
+
+int __mb_cur_max = 1;
Index: trunk/src/emx/src/lib/locale/nl_langinfo.c
===================================================================
--- trunk/src/emx/src/lib/locale/nl_langinfo.c	(revision 1705)
+++ trunk/src/emx/src/lib/locale/nl_langinfo.c	(revision 1705)
@@ -0,0 +1,150 @@
+/* $Id$ */
+/** @file
+ *
+ * nl_langinfo.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "libc-alias.h"
+#include <InnoTekLIBC/locale.h>
+#include <langinfo.h>
+
+
+char *_STD(nl_langinfo)(nl_item Item)
+{
+    switch (Item)
+    {
+        case D_T_FMT:
+            return __libc_gLocaleTime.date_time_fmt;
+        case D_FMT:
+            return __libc_gLocaleTime.date_fmt;
+        case T_FMT:
+            return __libc_gLocaleTime.time_fmt;
+        case AM_STR:
+            return __libc_gLocaleTime.am;
+        case PM_STR:
+            return __libc_gLocaleTime.pm;
+
+        case ABDAY_1:
+        case ABDAY_2:
+        case ABDAY_3:
+        case ABDAY_4:
+        case ABDAY_5:
+        case ABDAY_6:
+        case ABDAY_7:
+            return __libc_gLocaleTime.swdays[Item - ABDAY_1];
+
+        case DAY_1:
+        case DAY_2:
+        case DAY_3:
+        case DAY_4:
+        case DAY_5:
+        case DAY_6:
+        case DAY_7:
+            return __libc_gLocaleTime.lwdays[Item - DAY_1];
+
+        case ABMON_1:
+        case ABMON_2:
+        case ABMON_3:
+        case ABMON_4:
+        case ABMON_5:
+        case ABMON_6:
+        case ABMON_7:
+        case ABMON_8:
+        case ABMON_9:
+        case ABMON_10:
+        case ABMON_11:
+        case ABMON_12:
+            return __libc_gLocaleTime.smonths[Item - ABMON_1];
+
+        case MON_1:
+        case MON_2:
+        case MON_3:
+        case MON_4:
+        case MON_5:
+        case MON_6:
+        case MON_7:
+        case MON_8:
+        case MON_9:
+        case MON_10:
+        case MON_11:
+        case MON_12:
+            return __libc_gLocaleTime.lmonths[Item - MON_1];
+
+        case RADIXCHAR:
+            return __libc_gLocaleLconv.s.decimal_point;
+        case THOUSEP:
+            return __libc_gLocaleLconv.s.thousands_sep;
+
+        case YESSTR:
+            return ""; ///@todo LC_MESSAGE
+        case NOSTR:
+            return ""; ///@todo LC_MESSAGE
+
+        case CRNCYSTR:
+            return __libc_gLocaleLconv.pszCrncyStr;
+
+        case CODESET:
+            //todo
+            break;
+
+        case T_FMT_AMPM:
+            return __libc_gLocaleTime.ampm_fmt;
+
+        case ERA:
+            return __libc_gLocaleTime.era;
+
+        case ERA_D_FMT:
+            return __libc_gLocaleTime.era_date_fmt;
+
+        case ERA_D_T_FMT:
+            return __libc_gLocaleTime.era_date_time_fmt;
+
+        case ERA_T_FMT:
+            return __libc_gLocaleTime.era_time_fmt;
+
+        case ALT_DIGITS:
+            return __libc_gLocaleTime.alt_digits;
+
+        case YESEXPR:
+            return ""; ///@todo LC_MESSAGE
+        case NOEXPR:
+            return ""; ///@todo LC_MESSAGE
+
+        case DATESEP:
+            return __libc_gLocaleTime.datesep;
+
+        case TIMESEP:
+            return __libc_gLocaleTime.timesep;
+
+        case LISTSEP:
+            return __libc_gLocaleTime.listsep;
+    }
+
+    return "";
+}
+
+
Index: trunk/src/emx/src/lib/locale/setlocale.c
===================================================================
--- trunk/src/emx/src/lib/locale/setlocale.c	(revision 1702)
+++ trunk/src/emx/src/lib/locale/setlocale.c	(revision 1705)
@@ -118,4 +118,6 @@
     /** Ctype data. */
     __LIBC_LOCALECTYPE          Ctype;
+    /** Ctype conversion functions. */
+    __LIBC_PCLOCALECTYPEFUNCS   pCtypeFuncs;
     /** Time data. */
     __LIBC_LOCALETIME           Time;
@@ -220,7 +222,6 @@
 static void localeMonetaryFree(__LIBC_PLOCALELCONV pLconv);
 static int localeNumericDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv);
-static int localeMonetaryDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv);
+static int localeMonetaryDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, LocaleObject lobj, struct UniLconv *pULconv);
 static void localeGlobalFree(__LIBC_PLOCALEGLOBAL pGlobal, int iCategory);
-static int localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj);
 static int localeParseLocale(char *pszLocale, const char **ppszCodepage);
 static int localeDoOne(struct temp_locale *pTemp, int iCategory, const char *pszLocale, const char *pszCodepage);
@@ -467,5 +468,4 @@
 }
 
-
 static inline unsigned char Transform(LocaleObject lobj, UconvObject uobj,
                                       UniChar (* APIENTRY pfnTransFunc) (LocaleObject, UniChar),
@@ -496,4 +496,14 @@
 
     /*
+     * For "C" / "POSIX" we can just use the static default locale.
+     */
+    if (    IS_C_LOCALE(pszLocale)
+        ||  IS_POSIX_LOCALE(pszLocale))
+    {
+        memcpy(pCtype, &__libc_GLocaleCtypeDefault, sizeof(*pCtype));
+        return 0;
+    }
+
+    /*
      * Query multi-byte related stuff.
      */
@@ -501,4 +511,49 @@
     if (rc)
         return rc;
+
+    /*
+     * Query encoding.
+     */
+    uconv_attribute_t   attr;
+    rc = UniQueryUconvObject(uobj, &attr, sizeof(attr), NULL, NULL, NULL);
+    if (rc)
+        return -unierr2errno(rc);
+    switch (attr.esid)
+    {
+        case ESID_sbcs_data:
+        case ESID_sbcs_pc:
+        case ESID_sbcs_ebcdic:
+        case ESID_sbcs_iso:
+        case ESID_sbcs_windows:
+        case ESID_sbcs_alt:
+            __libc_localeFuncsSBCS(&pCtype->CtypeFuncs);
+            break;
+
+        case ESID_dbcs_data:
+        case ESID_dbcs_pc:
+        case ESID_dbcs_ebcdic:
+            __libc_localeFuncsDBCS(&pCtype->CtypeFuncs);
+            break;
+
+        case ESID_mbcs_data:
+        case ESID_mbcs_pc:
+        case ESID_mbcs_ebcdic:
+            __libc_localeFuncsMBCS(&pCtype->CtypeFuncs);
+            break;
+
+        case ESID_ucs_2:
+            __libc_localeFuncsUCS2(&pCtype->CtypeFuncs);
+            break;
+
+        case ESID_utf_8:
+            __libc_localeFuncsUTF8(&pCtype->CtypeFuncs);
+            break;
+
+        case ESID_upf_8:
+        case ESID_ugl:
+        default:
+            __libc_localeFuncsDefault(&pCtype->CtypeFuncs);
+            break;
+    }
 
     /*
@@ -510,49 +565,101 @@
      * Unicode - this would lead in a shift of the entire string.
      */
+    /** @todo Aren't there apis for getting all this at once? */
+    bzero(pCtype->auchToSBCS0To128, sizeof(pCtype->auchToSBCS0To128));
+    bzero(pCtype->aSBCSs, sizeof(pCtype->aSBCSs));
+    pCtype->cSBCSs = 0;
     for (i = 0; i < 256; i++)
     {
-        unsigned short  usfType = 0;
-        unsigned char   uchUpper;
-        unsigned char   uchLower;
-        UniChar         ucs;
-
-        if (!__libc_ucs2To(uobj, (unsigned char *)&i, 1, &ucs))
-            ucs = i;
-
-        /* isxxx() do not support DBCS characters at all */
-        if (!IS_MBCS_PREFIX(pCtype, i))
+        unsigned        ufType = 0;
+        unsigned char   uchUpper = i;
+        unsigned char   uchLower = i;
+        UniChar         uc = 0xffff;
+
+        /* isxxx() do not support MBCS characters at all. */
+        if (!pCtype->mbcs || !IS_MBCS_PREFIX(pCtype, i))
         {
-            /* ASSUMES CT_* == __* ! */
-            UNICTYPE *pCtype = UniQueryCharType(ucs);
-            if (pCtype)
-                usfType = (pCtype->itype) & (__UPPER  | __LOWER  | __DIGIT | __SPACE |
-                                             __PUNCT  | __CNTRL  | __BLANK | __XDIGIT |
-                                             __ALPHA  | __ALNUM  | __GRAPH | __PRINT |
-                                             __NUMBER | __SYMBOL | __ASCII);
-            uchUpper = Transform(lobj, uobj, UniTransUpper, ucs, i);
-            uchLower = Transform(lobj, uobj, UniTransLower, ucs, i);
-            /** @todo isn't there apis for getting all this at once? */
+            if (__libc_ucs2To(uobj, (unsigned char *)&i, 1, &uc))
+            {
+                /* ASSUMES that lower/upper are paired! */
+                /* ASSUMES that there are no difference between the locale and the unicode spec! */
+                UNICTYPE *pUniType = UniQueryCharType(uc);
+                if (pUniType)
+                {
+                    ufType = ___wctype(uc);
+                    if (ufType & __CT_LOWER)
+                        uchUpper = Transform(lobj, uobj, UniTransUpper, uc, i);
+                    if (ufType & __CT_UPPER)
+                        uchLower = Transform(lobj, uobj, UniTransLower, uc, i);
+
+                    /*
+                     * Add to conversion table.
+                     */
+                    if (uc < 128)
+                        pCtype->auchToSBCS0To128[uc] = i;
+                    else
+                    {
+                        /*
+                         * Try fit it into an existing chunk.
+                         */
+                        int iChunk;
+                        for (iChunk = 0; iChunk < pCtype->cSBCSs; iChunk++)
+                        {
+                            int cFree = sizeof(pCtype->aSBCSs[iChunk].auch) / sizeof(pCtype->aSBCSs[iChunk].auch[0]) - pCtype->aSBCSs[iChunk].cChars;
+                            if (cFree > 0)
+                            {
+                                int off = (int)uc - (int)pCtype->aSBCSs[iChunk].usStart;
+                                if (off < sizeof(pCtype->aSBCSs[iChunk].auch) / sizeof(pCtype->aSBCSs[iChunk].auch[0]))
+                                {
+                                    if (off >= 0)
+                                    {
+                                        if (pCtype->aSBCSs[iChunk].cChars <= off)
+                                            pCtype->aSBCSs[iChunk].cChars = off + 1;
+                                        pCtype->aSBCSs[iChunk].auch[off] = i;
+                                        break;
+                                    }
+                                    /* Relocate the chunk up to 3 bytes if that will help. (might cause overlapping areas!) */
+                                    else if (off >= -3 && -off < cFree)
+                                    {
+                                        off = -off;
+                                        memmove(&pCtype->aSBCSs[iChunk].auch[off], &pCtype->aSBCSs[iChunk].auch[0], pCtype->aSBCSs[iChunk].cChars * sizeof(pCtype->aSBCSs[iChunk].auch[0]));
+
+                                        pCtype->aSBCSs[iChunk].usStart -= off;
+                                        pCtype->aSBCSs[iChunk].cChars  += off;
+                                        pCtype->aSBCSs[iChunk].auch[0]  = i;
+                                        switch (off)
+                                        {
+                                            case 3: pCtype->aSBCSs[iChunk].auch[2] = 0;
+                                            case 2: pCtype->aSBCSs[iChunk].auch[1] = 0; break;
+                                        }
+                                        break;
+                                    }
+                                }
+                            }
+                        } /* foreach chunk */
+
+                        /*
+                         * Add new chunk?
+                         */
+                        if (    iChunk == pCtype->cSBCSs
+                            &&  iChunk < sizeof(pCtype->aSBCSs) / sizeof(pCtype->aSBCSs[0]))
+                        {
+                            pCtype->aSBCSs[iChunk].usStart = uc;
+                            pCtype->aSBCSs[iChunk].cChars  = 1;
+                            pCtype->aSBCSs[iChunk].auch[0] = i;
+                            pCtype->cSBCSs++;
+                        }
+                    }
+                } /* Unicode type data, ok. */
+            }
+            else
+                uc = 0xffff;
         }
-        else
-            uchUpper = uchLower = i;
-
-        pCtype->ausfType[i]  = usfType;
-        pCtype->auchUpper[i] = uchUpper;
-        pCtype->auchLower[i] = uchLower;
-    }
-
-    /*
-     * In the "C" pszLocale second half of the cflags table should be empty.
-     */
-    if (    IS_C_LOCALE(pszLocale)
-        ||  IS_POSIX_LOCALE(pszLocale))
-    {
-        bzero(&pCtype->ausfType[128], 128 * sizeof(pCtype->ausfType[0]));
-        for (i = 128; i < 255; i++)
-        {
-            pCtype->auchUpper[i] = i;
-            pCtype->auchLower[i] = i;
-        }
-    }
+
+        /* Store the data in the locale structure. */
+        pCtype->aufType[i]      = ufType;
+        pCtype->auchUpper[i]    = uchUpper;
+        pCtype->auchLower[i]    = uchLower;
+        pCtype->aucUnicode[i]   = uc;
+    } /* foreach char 0..255 */
 
     /*
@@ -650,13 +757,22 @@
 
     /* query the items. */
-    if (    (rc = query_item( lobj, uobj,     D_T_FMT, &pTime->date_time_fmt))
-        ||  (rc = query_item( lobj, uobj,     D_FMT,   &pTime->date_fmt))
-        ||  (rc = query_item( lobj, uobj,     T_FMT,   &pTime->time_fmt))
-        ||  (rc = query_item( lobj, uobj,     AM_STR,  &pTime->am))
-        ||  (rc = query_item( lobj, uobj,     PM_STR,  &pTime->pm))
-        ||  (rc = query_array(lobj, uobj,  7, DAY_1,   &pTime->lwdays[0]))
-        ||  (rc = query_array(lobj, uobj,  7, ABDAY_1, &pTime->swdays[0]))
-        ||  (rc = query_array(lobj, uobj, 12, MON_1,   &pTime->lmonths[0]))
-        ||  (rc = query_array(lobj, uobj, 12, ABMON_1, &pTime->smonths[0]))
+    if (    (rc = query_item( lobj, uobj,     D_T_FMT,      &pTime->date_time_fmt))
+        ||  (rc = query_item( lobj, uobj,     D_FMT,        &pTime->date_fmt))
+        ||  (rc = query_item( lobj, uobj,     T_FMT,        &pTime->time_fmt))
+        ||  (rc = query_item( lobj, uobj,     AM_STR,       &pTime->am))
+        ||  (rc = query_item( lobj, uobj,     PM_STR,       &pTime->pm))
+        ||  (rc = query_item( lobj, uobj,     T_FMT_AMPM,   &pTime->ampm_fmt))
+        ||  (rc = query_item( lobj, uobj,     ERA,          &pTime->era))
+        ||  (rc = query_item( lobj, uobj,     ERA_D_FMT,    &pTime->era_date_fmt))
+        ||  (rc = query_item( lobj, uobj,     ERA_D_T_FMT,  &pTime->era_date_time_fmt))
+        ||  (rc = query_item( lobj, uobj,     ERA_T_FMT,    &pTime->era_time_fmt))
+        ||  (rc = query_item( lobj, uobj,     ALT_DIGITS,   &pTime->alt_digits))
+        ||  (rc = query_item( lobj, uobj,     DATESEP,      &pTime->datesep))
+        ||  (rc = query_item( lobj, uobj,     TIMESEP,      &pTime->timesep))
+        ||  (rc = query_item( lobj, uobj,     LISTSEP,      &pTime->listsep))
+        ||  (rc = query_array(lobj, uobj,  7, DAY_1,        &pTime->lwdays[0]))
+        ||  (rc = query_array(lobj, uobj,  7, ABDAY_1,      &pTime->swdays[0]))
+        ||  (rc = query_array(lobj, uobj, 12, MON_1,        &pTime->lmonths[0]))
+        ||  (rc = query_array(lobj, uobj, 12, ABMON_1,      &pTime->smonths[0]))
             )
     {
@@ -714,12 +830,14 @@
 static void localeMonetaryFree(__LIBC_PLOCALELCONV pLconv)
 {
-#define FREE(x) do { if (pLconv->s.x && !pLconv->fMonetaryConsts) free(pLconv->s.x); pLconv->s.x = NULL; } while (0)
-    FREE(int_curr_symbol);
-    FREE(currency_symbol);
-    FREE(mon_decimal_point);
-    FREE(mon_thousands_sep);
-    FREE(mon_grouping);
-    FREE(positive_sign);
-    FREE(negative_sign);
+#define FREE(x) do { if (pLconv->x && !pLconv->fMonetaryConsts) free(pLconv->x); pLconv->x = NULL; } while (0)
+    FREE(s.int_curr_symbol);
+    FREE(s.currency_symbol);
+    FREE(s.mon_decimal_point);
+    FREE(s.mon_thousands_sep);
+    FREE(s.mon_grouping);
+    FREE(s.positive_sign);
+    FREE(s.negative_sign);
+    FREE(pszCrncyStr);
+
     pLconv->fMonetaryConsts = 0;
 #undef FREE
@@ -783,5 +901,5 @@
  * @param   pULconv     Pointer to the pULconv structure to get the data from.
  */
-static int localeMonetaryDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv)
+static int localeMonetaryDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, LocaleObject lobj, struct UniLconv *pULconv)
 {
     int rc;
@@ -809,4 +927,11 @@
     pLconv->s.n_sign_posn       = pULconv->n_sign_posn;
 #undef CONVERT_UCS
+
+    /*
+     * Extra stuff (which I don't know which member corresponds to).
+     */
+    if ((rc = query_item(lobj, uobj, CRNCYSTR, &pLconv->pszCrncyStr)))
+        return rc;
+
     return localeConvertGrouping(pULconv->mon_grouping, &pLconv->s.mon_grouping);
 }
@@ -1005,5 +1130,5 @@
  * Creates the libuni objects we need.
  */
-static int localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj)
+int __libc_localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj)
 {
     LIBCLOG_ENTER("pszLocale=%p:{%s} pszCodepage=%p:{%s} pszCodepageActual=%p plobj=%p puobj=%p\n",
@@ -1068,5 +1193,5 @@
      * Create the objects.
      */
-    rc = localeCreateObjects(pszLocale, pszCodepage, &szCodepageActual[0], &lobj, &uobj);
+    rc = __libc_localeCreateObjects(pszLocale, pszCodepage, &szCodepageActual[0], &lobj, &uobj);
     if (rc)
         return rc;
@@ -1106,5 +1231,5 @@
                     rc = localeNumericDo(&pTemp->Lconv, uobj, pULconv);
                 else
-                    rc = localeMonetaryDo(&pTemp->Lconv, uobj, pULconv);
+                    rc = localeMonetaryDo(&pTemp->Lconv, uobj, lobj, pULconv);
                 UniFreeLocaleInfo(pULconv);
             }
@@ -1363,4 +1488,5 @@
         __libc_gLocaleLconv.s.p_sign_posn        = pTemp->Lconv.s.p_sign_posn;
         __libc_gLocaleLconv.s.n_sign_posn        = pTemp->Lconv.s.n_sign_posn;
+        __libc_gLocaleLconv.pszCrncyStr          = pTemp->Lconv.pszCrncyStr;
         pTemp->afProcessed[LC_MONETARY + 1] = 0;
         gLocale.apszNames[LC_MONETARY + 1] = pTemp->Global.apszNames[LC_MONETARY + 1];
@@ -1587,5 +1713,5 @@
                     memcpy(psz, gLocale.apszNames[LC_CTYPE + 1], cch);
                     localeParseLocale(psz, &pszCodepage);
-                    rc = localeCreateObjects(psz, pszCodepage, NULL, &lobj, &uobj);
+                    rc = __libc_localeCreateObjects(psz, pszCodepage, NULL, &lobj, &uobj);
                     if (!rc)
                         LIBCLOG_RETURN_INT(rc);
@@ -1607,5 +1733,5 @@
                     memcpy(psz, gLocale.apszNames[LC_COLLATE + 1], cch);
                     localeParseLocale(psz, &pszCodepage);
-                    rc = localeCreateObjects(psz, pszCodepage, NULL, &lobj, &uobj);
+                    rc = __libc_localeCreateObjects(psz, pszCodepage, NULL, &lobj, &uobj);
                     if (!rc)
                         LIBCLOG_RETURN_INT(rc);
Index: trunk/src/emx/src/lib/locale/wctype.c
===================================================================
--- trunk/src/emx/src/lib/locale/wctype.c	(revision 1705)
+++ trunk/src/emx/src/lib/locale/wctype.c	(revision 1705)
@@ -0,0 +1,78 @@
+/* $Id$ */
+/** @file
+ *
+ * wctype.
+ *
+ * Copyright (c) 2004 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of InnoTek LIBC.
+ *
+ * InnoTek LIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * InnoTek LIBC 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with InnoTek LIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "libc-alias.h"
+#include <wctype.h>
+#include <string.h>
+
+
+/**
+ * Convert a property string to flag value.
+ */
+wctype_t _STD(wctype)(const char *pszProperty)
+{
+    static const struct
+    {
+        const char     *psz;
+        unsigned        cch;
+        wctype_t        uf;
+    } aProps[] =
+    {
+        #define STR(s) s, sizeof(s) - 1
+        { STR("alnum"),     __CT_ALPHA | __CT_DIGIT },
+	{ STR("alpha"),     __CT_ALPHA },
+	{ STR("blank"),     __CT_BLANK },
+	{ STR("cntrl"),     __CT_CNTRL },
+	{ STR("digit"),     __CT_DIGIT },
+	{ STR("graph"),     __CT_GRAPH },
+	{ STR("lower"),     __CT_LOWER },
+	{ STR("print"),     __CT_PRINT },
+	{ STR("punct"),     __CT_PUNCT },
+	{ STR("space"),     __CT_SPACE },
+	{ STR("upper"),     __CT_UPPER },
+	{ STR("xdigit"),    __CT_XDIGIT },
+        /* extensions: */
+	{ STR("ascii"),     __CT_ASCII },	
+	{ STR("ideogram"),  __CT_IDEOGRAM },	
+	{ STR("number"),    __CT_NUMBER },	
+	{ STR("rune"),      ~__CT_NUM_MASK},
+	{ STR("symbol"),    __CT_SYMBOL },	
+        #undef STR
+    };
+    unsigned cch = strlen(pszProperty);
+    int i;
+    for (i = 0; i < sizeof(aProps) / sizeof(aProps[0]) - 1; i++)
+        if (    aProps[i].cch == cch
+            &&  !memcmp(aProps[i].psz, pszProperty, cch))
+            return aProps[i].uf;
+    /* not found. */
+    return 0;
+}
+
