Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _INC_CTYPE
      7 #define _INC_CTYPE
      8 
      9 #include <crtdefs.h>
     10 
     11 #ifdef __cplusplus
     12 extern "C" {
     13 #endif
     14 
     15 #ifndef WEOF
     16 #define WEOF (wint_t)(0xFFFF)
     17 #endif
     18 
     19 #ifndef _CRT_CTYPEDATA_DEFINED
     20 #define _CRT_CTYPEDATA_DEFINED
     21 #ifndef _CTYPE_DISABLE_MACROS
     22 
     23 #ifndef __PCTYPE_FUNC
     24 #define __PCTYPE_FUNC __pctype_func()
     25 #ifdef _MSVCRT_
     26 #define __pctype_func()	(_pctype)
     27 #else
     28 #define __pctype_func()	(* __MINGW_IMP_SYMBOL(_pctype))
     29 #endif
     30 #endif
     31 
     32 #ifndef _pctype
     33 #ifdef _MSVCRT_
     34   extern unsigned short *_pctype;
     35 #else
     36   extern unsigned short ** __MINGW_IMP_SYMBOL(_pctype);
     37 #define _pctype (* __MINGW_IMP_SYMBOL(_pctype))
     38 #endif
     39 #endif
     40 
     41 #endif
     42 #endif
     43 
     44 #ifndef _CRT_WCTYPEDATA_DEFINED
     45 #define _CRT_WCTYPEDATA_DEFINED
     46 #ifndef _CTYPE_DISABLE_MACROS
     47 #ifndef _wctype
     48 #ifdef _MSVCRT_
     49   extern unsigned short *_wctype;
     50 #else
     51   extern unsigned short ** __MINGW_IMP_SYMBOL(_wctype);
     52 #define _wctype (* __MINGW_IMP_SYMBOL(_wctype))
     53 #endif
     54 #endif
     55 #ifdef _MSVCRT_
     56 #define __pwctype_func() (_pwctype)
     57 #ifndef _pwctype
     58   extern unsigned short *_pwctype;
     59 #endif
     60 #else
     61 #define __pwctype_func() (* __MINGW_IMP_SYMBOL(_pwctype))
     62 #ifndef _pwctype
     63   extern unsigned short ** __MINGW_IMP_SYMBOL(_pwctype);
     64 #define _pwctype (* __MINGW_IMP_SYMBOL(_pwctype))
     65 #endif
     66 #endif
     67 #endif
     68 #endif
     69 
     70   /* CRT stuff */
     71 #if 1
     72   extern const unsigned char __newclmap[];
     73   extern const unsigned char __newcumap[];
     74   extern pthreadlocinfo __ptlocinfo;
     75   extern pthreadmbcinfo __ptmbcinfo;
     76   extern int __globallocalestatus;
     77   extern int __locale_changed;
     78   extern struct threadlocaleinfostruct __initiallocinfo;
     79   extern _locale_tstruct __initiallocalestructinfo;
     80   pthreadlocinfo __cdecl __updatetlocinfo(void);
     81   pthreadmbcinfo __cdecl __updatetmbcinfo(void);
     82 #endif
     83 
     84 #define _UPPER 0x1
     85 #define _LOWER 0x2
     86 #define _DIGIT 0x4
     87 #define _SPACE 0x8
     88 
     89 #define _PUNCT 0x10
     90 #define _CONTROL 0x20
     91 #define _BLANK 0x40
     92 #define _HEX 0x80
     93 
     94 #define _LEADBYTE 0x8000
     95 #define _ALPHA (0x0100|_UPPER|_LOWER)
     96 
     97 #ifndef _CTYPE_DEFINED
     98 #define _CTYPE_DEFINED
     99 
    100   _CRTIMP int __cdecl _isctype(int _C,int _Type);
    101   _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
    102   _CRTIMP int __cdecl isalpha(int _C);
    103   _CRTIMP int __cdecl _isalpha_l(int _C,_locale_t _Locale);
    104   _CRTIMP int __cdecl isupper(int _C);
    105   _CRTIMP int __cdecl _isupper_l(int _C,_locale_t _Locale);
    106   _CRTIMP int __cdecl islower(int _C);
    107   _CRTIMP int __cdecl _islower_l(int _C,_locale_t _Locale);
    108   _CRTIMP int __cdecl isdigit(int _C);
    109   _CRTIMP int __cdecl _isdigit_l(int _C,_locale_t _Locale);
    110   _CRTIMP int __cdecl isxdigit(int _C);
    111   _CRTIMP int __cdecl _isxdigit_l(int _C,_locale_t _Locale);
    112   _CRTIMP int __cdecl isspace(int _C);
    113   _CRTIMP int __cdecl _isspace_l(int _C,_locale_t _Locale);
    114   _CRTIMP int __cdecl ispunct(int _C);
    115   _CRTIMP int __cdecl _ispunct_l(int _C,_locale_t _Locale);
    116   _CRTIMP int __cdecl isalnum(int _C);
    117   _CRTIMP int __cdecl _isalnum_l(int _C,_locale_t _Locale);
    118   _CRTIMP int __cdecl isprint(int _C);
    119   _CRTIMP int __cdecl _isprint_l(int _C,_locale_t _Locale);
    120   _CRTIMP int __cdecl isgraph(int _C);
    121   _CRTIMP int __cdecl _isgraph_l(int _C,_locale_t _Locale);
    122   _CRTIMP int __cdecl iscntrl(int _C);
    123   _CRTIMP int __cdecl _iscntrl_l(int _C,_locale_t _Locale);
    124   _CRTIMP int __cdecl toupper(int _C);
    125   _CRTIMP int __cdecl tolower(int _C);
    126   _CRTIMP int __cdecl _tolower(int _C);
    127   _CRTIMP int __cdecl _tolower_l(int _C,_locale_t _Locale);
    128   _CRTIMP int __cdecl _toupper(int _C);
    129   _CRTIMP int __cdecl _toupper_l(int _C,_locale_t _Locale);
    130   _CRTIMP int __cdecl __isascii(int _C);
    131   _CRTIMP int __cdecl __toascii(int _C);
    132   _CRTIMP int __cdecl __iscsymf(int _C);
    133   _CRTIMP int __cdecl __iscsym(int _C);
    134 
    135 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined (NO_OLDNAMES) || defined (__cplusplus)
    136 int __cdecl isblank(int _C);
    137 #endif
    138 #endif
    139 
    140 #ifndef _WCTYPE_DEFINED
    141 #define _WCTYPE_DEFINED
    142 
    143   int __cdecl iswalpha(wint_t _C);
    144   _CRTIMP int __cdecl _iswalpha_l(wint_t _C,_locale_t _Locale);
    145   int __cdecl iswupper(wint_t _C);
    146   _CRTIMP int __cdecl _iswupper_l(wint_t _C,_locale_t _Locale);
    147   int __cdecl iswlower(wint_t _C);
    148   _CRTIMP int __cdecl _iswlower_l(wint_t _C,_locale_t _Locale);
    149   int __cdecl iswdigit(wint_t _C);
    150   _CRTIMP int __cdecl _iswdigit_l(wint_t _C,_locale_t _Locale);
    151   int __cdecl iswxdigit(wint_t _C);
    152   _CRTIMP int __cdecl _iswxdigit_l(wint_t _C,_locale_t _Locale);
    153   int __cdecl iswspace(wint_t _C);
    154   _CRTIMP int __cdecl _iswspace_l(wint_t _C,_locale_t _Locale);
    155   int __cdecl iswpunct(wint_t _C);
    156   _CRTIMP int __cdecl _iswpunct_l(wint_t _C,_locale_t _Locale);
    157   int __cdecl iswalnum(wint_t _C);
    158   _CRTIMP int __cdecl _iswalnum_l(wint_t _C,_locale_t _Locale);
    159   int __cdecl iswprint(wint_t _C);
    160   _CRTIMP int __cdecl _iswprint_l(wint_t _C,_locale_t _Locale);
    161   int __cdecl iswgraph(wint_t _C);
    162   _CRTIMP int __cdecl _iswgraph_l(wint_t _C,_locale_t _Locale);
    163   int __cdecl iswcntrl(wint_t _C);
    164   _CRTIMP int __cdecl _iswcntrl_l(wint_t _C,_locale_t _Locale);
    165   int __cdecl iswascii(wint_t _C);
    166   int __cdecl isleadbyte(int _C);
    167   _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
    168   wint_t __cdecl towupper(wint_t _C);
    169   _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t _Locale);
    170   wint_t __cdecl towlower(wint_t _C);
    171   _CRTIMP wint_t __cdecl _towlower_l(wint_t _C,_locale_t _Locale);
    172   int __cdecl iswctype(wint_t _C,wctype_t _Type);
    173   _CRTIMP int __cdecl _iswctype_l(wint_t _C,wctype_t _Type,_locale_t _Locale);
    174   _CRTIMP int __cdecl __iswcsymf(wint_t _C);
    175   _CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
    176   _CRTIMP int __cdecl __iswcsym(wint_t _C);
    177   _CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
    178   int __cdecl is_wctype(wint_t _C,wctype_t _Type);
    179 
    180 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined (NO_OLDNAMES)
    181 int __cdecl iswblank(wint_t _C);
    182 #endif
    183 #endif
    184 
    185 #ifndef _CTYPE_DISABLE_MACROS
    186 
    187 #ifndef MB_CUR_MAX
    188 #define MB_CUR_MAX ___mb_cur_max_func()
    189 #ifndef __mb_cur_max
    190 #ifdef _MSVCRT_
    191   extern int __mb_cur_max;
    192 #define __mb_cur_max	__mb_cur_max
    193 #else
    194   extern int * __MINGW_IMP_SYMBOL(__mb_cur_max);
    195 #define __mb_cur_max	(* __MINGW_IMP_SYMBOL(__mb_cur_max))
    196 #endif
    197 #endif
    198 #define ___mb_cur_max_func() (__mb_cur_max)
    199 #endif
    200 
    201 #define __chvalidchk(a,b) (__PCTYPE_FUNC[(a)] & (b))
    202 #define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? __chvalidchk(_Char,_Flag) : ((_locale_t)_Locale)->locinfo->pctype[_Char] & (_Flag))
    203 #define _ischartype_l(_Char,_Flag,_Locale) (((_Locale)!=NULL && (((_locale_t)(_Locale))->locinfo->mb_cur_max) > 1) ? _isctype_l(_Char,(_Flag),_Locale) : _chvalidchk_l(_Char,_Flag,_Locale))
    204 #define _isalpha_l(_Char,_Locale) _ischartype_l(_Char,_ALPHA,_Locale)
    205 #define _isupper_l(_Char,_Locale) _ischartype_l(_Char,_UPPER,_Locale)
    206 #define _islower_l(_Char,_Locale) _ischartype_l(_Char,_LOWER,_Locale)
    207 #define _isdigit_l(_Char,_Locale) _ischartype_l(_Char,_DIGIT,_Locale)
    208 #define _isxdigit_l(_Char,_Locale) _ischartype_l(_Char,_HEX,_Locale)
    209 #define _isspace_l(_Char,_Locale) _ischartype_l(_Char,_SPACE,_Locale)
    210 #define _ispunct_l(_Char,_Locale) _ischartype_l(_Char,_PUNCT,_Locale)
    211 #define _isalnum_l(_Char,_Locale) _ischartype_l(_Char,_ALPHA|_DIGIT,_Locale)
    212 #define _isprint_l(_Char,_Locale) _ischartype_l(_Char,_BLANK|_PUNCT|_ALPHA|_DIGIT,_Locale)
    213 #define _isgraph_l(_Char,_Locale) _ischartype_l(_Char,_PUNCT|_ALPHA|_DIGIT,_Locale)
    214 #define _iscntrl_l(_Char,_Locale) _ischartype_l(_Char,_CONTROL,_Locale)
    215 #define _tolower(_Char) ((_Char)-'A'+'a')
    216 #define _toupper(_Char) ((_Char)-'a'+'A')
    217 #define __isascii(_Char) ((unsigned)(_Char) < 0x80)
    218 #define __toascii(_Char) ((_Char) & 0x7f)
    219 
    220 #ifndef _WCTYPE_INLINE_DEFINED
    221 #define _WCTYPE_INLINE_DEFINED
    222 
    223 #undef _CRT_WCTYPE_NOINLINE
    224 #ifndef __cplusplus
    225 #define iswalpha(_c) (iswctype(_c,_ALPHA))
    226 #define iswupper(_c) (iswctype(_c,_UPPER))
    227 #define iswlower(_c) (iswctype(_c,_LOWER))
    228 #define iswdigit(_c) (iswctype(_c,_DIGIT))
    229 #define iswxdigit(_c) (iswctype(_c,_HEX))
    230 #define iswspace(_c) (iswctype(_c,_SPACE))
    231 #define iswpunct(_c) (iswctype(_c,_PUNCT))
    232 #define iswalnum(_c) (iswctype(_c,_ALPHA|_DIGIT))
    233 #define iswprint(_c) (iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT))
    234 #define iswgraph(_c) (iswctype(_c,_PUNCT|_ALPHA|_DIGIT))
    235 #define iswcntrl(_c) (iswctype(_c,_CONTROL))
    236 #define iswascii(_c) ((unsigned)(_c) < 0x80)
    237 #define _iswalpha_l(_c,_p) (_iswctype_l(_c,_ALPHA,_p))
    238 #define _iswupper_l(_c,_p) (_iswctype_l(_c,_UPPER,_p))
    239 #define _iswlower_l(_c,_p) (_iswctype_l(_c,_LOWER,_p))
    240 #define _iswdigit_l(_c,_p) (_iswctype_l(_c,_DIGIT,_p))
    241 #define _iswxdigit_l(_c,_p) (_iswctype_l(_c,_HEX,_p))
    242 #define _iswspace_l(_c,_p) (_iswctype_l(_c,_SPACE,_p))
    243 #define _iswpunct_l(_c,_p) (_iswctype_l(_c,_PUNCT,_p))
    244 #define _iswalnum_l(_c,_p) (_iswctype_l(_c,_ALPHA|_DIGIT,_p))
    245 #define _iswprint_l(_c,_p) (_iswctype_l(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT,_p))
    246 #define _iswgraph_l(_c,_p) (_iswctype_l(_c,_PUNCT|_ALPHA|_DIGIT,_p))
    247 #define _iswcntrl_l(_c,_p) (_iswctype_l(_c,_CONTROL,_p))
    248 #endif
    249 #endif
    250 
    251 #define __iscsymf(_c) (isalpha(_c) || ((_c)=='_'))
    252 #define __iscsym(_c) (isalnum(_c) || ((_c)=='_'))
    253 #define __iswcsymf(_c) (iswalpha(_c) || ((_c)=='_'))
    254 #define __iswcsym(_c) (iswalnum(_c) || ((_c)=='_'))
    255 #define _iscsymf_l(_c,_p) (_isalpha_l(_c,_p) || ((_c)=='_'))
    256 #define _iscsym_l(_c,_p) (_isalnum_l(_c,_p) || ((_c)=='_'))
    257 #define _iswcsymf_l(_c,_p) (_iswalpha_l(_c,_p) || ((_c)=='_'))
    258 #define _iswcsym_l(_c,_p) (_iswalnum_l(_c,_p) || ((_c)=='_'))
    259 #endif
    260 
    261 #ifndef	NO_OLDNAMES
    262 #ifndef _CTYPE_DEFINED
    263   int __cdecl isascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    264   int __cdecl toascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    265   int __cdecl iscsymf(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    266   int __cdecl iscsym(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
    267 #else
    268 #define isascii __isascii
    269 #define toascii __toascii
    270 #define iscsymf __iscsymf
    271 #define iscsym __iscsym
    272 #endif
    273 #endif
    274 
    275 #ifdef __cplusplus
    276 }
    277 #endif
    278 #endif
    279