run-tests.sh: use --no-symlinks
[msysgit.git] / mingw / include / ctype.h
blob6404b16221e74b6eb8616fb0016dc99555c67a57
1 /*
2 * ctype.h
3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
7 * Functions for testing character types and converting characters.
9 */
11 #ifndef _CTYPE_H_
12 #define _CTYPE_H_
14 /* All the headers include this file. */
15 #include <_mingw.h>
17 #define __need_wchar_t
18 #define __need_wint_t
19 #ifndef RC_INVOKED
20 #include <stddef.h>
21 #endif /* Not RC_INVOKED */
25 * The following flags are used to tell iswctype and _isctype what character
26 * types you are looking for.
28 #define _UPPER 0x0001
29 #define _LOWER 0x0002
30 #define _DIGIT 0x0004
31 #define _SPACE 0x0008 /* HT LF VT FF CR SP */
32 #define _PUNCT 0x0010
33 #define _CONTROL 0x0020
34 /* _BLANK is set for SP and non-ASCII horizontal space chars (eg,
35 "no-break space", 0xA0, in CP1250) but not for HT. */
36 #define _BLANK 0x0040
37 #define _HEX 0x0080
38 #define _LEADBYTE 0x8000
40 #define _ALPHA 0x0103
42 #ifndef RC_INVOKED
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
48 _CRTIMP int __cdecl isalnum(int);
49 _CRTIMP int __cdecl isalpha(int);
50 _CRTIMP int __cdecl iscntrl(int);
51 _CRTIMP int __cdecl isdigit(int);
52 _CRTIMP int __cdecl isgraph(int);
53 _CRTIMP int __cdecl islower(int);
54 _CRTIMP int __cdecl isprint(int);
55 _CRTIMP int __cdecl ispunct(int);
56 _CRTIMP int __cdecl isspace(int);
57 _CRTIMP int __cdecl isupper(int);
58 _CRTIMP int __cdecl isxdigit(int);
60 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
61 || !defined __STRICT_ANSI__
62 int __cdecl isblank (int);
63 #endif
65 #ifndef __STRICT_ANSI__
66 _CRTIMP int __cdecl _isctype (int, int);
67 #endif
69 /* These are the ANSI versions, with correct checking of argument */
70 _CRTIMP int __cdecl tolower(int);
71 _CRTIMP int __cdecl toupper(int);
74 * NOTE: The above are not old name type wrappers, but functions exported
75 * explicitly by MSVCRT/CRTDLL. However, underscored versions are also
76 * exported.
78 #ifndef __STRICT_ANSI__
80 * These are the cheap non-std versions: The return values are undefined
81 * if the argument is not ASCII char or is not of appropriate case
82 */
83 _CRTIMP int __cdecl _tolower(int);
84 _CRTIMP int __cdecl _toupper(int);
85 #endif
87 /* Also defined in stdlib.h */
88 #ifndef MB_CUR_MAX
89 #ifdef __DECLSPEC_SUPPORTED
90 # ifdef __MSVCRT__
91 # define MB_CUR_MAX __mb_cur_max
92 __MINGW_IMPORT int __mb_cur_max;
93 # else /* not __MSVCRT */
94 # define MB_CUR_MAX __mb_cur_max_dll
95 __MINGW_IMPORT int __mb_cur_max_dll;
96 # endif /* not __MSVCRT */
98 #else /* ! __DECLSPEC_SUPPORTED */
99 # ifdef __MSVCRT__
100 extern int* _imp____mbcur_max;
101 # define MB_CUR_MAX (*_imp____mb_cur_max)
102 # else /* not __MSVCRT */
103 extern int* _imp____mbcur_max_dll;
104 # define MB_CUR_MAX (*_imp____mb_cur_max_dll)
105 # endif /* not __MSVCRT */
106 #endif /* __DECLSPEC_SUPPORTED */
107 #endif /* MB_CUR_MAX */
110 #ifdef __DECLSPEC_SUPPORTED
111 __MINGW_IMPORT unsigned short _ctype[];
112 # ifdef __MSVCRT__
113 __MINGW_IMPORT unsigned short* _pctype;
114 # else /* CRTDLL */
115 __MINGW_IMPORT unsigned short* _pctype_dll;
116 # define _pctype _pctype_dll
117 # endif
119 #else /* __DECLSPEC_SUPPORTED */
120 extern unsigned short** _imp___ctype;
121 #define _ctype (*_imp___ctype)
122 # ifdef __MSVCRT__
123 extern unsigned short** _imp___pctype;
124 # define _pctype (*_imp___pctype)
125 # else /* CRTDLL */
126 extern unsigned short** _imp___pctype_dll;
127 # define _pctype (*_imp___pctype_dll)
128 # endif /* CRTDLL */
129 #endif /* __DECLSPEC_SUPPORTED */
132 * Use inlines here rather than macros, because macros will upset
133 * C++ usage (eg, ::isalnum), and so usually get undefined
135 * According to standard for SB chars, these function are defined only
136 * for input values representable by unsigned char or EOF.
137 * Thus, there is no range test.
138 * This reproduces behaviour of MSVCRT.dll lib implemention for SB chars.
140 * If no MB char support is needed, these can be simplified even
141 * more by command line define -DMB_CUR_MAX=1. The compiler will then
142 * optimise away the constant condition.
145 #if ! (defined (__NO_INLINE__) || defined (__NO_CTYPE_INLINES) \
146 || defined (__STRICT_ANSI__))
148 /* use simple lookup if SB locale, else _isctype() */
149 #define __ISCTYPE(c, mask) (MB_CUR_MAX == 1 ? (_pctype[c] & mask) : _isctype(c, mask))
150 __CRT_INLINE int __cdecl isalnum(int c) {return __ISCTYPE(c, (_ALPHA|_DIGIT));}
151 __CRT_INLINE int __cdecl isalpha(int c) {return __ISCTYPE(c, _ALPHA);}
152 __CRT_INLINE int __cdecl iscntrl(int c) {return __ISCTYPE(c, _CONTROL);}
153 __CRT_INLINE int __cdecl isdigit(int c) {return __ISCTYPE(c, _DIGIT);}
154 __CRT_INLINE int __cdecl isgraph(int c) {return __ISCTYPE(c, (_PUNCT|_ALPHA|_DIGIT));}
155 __CRT_INLINE int __cdecl islower(int c) {return __ISCTYPE(c, _LOWER);}
156 __CRT_INLINE int __cdecl isprint(int c) {return __ISCTYPE(c, (_BLANK|_PUNCT|_ALPHA|_DIGIT));}
157 __CRT_INLINE int __cdecl ispunct(int c) {return __ISCTYPE(c, _PUNCT);}
158 __CRT_INLINE int __cdecl isspace(int c) {return __ISCTYPE(c, _SPACE);}
159 __CRT_INLINE int __cdecl isupper(int c) {return __ISCTYPE(c, _UPPER);}
160 __CRT_INLINE int __cdecl isxdigit(int c) {return __ISCTYPE(c, _HEX);}
162 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
163 || !defined __STRICT_ANSI__
164 __CRT_INLINE int __cdecl isblank (int c)
165 {return (__ISCTYPE(c, _BLANK) || c == '\t');}
166 #endif
168 /* these reproduce behaviour of lib underscored versions */
169 __CRT_INLINE int __cdecl _tolower(int c) {return ( c -'A'+'a');}
170 __CRT_INLINE int __cdecl _toupper(int c) {return ( c -'a'+'A');}
172 /* TODO? Is it worth inlining ANSI tolower, toupper? Probably only
173 if we only want C-locale. */
175 #endif /* _NO_CTYPE_INLINES */
177 /* Wide character equivalents */
179 #ifndef WEOF
180 #define WEOF (wchar_t)(0xFFFF)
181 #endif
183 #ifndef _WCTYPE_T_DEFINED
184 typedef wchar_t wctype_t;
185 #define _WCTYPE_T_DEFINED
186 #endif
188 _CRTIMP int __cdecl iswalnum(wint_t);
189 _CRTIMP int __cdecl iswalpha(wint_t);
190 _CRTIMP int __cdecl iswascii(wint_t);
191 _CRTIMP int __cdecl iswcntrl(wint_t);
192 _CRTIMP int __cdecl iswctype(wint_t, wctype_t);
193 _CRTIMP int __cdecl is_wctype(wint_t, wctype_t); /* Obsolete! */
194 _CRTIMP int __cdecl iswdigit(wint_t);
195 _CRTIMP int __cdecl iswgraph(wint_t);
196 _CRTIMP int __cdecl iswlower(wint_t);
197 _CRTIMP int __cdecl iswprint(wint_t);
198 _CRTIMP int __cdecl iswpunct(wint_t);
199 _CRTIMP int __cdecl iswspace(wint_t);
200 _CRTIMP int __cdecl iswupper(wint_t);
201 _CRTIMP int __cdecl iswxdigit(wint_t);
203 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
204 || !defined __STRICT_ANSI__ || defined __cplusplus
205 int __cdecl iswblank (wint_t);
206 #endif
208 /* Older MS docs uses wchar_t for arg and return type, while newer
209 online MS docs say arg is wint_t and return is int.
210 ISO C uses wint_t for both. */
211 _CRTIMP wint_t __cdecl towlower (wint_t);
212 _CRTIMP wint_t __cdecl towupper (wint_t);
214 _CRTIMP int __cdecl isleadbyte (int);
216 /* Also in wctype.h */
217 #if ! (defined (__NO_INLINE__) || defined(__NO_CTYPE_INLINES) \
218 || defined(__WCTYPE_INLINES_DEFINED))
219 #define __WCTYPE_INLINES_DEFINED
220 __CRT_INLINE int __cdecl iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));}
221 __CRT_INLINE int __cdecl iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));}
222 __CRT_INLINE int __cdecl iswascii(wint_t wc) {return ((wc & ~0x7F) ==0);}
223 __CRT_INLINE int __cdecl iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));}
224 __CRT_INLINE int __cdecl iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));}
225 __CRT_INLINE int __cdecl iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));}
226 __CRT_INLINE int __cdecl iswlower(wint_t wc) {return (iswctype(wc,_LOWER));}
227 __CRT_INLINE int __cdecl iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));}
228 __CRT_INLINE int __cdecl iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));}
229 __CRT_INLINE int __cdecl iswspace(wint_t wc) {return (iswctype(wc,_SPACE));}
230 __CRT_INLINE int __cdecl iswupper(wint_t wc) {return (iswctype(wc,_UPPER));}
231 __CRT_INLINE int __cdecl iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));}
232 __CRT_INLINE int __cdecl isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);}
233 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
234 || !defined __STRICT_ANSI__ || defined __cplusplus
235 __CRT_INLINE int __cdecl iswblank (wint_t wc)
236 {return (iswctype(wc,_BLANK) || wc == L'\t');}
237 #endif
239 #endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */
241 #ifndef __STRICT_ANSI__
242 int __cdecl __isascii (int);
243 int __cdecl __toascii (int);
244 int __cdecl __iscsymf (int); /* Valid first character in C symbol */
245 int __cdecl __iscsym (int); /* Valid character in C symbol (after first) */
247 #if !(defined (__NO_INLINE__) || defined (__NO_CTYPE_INLINES))
248 __CRT_INLINE int __cdecl __isascii(int c) {return ((c & ~0x7F) == 0);}
249 __CRT_INLINE int __cdecl __toascii(int c) {return (c & 0x7F);}
250 __CRT_INLINE int __cdecl __iscsymf(int c) {return (isalpha(c) || (c == '_'));}
251 __CRT_INLINE int __cdecl __iscsym(int c) {return (isalnum(c) || (c == '_'));}
252 #endif /* __NO_CTYPE_INLINES */
254 #ifndef _NO_OLDNAMES
255 /* Not _CRTIMP */
256 int __cdecl isascii (int);
257 int __cdecl toascii (int);
258 int __cdecl iscsymf (int);
259 int __cdecl iscsym (int);
260 #endif /* Not _NO_OLDNAMES */
262 #endif /* Not __STRICT_ANSI__ */
264 #ifdef __cplusplus
266 #endif
268 #endif /* Not RC_INVOKED */
270 #endif /* Not _CTYPE_H_ */