Changeset 1705 for trunk/src/emx/include


Ignore:
Timestamp:
Dec 6, 2004, 3:19:54 AM (21 years ago)
Author:
bird
Message:

wide-char and other locale stuff.

Location:
trunk/src/emx/include
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/locale.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1704 r1705  
    3131
    3232#include <sys/cdefs.h>
     33#include <sys/_types.h>
    3334#include <locale.h>
    3435#include <uconv.h>
     
    4546    /** MBCS prefixes. Two bits per character. */
    4647    unsigned char   au2MBCSPrefixs[256/4];
     48#ifdef __OS2__
    4749    /** The converter object to convert to and from selected codepage
    4850      (used with MBCS codepages only). */
     
    5052    /** The locale object. */
    5153    LocaleObject    lobj;
     54#endif
    5255    /** Non-zero if there are any MBCS prefix characters in codepage. */
    5356    char            mbcs;
     
    5659typedef __LIBC_LOCALECOLLATE *__LIBC_PLOCALECOLLATE;
    5760
     61/**
     62 * Multibyte to/from wide character conversion functions.
     63 */
     64typedef struct __libc_localeCTypeFuncs
     65{
     66    int     (*pfnmbsinit)(const __mbstate_t *);
     67    size_t  (*pfnmbrtowc)(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict);
     68    size_t  (*pfnmbsnrtowcs)(__wchar_t * __restrict, const char ** __restrict, size_t, size_t, __mbstate_t * __restrict);
     69    size_t  (*pfnwcrtomb)(char * __restrict, __wchar_t, __mbstate_t * __restrict);
     70    size_t  (*pfnwcsnrtombs)(char * __restrict, const __wchar_t ** __restrict, size_t, size_t, __mbstate_t * __restrict);
     71} __LIBC_LOCALECTYPEFUNCS;
     72/** Pointer to multibyte/wide character conversion functions. */
     73typedef __LIBC_LOCALECTYPEFUNCS *__LIBC_PLOCALECTYPEFUNCS;
     74/** Pointer to const multibyte/wide character conversion functions. */
     75typedef const __LIBC_LOCALECTYPEFUNCS *__LIBC_PCLOCALECTYPEFUNCS;
    5876
    5977/**
     
    6381{
    6482    /** All uppercased characters. */
    65     unsigned char   auchUpper[256];
     83    unsigned char           auchUpper[256];
    6684    /** All lowercased characters. */
    67     unsigned char   auchLower[256];
     85    unsigned char           auchLower[256];
    6886    /** Bit flags for every character (for isXXX() function series). */
    69     unsigned short  ausfType[256];
     87    unsigned                aufType[256];
     88
     89/* part which we don't 'expose': */
    7090    /** MBCS prefixes. Two bits per character. */
    71     unsigned char   au2MBCSPrefixs[256/4];
     91    unsigned char           au2MBCSPrefixs[256/4];
     92    /** Unicode translation. (0xffff means not translation.) */
     93    unsigned short          aucUnicode[256];
     94    /** Unicode -> SBCS conversion: 0..128. */
     95    unsigned char           auchToSBCS0To128[128];
     96    /** Unicode -> SBCS conversion: Custom regions. */
     97    struct
     98    {
     99        /** First unicode code point. */
     100        unsigned short      usStart;
     101        /** Number of entries used. */
     102        unsigned short      cChars;
     103        /** Array SBCS chars corresponding to (wc - usStart). 0 means no conversion. */
     104        unsigned char       auch[28];
     105    }                       aSBCSs[8];
     106    /** Number of aSBCS regions in use. */
     107    unsigned                cSBCSs;
     108    /** Conversion functions. */
     109    __LIBC_LOCALECTYPEFUNCS CtypeFuncs;
     110#ifdef __OS2__
    72111    /** The converter object to convert to and from selected codepage
    73112      (used with MBCS codepages only). */
    74     UconvObject     uobj;
     113    UconvObject             uobj;
    75114    /** The locale object. */
    76     LocaleObject    lobj;
     115    LocaleObject            lobj;
     116#endif
    77117    /** Non-zero if there are any MBCS prefix characters in codepage. */
    78     char            mbcs;
     118    char                    mbcs;
    79119} __LIBC_LOCALECTYPE;
    80120/** Pointer to the Ctype locale struct. */
     
    83123
    84124/**
    85  * This structure contains the flags for the default (C/POSIX) locale.
    86  */
    87 typedef struct __libc_LocaleCtypeDefault
    88 {
    89     /** Bit flags for every character (for isXXX() function series). */
    90     unsigned short  ausfType[256];
    91 } __LIBC_LOCALECTYPEDEFAULT;
    92 /** Pointer to the Ctype locale struct. */
    93 typedef __LIBC_LOCALECTYPEDEFAULT *__LIBC_PLOCALECTYPEDEFAULT;
    94 
     125 * Unicode CType data.
     126 * The structure contains information for the first 256 unicode chars.
     127 */
     128typedef struct __libc_localeWCType
     129{
     130    /** All uppercased characters. */
     131    __wchar_t       awcUpper[256];
     132    /** All lowercased characters. */
     133    __wchar_t       awcLower[256];
     134    /** Bit flags for every character (for iswXXX() function series). */
     135    unsigned        aufType[256];
     136} __LIBC_LOCALEWCTYPE;
     137/** Pointer to the Ctype unicode struct. */
     138typedef __LIBC_LOCALEWCTYPE *__LIBC_PLOCALEWCTYPE;
    95139
    96140/**
     
    101145{
    102146    /** Short month names. */
    103     char *smonths[12];
     147    char   *smonths[12];
    104148    /** Long month names. */
    105     char *lmonths[12];
     149    char   *lmonths[12];
    106150    /** Short weekday names. */
    107     char *swdays[7];
     151    char   *swdays[7];
    108152    /** Long weekday names. */
    109     char *lwdays[7];
     153    char   *lwdays[7];
    110154    /** Date and time format. */
    111     char *date_time_fmt;
     155    char   *date_time_fmt;
    112156    /** Date format. */
    113     char *date_fmt;
     157    char   *date_fmt;
    114158    /** Time format. */
    115     char *time_fmt;
     159    char   *time_fmt;
    116160    /** AM strings. */
    117     char *am;
     161    char   *am;
    118162    /** PM strings. */
    119     char *pm;
     163    char   *pm;
     164    /** AM/PM format. (T_FMT_AMPM) */
     165    char   *ampm_fmt;
     166    /** ERA */
     167    char   *era;
     168    /** ERA_D_FMT. */
     169    char   *era_date_fmt;
     170    /** ERA_D_T_FMT. */
     171    char   *era_date_time_fmt;
     172    /** ERA_T_FMT. */
     173    char   *era_time_fmt;
     174    /** ALT_DIGITS. */
     175    char   *alt_digits;
     176    /** DATESEP. */
     177    char   *datesep;
     178    /** TIMESEP. */
     179    char   *timesep;
     180    /** LISTSEP. */
     181    char   *listsep;
    120182    /** If set all the strings are consts and shall not be free()ed. */
    121     int             fConsts;
     183    int     fConsts;
    122184} __LIBC_LOCALETIME;
    123185/** Pointer to time locale data. */
     
    135197    /** The lconv structure. */
    136198    struct lconv    s;
     199    /** CRNCYSTR. */
     200    char           *pszCrncyStr;
    137201    /** Indicates that all the numeric members are readonly const strings. */
    138202    int             fNumericConsts;
     
    145209
    146210/** String collation information. */
    147 extern __LIBC_LOCALECOLLATE     __libc_gLocaleCollate;
     211extern __LIBC_LOCALECOLLATE         __libc_gLocaleCollate;
    148212/** Character case conversion tables. */
    149 extern __LIBC_LOCALECTYPE       __libc_GLocaleCtype;
     213extern __LIBC_LOCALECTYPE           __libc_GLocaleCtype;
    150214/** Character case conversion tables for the default 'C'/'POSIX' locale. */
    151 extern const __LIBC_LOCALECTYPEDEFAULT __libc_GLocaleCtypeDefault;
     215extern const __LIBC_LOCALECTYPE     __libc_GLocaleCtypeDefault;
     216/** Cached Unicode (__wchar_t) case conversion tables and flags. */
     217extern const __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype;
    152218/** Locale information structure. */
    153 extern __LIBC_LOCALELCONV       __libc_gLocaleLconv;
     219extern __LIBC_LOCALELCONV           __libc_gLocaleLconv;
    154220/** Date / time formatting rules. */
    155 extern __LIBC_LOCALETIME        __libc_gLocaleTime;
    156 
     221extern __LIBC_LOCALETIME            __libc_gLocaleTime;
     222
     223/** Macros to lock the different locale structures.
     224 * @{
     225 */
     226#define LOCALE_LOCK()               do {} while (0)
     227#define LOCALE_UNLOCK()             do {} while (0)
     228#define LOCALE_CTYPE_RW_LOCK()      do {} while (0)
     229#define LOCALE_CTYPE_RW_UNLOCK()    do {} while (0)
     230#define LOCALE_CTYPE_RW_LOCK()      do {} while (0)
     231#define LOCALE_CTYPE_RW_UNLOCK()    do {} while (0)
     232/** @} */
    157233
    158234/** Convert a string to Unicode, apply some transform and convert back. */
     
    165241extern void __libc_TranslateCodepage(const char *cp, UniChar *ucp);
    166242
     243extern int __libc_localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj);
     244
     245extern void __libc_localeFuncsSBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     246extern void __libc_localeFuncsDBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     247extern void __libc_localeFuncsMBCS(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     248extern void __libc_localeFuncsUCS2(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     249extern void __libc_localeFuncsUTF8(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     250extern void __libc_localeFuncsDefault(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     251
     252extern size_t  __libc_localeFuncsGeneric_mbsnrtowcs(size_t  (*pfnmbrtowc)(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict),
     253                                                    __wchar_t * __restrict dst, const char ** __restrict src, size_t nms, size_t len, __mbstate_t * __restrict ps);
     254extern size_t  __libc_localeFuncsGeneric_wcsnrtombs(size_t  (*pfnwcrtomb)(char * __restrict, __wchar_t, __mbstate_t * __restrict),
     255                                                    char * __restrict dst, const __wchar_t ** __restrict src, size_t nwc, size_t len, __mbstate_t * __restrict ps);
     256
     257extern void     __libc_localeFuncsNone(__LIBC_PLOCALECTYPEFUNCS pFuncs);
     258extern size_t   __libc_locale_none_mbrtowc(__wchar_t * __restrict, const char * __restrict, size_t, __mbstate_t * __restrict);
     259extern int      __libc_locale_none_mbsinit(const __mbstate_t *);
     260extern 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);
     261extern size_t   __libc_locale_none_wcrtomb(char * __restrict, __wchar_t, __mbstate_t * __restrict);
     262extern size_t   __libc_locale_none_wcsnrtombs(char * __restrict, const __wchar_t ** __restrict, size_t, size_t, __mbstate_t * __restrict);
    167263
    168264
  • trunk/src/emx/include/_ctype.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1704 r1705  
    3434__BEGIN_DECLS
    3535/**
    36  * Simplified Ctype structure for inline functions.
     36 * Simplified Ctype structures for inline functions.
    3737 */
    3838extern struct
     
    4343    unsigned char   auchLower[256];
    4444    /** Bit flags for every character (for isXXX() function series). */
    45     unsigned short  ausfType[256];
     45    unsigned        aufType[256];
    4646} __libc_GLocaleCtype;
    4747
    4848/**
    49  * Simplified Default Ctype structure for inline functions.
     49 * Simplified Default Ctype structures for inline functions.
    5050 */
    5151extern const struct
    5252{
     53    /** All uppercased characters. */
     54    unsigned char   auchUpper[256];
     55    /** All lowercased characters. */
     56    unsigned char   auchLower[256];
    5357    /** Bit flags for every character (for isXXX() function series). */
    54     unsigned short  ausfType[256];
     58    unsigned        aufType[256];
    5559} __libc_GLocaleCtypeDefault;
     60
     61/**
     62 * Unicode CType data.
     63 * The structure contains information for the first 256 unicode chars.
     64 */
     65extern const struct __libc_localeWCType
     66{
     67    /** All uppercased characters. */
     68    __wchar_t       awcUpper[256];
     69    /** All lowercased characters. */
     70    __wchar_t       awcLower[256];
     71    /** Bit flags for every character (for iswXXX() function series). */
     72    unsigned        aufType[256];
     73} __libc_GLocaleWCtype;
    5674__END_DECLS
    5775#endif /* !__InnoTekLIBC_locale_h__ */
    5876
    5977
    60 /** Bit masks for the ausfType member of __libc_GLocaleCtype
     78/** Bit masks for the aufType member of __libc_GLocaleCtype
    6179 *  and __libc_GLocaleCtypeDefault
    6280 *
    63  * @remark These have identical values to the CT_* to speed up setlocale().
     81 * @remark These have values identical values to the CT_* << 8 to speed up
     82 *         setlocale() and to make us compatible with the BSD scheme. In addition
     83 *         values C3_IDEOGRAPH and the C2_* << 24 are converted into the value. The
     84 *         screen width stuff is attempted derived from other info provided by the
     85 *         unicode libraries.
    6486 * @{
    6587 */
    66 #define __UPPER     0x0001      /** Upper case alphabetic character. */
    67 #define __LOWER     0x0002      /** Lower case alphabetic character. */
    68 #define __DIGIT     0x0004      /** Digits 0-9. */
    69 #define __SPACE     0x0008      /** White space and line ends. */
    70 #define __PUNCT     0x0010      /** Punctuation marks. */
    71 #define __CNTRL     0x0020      /** Control and format characters. */
    72 #define __BLANK     0x0040      /** Space and tab. */
    73 #define __XDIGIT    0x0080      /** Hex digits. */
    74 #define __ALPHA     0x0100      /** Letters and linguistic marks. */
    75 #define __ALNUM     0x0200      /** Alphanumeric. */
    76 #define __GRAPH     0x0400      /** All except controls and space. */
    77 #define __PRINT     0x0800      /** Everything except controls. */
    78 #define __NUMBER    0x1000      /** Integral number. */
    79 #define __SYMBOL    0x2000      /** Symbol. */
    80 #define __ASCII     0x8000      /** In standard ASCII set. */
    81 
    82 /* BSD compatability */
    83 #define _CTYPE_A    __ALPHA
    84 #define _CTYPE_C    __CNTRL
    85 #define _CTYPE_D    __DIGIT
    86 #define _CTYPE_G    __GRAPH
    87 #define _CTYPE_L    __LOWER
    88 #define _CTYPE_P    __PUNCT
    89 #define _CTYPE_S    __SPACE
    90 #define _CTYPE_U    __UPPER
    91 #define _CTYPE_X    __XDIGIT
    92 #define _CTYPE_B    __BLANK
    93 #define _CTYPE_R    __PRINT
    94 #if 0 //later
    95 #define _CTYPE_I        0x00080000L             /* Ideogram */
    96 #define _CTYPE_T        0x00100000L             /* Special */
    97 #define _CTYPE_Q        0x00200000L             /* Phonogram */
    98 
    99 #define _CTYPE_SW0      0x20000000L             /* 0 width character */
    100 #define _CTYPE_SW1      0x40000000L             /* 1 width character */
    101 #define _CTYPE_SW2      0x80000000L             /* 2 width character */
    102 #define _CTYPE_SW3      0xc0000000L             /* 3 width character */
    103 #define _CTYPE_SWM      0xe0000000L             /* Mask for screen width data */
    104 #define _CTYPE_SWS      30                      /* Bits to shift to get width */
     88#define __CT_NUM_MASK   0x000000ffU     /** Numberic value for digit to int conversion. */
     89
     90#define __CT_UPPER      0x00000100U     /** Upper case alphabetic character. */
     91#define __CT_LOWER      0x00000200U     /** Lower case alphabetic character. */
     92#define __CT_DIGIT      0x00000400U     /** Digits 0-9. */
     93#define __CT_SPACE      0x00000800U     /** White space and line ends. */
     94#define __CT_PUNCT      0x00001000U     /** Punctuation marks. */
     95#define __CT_CNTRL      0x00002000U     /** Control and format characters. */
     96#define __CT_BLANK      0x00004000U     /** Space and tab. */
     97#define __CT_XDIGIT     0x00008000U     /** Hex digits. */
     98#define __CT_ALPHA      0x00010000U     /** Letters and linguistic marks. */
     99#define __CT_ALNUM      0x00020000U     /** Alphanumeric - obsolete (__CT_ALPHA | __CT_DIGIT) is the same. */
     100#define __CT_GRAPH      0x00040000U     /** All except controls and space. */
     101#define __CT_PRINT      0x00080000U     /** Everything except controls. */
     102#define __CT_NUMBER     0x00100000U     /** Integral number. */
     103#define __CT_SYMBOL     0x00200000U     /** Symbol. */
     104#define __CT_ASCII      0x00800000U     /** In standard ASCII set. */
     105
     106#define __CT_IDEOGRAM   0x00400000U     /** Ideogram. (C3_IDEOGRAPH?) (Unused/known CT_ bit.) */
     107
     108/* #define __CT_BIDI_MASK  0x0f000000U - not implemented */     /** Bidi mask C2_*. */
     109
     110#define __CT_SCRW0      0x20000000U     /** 0 width character. (Just indicator for SW data when width is 0.) */
     111#define __CT_SCRW1      0x40000000U     /** 1 width character. */
     112#define __CT_SCRW2      0x80000000U     /** 2 width character. */
     113#define __CT_SCRW3      0xc0000000U     /** 3 width character. */
     114#define __CT_SCRW_MASK  0xe0000000U     /** Mask for screen width data. */
     115#define __CT_SCRW_SHIFT 30              /** Bits to shift to get width. */
     116
     117/** BSD compatability.
     118 * @{ */
     119#define _CTYPE_A        __CT_ALPHA
     120#define _CTYPE_C        __CT_CNTRL
     121#define _CTYPE_D        __CT_DIGIT
     122#define _CTYPE_G        __CT_GRAPH
     123#define _CTYPE_L        __CT_LOWER
     124#define _CTYPE_P        __CT_PUNCT
     125#define _CTYPE_S        __CT_SPACE
     126#define _CTYPE_U        __CT_UPPER
     127#define _CTYPE_X        __CT_XDIGIT
     128#define _CTYPE_B        __CT_BLANK
     129#define _CTYPE_R        __CT_PRINT
     130#define _CTYPE_I        __CT_IDEOGRAM
     131#if 0 /* We don't have this info :/ */
     132#define _CTYPE_T        0x00100000L             /* Special */
     133#define _CTYPE_Q        0x00200000L             /* Phonogram */
    105134#endif
    106 
    107 /** @} */
    108 
    109 
    110 __BEGIN_DECLS
    111 int ___istype(__ct_rune_t, unsigned);
    112 __ct_rune_t ___tolower(__ct_rune_t);
    113 __ct_rune_t ___toupper(__ct_rune_t);
    114 __END_DECLS
     135#define _CTYPE_SW0      __CT_SCRW0
     136#define _CTYPE_SW1      __CT_SCRW1
     137#define _CTYPE_SW2      __CT_SCRW2
     138#define _CTYPE_SW3      __CT_SCRW3
     139#define _CTYPE_SWM      __CT_SCRW_MASK
     140#define _CTYPE_SWS      __CT_SCRW_SHIFT
     141/** @} */
     142/** @} */
     143
     144
     145/** Functions for handling runes outside the 0-255 range.
     146 * @{ */
     147__BEGIN_DECLS
     148unsigned ___wctype(__wchar_t);
     149__wchar_t ___towlower(__wchar_t);
     150__wchar_t ___towupper(__wchar_t);
     151__END_DECLS
     152/** @} */
     153
    115154
    116155#if !defined(_DONT_USE_CTYPE_INLINE_) && \
    117156    (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
    118157
    119 __BEGIN_DECLS
    120 static inline int __istype(__ct_rune_t _c, unsigned _f)
    121 {
    122     return !(_c & 0xffffff00) ? (__libc_GLocaleCtype.ausfType[_c & 0xff] & (_f)) != 0 : ___istype(_c, _f);
    123 }
    124 
    125 static inline int __isctype(__ct_rune_t _c, unsigned _f)
    126 {
    127     return (__libc_GLocaleCtypeDefault.ausfType[_c & 0xff] & (_f)) != 0;
    128 }
    129 
    130 static inline int __toupper(__ct_rune_t _c)
    131 {
    132     return !(_c & 0xffffff00) ? __libc_GLocaleCtype.auchUpper[_c & 0xff] : ___toupper(_c);
    133 }
    134 
    135 static inline int __tolower(__ct_rune_t _c)
    136 {
    137     return !(_c & 0xffffff00) ? __libc_GLocaleCtype.auchLower[_c & 0xff] : ___tolower(_c);
    138 }
    139 __END_DECLS
     158/** Inlined function versions.
     159 * @{
     160 */
     161__BEGIN_DECLS
     162static inline unsigned __ctype(__ct_rune_t __ch, unsigned __f)
     163{
     164    return !((__ch) & ~0xffU)
     165        ? __libc_GLocaleCtype.aufType[(__ch)/* & 0xff*/] & (__f)
     166        : 0;
     167}
     168
     169static inline int __istype(__ct_rune_t __ch, unsigned __f)
     170{
     171    return !!__ctype((__ch), (__f));
     172}
     173
     174static inline int __isctype(__ct_rune_t __ch, unsigned __f)
     175{
     176    return !((__ch) & ~0xffU)
     177        ? !!(__libc_GLocaleCtypeDefault.aufType[(__ch)/* & 0xff*/] & (__f))
     178        : 0;
     179}
     180
     181static inline __ct_rune_t __toupper(__ct_rune_t __ch)
     182{
     183    return !((__ch) & ~0xffU)
     184        ? __libc_GLocaleCtype.auchUpper[(__ch)/* & 0xff*/]
     185        : (__ch);
     186}
     187
     188static inline __ct_rune_t __tolower(__ct_rune_t __ch)
     189{
     190    return !((__ch) & ~0xffU)
     191        ? __libc_GLocaleCtype.auchLower[(__ch)/* & 0xff*/]
     192        : (__ch);
     193}
     194
     195
     196static inline unsigned __wctype(__wint_t __wc, unsigned __f)
     197{
     198    return !((__wc) & ~0xffU)
     199        ? __libc_GLocaleWCtype.aufType[(__wc)] & (__f)
     200        : ___wctype(__wc) & (__f);
     201}
     202
     203static inline int __iswtype(__wint_t __wc, unsigned __f)
     204{
     205    return !!__wctype((__wc), (__f));
     206}
     207
     208static inline __wint_t __towupper(__wint_t __wc)
     209{
     210    return !((__wc) & ~0xffU)
     211        ? __libc_GLocaleWCtype.awcUpper[(__wc)]
     212        : ___towupper(__wc);
     213}
     214
     215static inline __wint_t __towlower(__wint_t __wc)
     216{
     217    return !((__wc) & ~0xffU)
     218        ? __libc_GLocaleWCtype.awcLower[(__wc)]
     219        : ___towlower(__wc);
     220}
     221
     222
     223static inline int __wcwidth(__wint_t __wc)
     224{
     225    if ((__wc) != 0)
     226    {
     227        unsigned __f = __wctype((__wc), __CT_SCRW_MASK | __CT_PRINT);
     228        return ((__f) & __CT_SCRW_MASK)
     229            ? ((__f) & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
     230            : ((__f) & __CT_PRINT) ? 1 : -1;
     231    }
     232    else
     233        return 0;
     234}
     235__END_DECLS
     236/** @} */
    140237
    141238#else
    142239
    143 __BEGIN_DECLS
    144 int __istype(int, unsigned);
    145 int __isctype(int, unsigned);
    146 int __toupper(int);
    147 int __tolower(int);
    148 
    149 __END_DECLS
     240/** Non-inlined function versions.
     241 * @{
     242 */
     243__BEGIN_DECLS
     244unsigned    __ctype(__ct_rune_t, unsigned);
     245int         __istype(__ct_rune_t, unsigned);
     246__ct_rune_t __isctype(__ct_rune_t, unsigned);
     247__ct_rune_t __toupper(__ct_rune_t);
     248int         __tolower(__ct_rune_t);
     249
     250unsigned    __wctype(__wint_t, unsigned);
     251int         __iswtype(__wint_t, unsigned);
     252__wint_t     __towupper(__wint_t);
     253__wint_t     __towlower(__wint_t);
     254int         __wcwidth(__wint_t);
     255__END_DECLS
     256/** @} */
    150257
    151258#endif
  • trunk/src/emx/include/ctype.h

    • Property cvs2svn:cvs-rev changed from 1.15 to 1.16
    r1704 r1705  
    44 * InnoTek LIBC - Character type querying.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
     6 * Copyright (ch) 2004 knut st. osmundsen <bird@innotek.de>
    77 *
    88 *
     
    5353
    5454#if __BSD_VISIBLE
    55 /* @todo int    digittoint(int); */
     55int     digittoint(int);
    5656int     isblank(int);
    5757int     ishexnumber(int);
    58 /* @todo int    isideogram(int); */
     58int     isideogram(int);
    5959int     isnumber(int);
    6060/* @todo int    isphonogram(int); */
    61 /* @todo int    isrune(int); */
     61int     isrune(int);
    6262/* @todo int    isspecial(int); */
    6363#endif
    6464__END_DECLS
    6565
    66 #define isalnum(c)  __istype((c), (__UPPER)|(__LOWER)|(__DIGIT))
    67 #define isalpha(c)  __istype((c), (__UPPER)|(__LOWER))
    68 #define iscntrl(c)  __istype((c), (__CNTRL))
    69 #define isgraph(c)  __istype((c), (__PUNCT)|(__UPPER)|(__LOWER)|(__DIGIT))
    70 #define islower(c)  __istype((c), (__LOWER))
    71 #define isprint(c)  __istype((c), (__PRINT))
    72 #define ispunct(c)  __istype((c), (__PUNCT))
    73 #define isspace(c)  __istype((c), (__SPACE))
    74 #define isupper(c)  __istype((c), (__UPPER))
    75 #ifdef __UNIX_CHAR_CLASS__
    76 /* BSD and some other UNIXes have non-standard definitions of these two at least. */
    77 #define isdigit(c)  __isctype((c),(__DIGIT))
    78 #define isxdigit(c) __isctype((c),(__XDIGIT))
     66#define isalnum(ch)     __istype((ch), (__CT_ALPHA)|(__CT_DIGIT))
     67#define isalpha(ch)     __istype((ch), (__CT_ALPHA))
     68#define iscntrl(ch)     __istype((ch), (__CT_CNTRL))
     69#define isgraph(ch)     __istype((ch), (__CT_GRAPH))
     70#define islower(ch)     __istype((ch), (__CT_LOWER))
     71#define isprint(ch)     __istype((ch), (__CT_PRINT))
     72#define ispunct(ch)     __istype((ch), (__CT_PUNCT))
     73#define isspace(ch)     __istype((ch), (__CT_SPACE))
     74#define isupper(ch)     __istype((ch), (__CT_UPPER))
     75#ifdef __UNIX_CHAR_CLASS__ /* BSD and some other UNIXes have non-standard definitions of these two at least. */
     76#define isdigit(ch)     __isctype((ch),(__CT_DIGIT))
     77#define isxdigit(ch)    __isctype((ch),(__CT_XDIGIT))
    7978#else
    80 #define isdigit(c)  __istype((c),(__DIGIT))
    81 #define isxdigit(c) __istype((c),(__XDIGIT))
     79#define isdigit(ch)     __istype((ch), (__CT_DIGIT))
     80#define isxdigit(ch)    __istype((ch), (__CT_XDIGIT))
    8281#endif
    83 #define tolower(c)  __tolower(c)
    84 #define toupper(c)  __toupper(c)
     82#define tolower(ch)     __tolower(ch)
     83#define toupper(ch)     __toupper(ch)
    8584
    8685#if __XSI_VISIBLE
    87 #define _toupper(c) __toupper(c)
    88 #define _tolower(c) __tolower(c)
    89 #define isascii(c)   (((c) & ~0x7F) == 0)
    90 #define toascii(c)   ((c) & 0x7F)
     86#define _toupper(ch)    __toupper(ch)
     87#define _tolower(ch)    __tolower(ch)
     88#define isascii(ch)     (((ch) & ~0x7F) == 0)
     89#define toascii(ch)     ((ch) & 0x7F)
    9190#endif
    9291
    9392#if __BSD_VISIBLE
    94 #define isblank(c)      __istype((c), (__BLANK))
    95 #define ishexnumber(c)  __istype((c), (__XDIGIT))
    96 #define isnumber(c)     __istype((c), (__DIGIT))
     93#define isblank(ch)     __istype((ch), (__CT_BLANK))
     94#define ishexnumber(ch) __istype((ch), (__CT_XDIGIT))
     95#define isideogram(ch)  __istype((ch), (__CT_IDEOGRAM))
     96#define isnumber(ch)    __istype((ch), (__CT_DIGIT))
     97#define isrune(ch)      __istype((ch), ~(__CT_NUM_MASK))
     98#define digittoint(ch)  __ctype((ch), (__CT_NUM_MASK))
    9799#endif
    98100
  • trunk/src/emx/include/stdlib.h

    • Property cvs2svn:cvs-rev changed from 1.29 to 1.30
    r1704 r1705  
    8484#define RAND_MAX        0x7fffffff
    8585
    86 extern int _mb_cur_max;                 /* bird: one underscore, not two for us. */
    87 #define MB_CUR_MAX      _mb_cur_max     /* bird: one underscore, not two for us. */
     86extern int __mb_cur_max;
     87#define MB_CUR_MAX      __mb_cur_max
    8888
    8989__BEGIN_DECLS
  • trunk/src/emx/include/sys/cdefs.h

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1704 r1705  
    3131 *
    3232 *      @(#)cdefs.h     8.8 (Berkeley) 1/9/95
    33  * $FreeBSD: src/sys/sys/cdefs.h,v 1.81 2004/04/07 04:19:49 imp Exp $
     33 * $FreeBSD: src/sys/sys/cdefs.h,v 1.84 2004/08/13 00:53:40 julian Exp $
    3434 */
    3535
     
    155155#define __pure2         __attribute__((__const__))
    156156#define __unused        __attribute__((__unused__))
     157#define __used          __attribute__((__used__))
    157158#define __packed        __attribute__((__packed__))
    158159#define __aligned(x)    __attribute__((__aligned__(x)))
     
    163164#define __pure2         __attribute__((__const__))
    164165#define __unused        __attribute__((__unused__))
     166#define __used          __attribute__((__used__))
    165167#define __packed        __attribute__((__packed__))
    166168#define __aligned(x)    __attribute__((__aligned__(x)))
    167169#define __section(x)    __attribute__((__section__(x)))
    168170#endif
     171#endif
     172
     173#if __GNUC_PREREQ__(2, 96)
     174#define __pure          __attribute__((__pure__))
     175#else
     176#define __pure
    169177#endif
    170178
     
    245253 */
    246254#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
     255#define __rangeof(type, start, end) \
     256        (__offsetof(type, end) - __offsetof(type, start))
    247257
    248258/*
     
    310320 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
    311321 * Usage:
    312  *      __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.81 2004/04/07 04:19:49 imp Exp $");
     322 *      __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.84 2004/08/13 00:53:40 julian Exp $");
    313323 */
    314324#ifndef __FBSDID
  • trunk/src/emx/include/wchar.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1704 r1705  
    11/** @file
    22 * FreeBSD 5.3
    3  * @changed bird: Disabled most of it.
     3 * @changed bird: Disabled all stream related and some other stuff we don't do yet.
    44 */
    55/*-
     
    7676#include <sys/_types.h>
    7777#include <machine/_limits.h>
    78 #if 0  /* bird */
    7978#include <_ctype.h>
    80 #endif /* bird */
    8179
    8280#ifndef _MBSTATE_T_DECLARED
     
    112110#endif
    113111
    114 #if 0 /* bird */
    115 struct __sFILE;
    116 #endif /* bird */
     112/** @todo struct __sFILE;  */
    117113struct tm;
    118114
    119115__BEGIN_DECLS
    120 #if 0 /* bird */
    121116wint_t  btowc(int);
    122 wint_t  fgetwc(struct __sFILE *);
    123 wchar_t *
    124         fgetws(wchar_t * __restrict, int, struct __sFILE * __restrict);
    125 wint_t  fputwc(wchar_t, struct __sFILE *);
    126 int     fputws(const wchar_t * __restrict, struct __sFILE * __restrict);
    127 int     fwide(struct __sFILE *, int);
    128 int     fwprintf(struct __sFILE * __restrict, const wchar_t * __restrict, ...);
    129 int     fwscanf(struct __sFILE * __restrict, const wchar_t * __restrict, ...);
    130 wint_t  getwc(struct __sFILE *);
    131 wint_t  getwchar(void);
     117/** @todo wint_t        fgetwc(struct __sFILE *); */
     118/** @todo wchar_t       *
     119        fgetws(wchar_t * __restrict, int, struct __sFILE * __restrict); */
     120/** @todo wint_t        fputwc(wchar_t, struct __sFILE *); */
     121/** @todo int   fputws(const wchar_t * __restrict, struct __sFILE * __restrict); */
     122/** @todo int   fwide(struct __sFILE *, int); */
     123/** @todo int   fwprintf(struct __sFILE * __restrict, const wchar_t * __restrict, ...); */
     124/** @todo int   fwscanf(struct __sFILE * __restrict, const wchar_t * __restrict, ...); */
     125/** @todo wint_t        getwc(struct __sFILE *); */
     126/** @todo wint_t        getwchar(void); */
    132127size_t  mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
    133 #endif /* bird */
    134128size_t  mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
    135129            mbstate_t * __restrict);
    136 #if 0 /* bird */
    137130int     mbsinit(const mbstate_t *);
    138131size_t  mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
    139132            mbstate_t * __restrict);
    140 wint_t  putwc(wchar_t, struct __sFILE *);
    141 wint_t  putwchar(wchar_t);
    142 int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
    143             ...);
    144 int     swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
    145 wint_t  ungetwc(wint_t, struct __sFILE *);
    146 int     vfwprintf(struct __sFILE * __restrict, const wchar_t * __restrict,
    147             __va_list);
    148 int     vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
    149             __va_list);
    150 int     vwprintf(const wchar_t * __restrict, __va_list);
    151 #endif /* bird */
     133/** @todo wint_t        putwc(wchar_t, struct __sFILE *); */
     134/** @todo wint_t        putwchar(wchar_t); */
     135/** @todo int   swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
     136            ...); */
     137/** @todo int   swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...); */
     138/** @todo wint_t        ungetwc(wint_t, struct __sFILE *); */
     139/** @todo int   vfwprintf(struct __sFILE * __restrict, const wchar_t * __restrict,
     140            __va_list); */
     141/** @todo int   vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
     142            __va_list); */
     143/** @todo int   vwprintf(const wchar_t * __restrict, __va_list); */
    152144size_t  wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
    153 #if 0 /* bird */
    154145wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict);
    155146wchar_t *wcschr(const wchar_t *, wchar_t) __pure;
     
    185176wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
    186177wchar_t *wmemset(wchar_t *, wchar_t, size_t);
    187 int     wprintf(const wchar_t * __restrict, ...);
    188 int     wscanf(const wchar_t * __restrict, ...);
    189 
    190 #ifndef _STDSTREAM_DECLARED
    191 extern struct __sFILE *__stdinp;
    192 extern struct __sFILE *__stdoutp;
    193 extern struct __sFILE *__stderrp;
    194 #define _STDSTREAM_DECLARED
    195 #endif
    196 
    197 #define getwc(fp)       fgetwc(fp)
    198 #define getwchar()      fgetwc(__stdinp)
    199 #define putwc(wc, fp)   fputwc(wc, fp)
    200 #define putwchar(wc)    fputwc(wc, __stdoutp)
     178/** @todo int   wprintf(const wchar_t * __restrict, ...); */
     179/** @todo int   wscanf(const wchar_t * __restrict, ...); */
     180
     181/** @todo #ifndef _STDSTREAM_DECLARED */
     182/** @todo extern struct __sFILE *__stdinp; */
     183/** @todo extern struct __sFILE *__stdoutp; */
     184/** @todo extern struct __sFILE *__stderrp; */
     185/** @todo #define       _STDSTREAM_DECLARED */
     186/** @todo #endif */
     187
     188/** @todo #define       getwc(fp)       fgetwc(fp) */
     189/** @todo #define       getwchar()      fgetwc(__stdinp) */
     190/** @todo #define       putwc(wc, fp)   fputwc(wc, fp) */
     191/** @todo #define       putwchar(wc)    fputwc(wc, __stdoutp) */
    201192
    202193#if __ISO_C_VISIBLE >= 1999
    203 int     vfwscanf(struct __sFILE * __restrict, const wchar_t * __restrict,
    204             __va_list);
    205 int     vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
    206             __va_list);
    207 int     vwscanf(const wchar_t * __restrict, __va_list);
     194/** @todo int   vfwscanf(struct __sFILE * __restrict, const wchar_t * __restrict,
     195            __va_list); */
     196/** @todo int   vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
     197            __va_list); */
     198/** @todo int   vwscanf(const wchar_t * __restrict, __va_list); */
    208199float   wcstof(const wchar_t * __restrict, wchar_t ** __restrict);
    209200long double
     
    226217
    227218#if __BSD_VISIBLE
    228 wchar_t *fgetwln(struct __sFILE * __restrict, size_t * __restrict);
     219/** @todo wchar_t       *fgetwln(struct __sFILE * __restrict, size_t * __restrict); */
    229220size_t  mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
    230221            size_t, mbstate_t * __restrict);
     
    234225size_t  wcslcpy(wchar_t *, const wchar_t *, size_t);
    235226#endif
    236 #endif /* bird */
    237227__END_DECLS
    238228
  • trunk/src/emx/include/wctype.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1704 r1705  
    11/** @file
    22 * FreeBSD 5.3
    3  * @changed bird: Disabled most of it.
     3 * @changed bird: hid a few bsd things and changed it to __isw* & __tow*.
     4 *                No __iscwtype on OS/2 since it's all unicode.
     5 * @remark  Take greate care when merging new versions into this file.
    46 */
    57/*-
     
    6365int     iswalnum(wint_t);
    6466int     iswalpha(wint_t);
    65 #if 0 /* bird */
    6667int     iswblank(wint_t);
    6768int     iswcntrl(wint_t);
    68 #endif /* bird */
    6969int     iswctype(wint_t, wctype_t);
    70 #if 0 /* bird */
    7170int     iswdigit(wint_t);
    7271int     iswgraph(wint_t);
    73 #endif /* bird */
    7472int     iswlower(wint_t);
    75 #if 0 /* bird */
    7673int     iswprint(wint_t);
    7774int     iswpunct(wint_t);
    7875int     iswspace(wint_t);
    79 #endif /* bird */
    8076int     iswupper(wint_t);
    81 #if 0 /* bird */
    8277int     iswxdigit(wint_t);
    8378wint_t  towctrans(wint_t, wctrans_t);
    84 #endif /* bird */
    8579wint_t  towlower(wint_t);
    8680wint_t  towupper(wint_t);
    87 #if 0 /* bird */
    8881wctrans_t
    8982        wctrans(const char *);
    90 #endif /* bird */
    9183wctype_t
    9284        wctype(const char *);
    93 #if 0 /* bird */
    9485
    9586#if __BSD_VISIBLE
     
    9889wint_t  iswideogram(wint_t);
    9990wint_t  iswnumber(wint_t);
    100 wint_t  iswphonogram(wint_t);
     91/** @todo wint_t        iswphonogram(wint_t); */
    10192wint_t  iswrune(wint_t);
    102 wint_t  iswspecial(wint_t);
    103 wint_t  nextwctype(wint_t, wctype_t);
     93/** @todo wint_t        iswspecial(wint_t); */
     94/** @todo wint_t        nextwctype(wint_t, wctype_t); */
    10495#endif
    105 #endif /* bird */
    10696__END_DECLS
    10797
    108 #define iswalnum(wc)            __istype((wc), _CTYPE_A|_CTYPE_D)
    109 #define iswalpha(wc)            __istype((wc), _CTYPE_A)
    110 #if 0 /* bird */
    111 #define iswblank(wc)            __istype((wc), _CTYPE_B)
    112 #define iswcntrl(wc)            __istype((wc), _CTYPE_C)
    113 #endif /* bird */
    114 #define iswctype(wc, charclass) __istype((wc), (charclass))
    115 #if 0 /* bird */
    116 #define iswdigit(wc)            __isctype((wc), _CTYPE_D)
    117 #define iswgraph(wc)            __istype((wc), _CTYPE_G)
    118 #endif /* bird */
    119 #define iswlower(wc)            __istype((wc), _CTYPE_L)
    120 #if 0 /* bird */
    121 #define iswprint(wc)            __istype((wc), _CTYPE_R)
    122 #define iswpunct(wc)            __istype((wc), _CTYPE_P)
    123 #define iswspace(wc)            __istype((wc), _CTYPE_S)
    124 #endif /* bird */
    125 #define iswupper(wc)            __istype((wc), _CTYPE_U)
    126 #if 0 /* bird */
    127 #define iswxdigit(wc)           __isctype((wc), _CTYPE_X)
    128 #endif /* bird */
    129 #define towlower(wc)            __tolower(wc)
    130 #define towupper(wc)            __toupper(wc)
    131 #if 0 /* bird */
     98#define iswalnum(wc)            __iswtype((wc), _CTYPE_A|_CTYPE_D)
     99#define iswalpha(wc)            __iswtype((wc), _CTYPE_A)
     100#define iswblank(wc)            __iswtype((wc), _CTYPE_B)
     101#define iswcntrl(wc)            __iswtype((wc), _CTYPE_C)
     102#define iswctype(wc, charclass) __iswtype((wc), (charclass))
     103#define iswdigit(wc)            __iswtype((wc), _CTYPE_D)
     104#define iswgraph(wc)            __iswtype((wc), _CTYPE_G)
     105#define iswlower(wc)            __iswtype((wc), _CTYPE_L)
     106#define iswprint(wc)            __iswtype((wc), _CTYPE_R)
     107#define iswpunct(wc)            __iswtype((wc), _CTYPE_P)
     108#define iswspace(wc)            __iswtype((wc), _CTYPE_S)
     109#define iswupper(wc)            __iswtype((wc), _CTYPE_U)
     110
     111#define iswxdigit(wc)           __iswtype((wc), _CTYPE_X)
     112#define towlower(wc)            __towlower(wc)
     113#define towupper(wc)            __towupper(wc)
    132114
    133115#if __BSD_VISIBLE
    134116#define iswascii(wc)            (((wc) & ~0x7F) == 0)
    135 #define iswhexnumber(wc)        __istype((wc), _CTYPE_X)
    136 #define iswideogram(wc)         __istype((wc), _CTYPE_I)
    137 #define iswnumber(wc)           __istype((wc), _CTYPE_D)
    138 #define iswphonogram(wc)        __istype((wc), _CTYPE_Q)
    139 #define iswrune(wc)             __istype((wc), 0xFFFFFF00L)
    140 #define iswspecial(wc)          __istype((wc), _CTYPE_T)
     117#define iswhexnumber(wc)        __iswtype((wc), _CTYPE_X)
     118#define iswideogram(wc)         __iswtype((wc), _CTYPE_I)
     119#define iswnumber(wc)           __iswtype((wc), _CTYPE_D)
     120/** @todo #define       iswphonogram(wc)        __iswtype((wc), _CTYPE_Q) */
     121#define iswrune(wc)             __iswtype((wc), 0xFFFFFF00L)
     122/** @todo #define       iswspecial(wc)          __iswtype((wc), _CTYPE_T) */
    141123#endif
    142 #endif /* bird */
     124
    143125#endif          /* _WCTYPE_H_ */
Note: See TracChangeset for help on using the changeset viewer.