gdi32/tests: Don't test unimplemented functions.
[wine/gsoc_dplay.git] / dlls / msvcrt / ctype.c
blob7b8c1fa58634172043f335664c6a85e8576754af
1 /*
2 * msvcrt.dll ctype functions
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "msvcrt.h"
22 #include "winnls.h"
24 /* Some abbreviations to make the following table readable */
25 #define _C_ MSVCRT__CONTROL
26 #define _S_ MSVCRT__SPACE
27 #define _P_ MSVCRT__PUNCT
28 #define _D_ MSVCRT__DIGIT
29 #define _H_ MSVCRT__HEX
30 #define _U_ MSVCRT__UPPER
31 #define _L_ MSVCRT__LOWER
33 WORD MSVCRT__ctype [257] = {
34 0, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_, _S_|_C_,
35 _S_|_C_, _S_|_C_, _S_|_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
36 _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|MSVCRT__BLANK,
37 _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
38 _P_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
39 _D_|_H_, _D_|_H_, _D_|_H_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _U_|_H_,
40 _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_, _U_, _U_,
41 _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
42 _U_, _P_, _P_, _P_, _P_, _P_, _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_,
43 _L_|_H_, _L_|_H_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
44 _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_,
45 _C_, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
53 /* Internal: Current ctype table for locale */
54 WORD MSVCRT_current_ctype[257];
56 /* pctype is used by macros in the Win32 headers. It must point
57 * To a table of flags exactly like ctype. To allow locale
58 * changes to affect ctypes (i.e. isleadbyte), we use a second table
59 * and update its flags whenever the current locale changes.
61 WORD* MSVCRT__pctype = MSVCRT_current_ctype + 1;
63 /* mbctype data */
64 extern int MSVCRT___mb_cur_max;
65 extern LCID MSVCRT_current_lc_all_lcid;
67 /*********************************************************************
68 * __p__pctype (MSVCRT.@)
70 WORD** CDECL __p__pctype(void)
72 return &MSVCRT__pctype;
75 /*********************************************************************
76 * _isctype (MSVCRT.@)
78 int CDECL _isctype(int c, int type)
80 if (c >= -1 && c <= 255)
81 return MSVCRT__pctype[c] & type;
83 if (MSVCRT___mb_cur_max != 1 && c > 0)
85 /* FIXME: Is there a faster way to do this? */
86 WORD typeInfo;
87 char convert[3], *pconv = convert;
89 if (MSVCRT__pctype[(UINT)c >> 8] & MSVCRT__LEADBYTE)
90 *pconv++ = (UINT)c >> 8;
91 *pconv++ = c & 0xff;
92 *pconv = 0;
93 /* FIXME: Use ctype LCID, not lc_all */
94 if (GetStringTypeExA(MSVCRT_current_lc_all_lcid, CT_CTYPE1,
95 convert, convert[1] ? 2 : 1, &typeInfo))
96 return typeInfo & type;
98 return 0;
101 /*********************************************************************
102 * isalnum (MSVCRT.@)
104 int CDECL MSVCRT_isalnum(int c)
106 return _isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT );
109 /*********************************************************************
110 * isalpha (MSVCRT.@)
112 int CDECL MSVCRT_isalpha(int c)
114 return _isctype( c, MSVCRT__ALPHA );
117 /*********************************************************************
118 * iscntrl (MSVCRT.@)
120 int CDECL MSVCRT_iscntrl(int c)
122 return _isctype( c, MSVCRT__CONTROL );
125 /*********************************************************************
126 * isdigit (MSVCRT.@)
128 int CDECL MSVCRT_isdigit(int c)
130 return _isctype( c, MSVCRT__DIGIT );
133 /*********************************************************************
134 * isgraph (MSVCRT.@)
136 int CDECL MSVCRT_isgraph(int c)
138 return _isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__PUNCT );
141 /*********************************************************************
142 * isleadbyte (MSVCRT.@)
144 int CDECL MSVCRT_isleadbyte(int c)
146 return _isctype( c, MSVCRT__LEADBYTE );
149 /*********************************************************************
150 * islower (MSVCRT.@)
152 int CDECL MSVCRT_islower(int c)
154 return _isctype( c, MSVCRT__LOWER );
157 /*********************************************************************
158 * isprint (MSVCRT.@)
160 int CDECL MSVCRT_isprint(int c)
162 return _isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__BLANK | MSVCRT__PUNCT );
165 /*********************************************************************
166 * ispunct (MSVCRT.@)
168 int CDECL MSVCRT_ispunct(int c)
170 return _isctype( c, MSVCRT__PUNCT );
173 /*********************************************************************
174 * isspace (MSVCRT.@)
176 int CDECL MSVCRT_isspace(int c)
178 return _isctype( c, MSVCRT__SPACE );
181 /*********************************************************************
182 * isupper (MSVCRT.@)
184 int CDECL MSVCRT_isupper(int c)
186 return _isctype( c, MSVCRT__UPPER );
189 /*********************************************************************
190 * isxdigit (MSVCRT.@)
192 int CDECL MSVCRT_isxdigit(int c)
194 return _isctype( c, MSVCRT__HEX );
197 /*********************************************************************
198 * __isascii (MSVCRT.@)
200 int CDECL MSVCRT___isascii(int c)
202 return isascii((unsigned)c);
205 /*********************************************************************
206 * __toascii (MSVCRT.@)
208 int CDECL MSVCRT___toascii(int c)
210 return (unsigned)c & 0x7f;
213 /*********************************************************************
214 * iswascii (MSVCRT.@)
217 int CDECL MSVCRT_iswascii(MSVCRT_wchar_t c)
219 return ((unsigned)c < 0x80);
222 /*********************************************************************
223 * __iscsym (MSVCRT.@)
225 int CDECL MSVCRT___iscsym(int c)
227 return (c < 127 && (isalnum(c) || c == '_'));
230 /*********************************************************************
231 * __iscsymf (MSVCRT.@)
233 int CDECL MSVCRT___iscsymf(int c)
235 return (c < 127 && (isalpha(c) || c == '_'));
238 /*********************************************************************
239 * _toupper (MSVCRT.@)
241 int CDECL MSVCRT__toupper(int c)
243 return c - 0x20; /* sic */
246 /*********************************************************************
247 * _tolower (MSVCRT.@)
249 int CDECL MSVCRT__tolower(int c)
251 return c + 0x20; /* sic */