Slightly improve keyboard tracking in combobox.
[wine/testsucceed.git] / dlls / msvcrt / ctype.c
blob7d001ee244bef1a6c981d69a2e5fa9fc71858847
1 /*
2 * msvcrt.dll ctype functions
4 * Copyright 2000 Jon Griffiths
5 */
6 #include "msvcrt.h"
8 #include "msvcrt/ctype.h"
10 DEFAULT_DEBUG_CHANNEL(msvcrt);
12 /* Some abbreviations to make the following table readable */
13 #define _C_ _CONTROL
14 #define _S_ _SPACE
15 #define _P_ _PUNCT
16 #define _D_ _DIGIT
17 #define _H_ _HEX
18 #define _U_ _UPPER
19 #define _L_ _LOWER
21 WORD MSVCRT__ctype [257] = {
22 0, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_, _S_|_C_,
23 _S_|_C_, _S_|_C_, _S_|_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
24 _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_BLANK,
25 _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
26 _P_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
27 _D_|_H_, _D_|_H_, _D_|_H_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _U_|_H_,
28 _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_, _U_, _U_,
29 _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
30 _U_, _P_, _P_, _P_, _P_, _P_, _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_,
31 _L_|_H_, _L_|_H_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
32 _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_,
33 _C_, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
38 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
41 /* Internal: Current ctype table for locale */
42 WORD MSVCRT_current_ctype[257];
44 /* pctype is used by macros in the Win32 headers. It must point
45 * To a table of flags exactly like ctype. To allow locale
46 * changes to affect ctypes (i.e. isleadbyte), we use a second table
47 * and update its flags whenever the current locale changes.
49 WORD* MSVCRT__pctype = MSVCRT_current_ctype + 1;
51 /* mbctype data */
52 extern int MSVCRT___mb_cur_max;
53 extern LCID MSVCRT_current_lc_all_lcid;
55 /*********************************************************************
56 * __p__pctype (MSVCRT.@)
58 WORD** __p__pctype(void)
60 return &MSVCRT__pctype;
63 /*********************************************************************
64 * _isctype (MSVCRT.@)
66 int _isctype(int c, int type)
68 if (c >= -1 && c <= 255)
69 return MSVCRT__pctype[c] & type;
71 if (MSVCRT___mb_cur_max != 1 && c > 0)
73 /* FIXME: Is there a faster way to do this? */
74 WORD typeInfo;
75 char convert[3], *pconv = convert;
77 if (MSVCRT__pctype[(UINT)c >> 8] & _LEADBYTE)
78 *pconv++ = (UINT)c >> 8;
79 *pconv++ = c & 0xff;
80 *pconv = 0;
81 /* FIXME: Use ctype LCID, not lc_all */
82 if (GetStringTypeExA(MSVCRT_current_lc_all_lcid, CT_CTYPE1,
83 convert, convert[1] ? 2 : 1, &typeInfo))
84 return typeInfo & type;
86 return 0;
89 /*********************************************************************
90 * isalnum (MSVCRT.@)
92 int MSVCRT_isalnum(int c)
94 return _isctype( c, _ALPHA | _DIGIT );
97 /*********************************************************************
98 * isalpha (MSVCRT.@)
100 int MSVCRT_isalpha(int c)
102 return _isctype( c, _ALPHA );
105 /*********************************************************************
106 * iscntrl (MSVCRT.@)
108 int MSVCRT_iscntrl(int c)
110 return _isctype( c, _CONTROL );
113 /*********************************************************************
114 * isdigit (MSVCRT.@)
116 int MSVCRT_isdigit(int c)
118 return _isctype( c, _DIGIT );
121 /*********************************************************************
122 * isgraph (MSVCRT.@)
124 int MSVCRT_isgraph(int c)
126 return _isctype( c, _ALPHA | _DIGIT | _PUNCT );
129 /*********************************************************************
130 * isleadbyte (MSVCRT.@)
132 int MSVCRT_isleadbyte(int c)
134 return _isctype( c, _LEADBYTE );
137 /*********************************************************************
138 * islower (MSVCRT.@)
140 int MSVCRT_islower(int c)
142 return _isctype( c, _LOWER );
145 /*********************************************************************
146 * isprint (MSVCRT.@)
148 int MSVCRT_isprint(int c)
150 return _isctype( c, _ALPHA | _DIGIT | _BLANK | _PUNCT );
153 /*********************************************************************
154 * ispunct (MSVCRT.@)
156 int MSVCRT_ispunct(int c)
158 return _isctype( c, _PUNCT );
161 /*********************************************************************
162 * isspace (MSVCRT.@)
164 int MSVCRT_isspace(int c)
166 return _isctype( c, _SPACE );
169 /*********************************************************************
170 * isupper (MSVCRT.@)
172 int MSVCRT_isupper(int c)
174 return _isctype( c, _UPPER );
177 /*********************************************************************
178 * isxdigit (MSVCRT.@)
180 int MSVCRT_isxdigit(int c)
182 return _isctype( c, _HEX );
185 /*********************************************************************
186 * __isascii (MSVCRT.@)
188 int MSVCRT___isascii(int c)
190 return isascii((unsigned)c);
193 /*********************************************************************
194 * __toascii (MSVCRT.@)
196 int MSVCRT___toascii(int c)
198 return (unsigned)c & 0x7f;
201 /*********************************************************************
202 * iswascii (MSVCRT.@)
205 int MSVCRT_iswascii(WCHAR c)
207 return ((unsigned)c < 0x80);
210 /*********************************************************************
211 * __iscsym (MSVCRT.@)
213 int MSVCRT___iscsym(int c)
215 return (c < 127 && (isalnum(c) || c == '_'));
218 /*********************************************************************
219 * __iscsymf (MSVCRT.@)
221 int MSVCRT___iscsymf(int c)
223 return (c < 127 && (isalpha(c) || c == '_'));
226 /*********************************************************************
227 * _toupper (MSVCRT.@)
229 int MSVCRT__toupper(int c)
231 return c - 0x20; /* sic */
234 /*********************************************************************
235 * _tolower (MSVCRT.@)
237 int MSVCRT__tolower(int c)
239 return c + 0x20; /* sic */