wined3d: Allow use of pixel shaders with drawStridedSlow.
[wine] / dlls / msvcrt / ctype.c
1 /*
2  * msvcrt.dll ctype functions
3  *
4  * Copyright 2000 Jon Griffiths
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 #include "msvcrt.h"
21 #include "wine/debug.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
24
25 /* Some abbreviations to make the following table readable */
26 #define _C_ MSVCRT__CONTROL
27 #define _S_ MSVCRT__SPACE
28 #define _P_ MSVCRT__PUNCT
29 #define _D_ MSVCRT__DIGIT
30 #define _H_ MSVCRT__HEX
31 #define _U_ MSVCRT__UPPER
32 #define _L_ MSVCRT__LOWER
33
34 WORD MSVCRT__ctype [257] = {
35   0, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_, _S_|_C_,
36   _S_|_C_, _S_|_C_, _S_|_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
37   _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|MSVCRT__BLANK,
38   _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
39   _P_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
40   _D_|_H_, _D_|_H_, _D_|_H_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _U_|_H_,
41   _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_, _U_, _U_,
42   _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
43   _U_, _P_, _P_, _P_, _P_, _P_, _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_,
44   _L_|_H_, _L_|_H_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
45   _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_,
46   _C_, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
52 };
53
54 /* Internal: Current ctype table for locale */
55 WORD MSVCRT_current_ctype[257];
56
57 /* pctype is used by macros in the Win32 headers. It must point
58  * To a table of flags exactly like ctype. To allow locale
59  * changes to affect ctypes (i.e. isleadbyte), we use a second table
60  * and update its flags whenever the current locale changes.
61  */
62 WORD* MSVCRT__pctype = MSVCRT_current_ctype + 1;
63
64 /* mbctype data */
65 extern int MSVCRT___mb_cur_max;
66 extern LCID MSVCRT_current_lc_all_lcid;
67
68 /*********************************************************************
69  *              __p__pctype (MSVCRT.@)
70  */
71 WORD** __p__pctype(void)
72 {
73   return &MSVCRT__pctype;
74 }
75
76 /*********************************************************************
77  *              _isctype (MSVCRT.@)
78  */
79 int _isctype(int c, int type)
80 {
81   if (c >= -1 && c <= 255)
82     return MSVCRT__pctype[c] & type;
83
84   if (MSVCRT___mb_cur_max != 1 && c > 0)
85   {
86     /* FIXME: Is there a faster way to do this? */
87     WORD typeInfo;
88     char convert[3], *pconv = convert;
89
90     if (MSVCRT__pctype[(UINT)c >> 8] & MSVCRT__LEADBYTE)
91       *pconv++ = (UINT)c >> 8;
92     *pconv++ = c & 0xff;
93     *pconv = 0;
94     /* FIXME: Use ctype LCID, not lc_all */
95     if (GetStringTypeExA(MSVCRT_current_lc_all_lcid, CT_CTYPE1,
96                          convert, convert[1] ? 2 : 1, &typeInfo))
97       return typeInfo & type;
98   }
99   return 0;
100 }
101
102 /*********************************************************************
103  *              isalnum (MSVCRT.@)
104  */
105 int MSVCRT_isalnum(int c)
106 {
107   return _isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT );
108 }
109
110 /*********************************************************************
111  *              isalpha (MSVCRT.@)
112  */
113 int MSVCRT_isalpha(int c)
114 {
115   return _isctype( c, MSVCRT__ALPHA );
116 }
117
118 /*********************************************************************
119  *              iscntrl (MSVCRT.@)
120  */
121 int MSVCRT_iscntrl(int c)
122 {
123   return _isctype( c, MSVCRT__CONTROL );
124 }
125
126 /*********************************************************************
127  *              isdigit (MSVCRT.@)
128  */
129 int MSVCRT_isdigit(int c)
130 {
131   return _isctype( c, MSVCRT__DIGIT );
132 }
133
134 /*********************************************************************
135  *              isgraph (MSVCRT.@)
136  */
137 int MSVCRT_isgraph(int c)
138 {
139   return _isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__PUNCT );
140 }
141
142 /*********************************************************************
143  *              isleadbyte (MSVCRT.@)
144  */
145 int MSVCRT_isleadbyte(int c)
146 {
147   return _isctype( c, MSVCRT__LEADBYTE );
148 }
149
150 /*********************************************************************
151  *              islower (MSVCRT.@)
152  */
153 int MSVCRT_islower(int c)
154 {
155   return _isctype( c, MSVCRT__LOWER );
156 }
157
158 /*********************************************************************
159  *              isprint (MSVCRT.@)
160  */
161 int MSVCRT_isprint(int c)
162 {
163   return _isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__BLANK | MSVCRT__PUNCT );
164 }
165
166 /*********************************************************************
167  *              ispunct (MSVCRT.@)
168  */
169 int MSVCRT_ispunct(int c)
170 {
171   return _isctype( c, MSVCRT__PUNCT );
172 }
173
174 /*********************************************************************
175  *              isspace (MSVCRT.@)
176  */
177 int MSVCRT_isspace(int c)
178 {
179   return _isctype( c, MSVCRT__SPACE );
180 }
181
182 /*********************************************************************
183  *              isupper (MSVCRT.@)
184  */
185 int MSVCRT_isupper(int c)
186 {
187   return _isctype( c, MSVCRT__UPPER );
188 }
189
190 /*********************************************************************
191  *              isxdigit (MSVCRT.@)
192  */
193 int MSVCRT_isxdigit(int c)
194 {
195   return _isctype( c, MSVCRT__HEX );
196 }
197
198 /*********************************************************************
199  *              __isascii (MSVCRT.@)
200  */
201 int MSVCRT___isascii(int c)
202 {
203   return isascii((unsigned)c);
204 }
205
206 /*********************************************************************
207  *              __toascii (MSVCRT.@)
208  */
209 int MSVCRT___toascii(int c)
210 {
211   return (unsigned)c & 0x7f;
212 }
213
214 /*********************************************************************
215  *              iswascii (MSVCRT.@)
216  *
217  */
218 int MSVCRT_iswascii(MSVCRT_wchar_t c)
219 {
220   return ((unsigned)c < 0x80);
221 }
222
223 /*********************************************************************
224  *              __iscsym (MSVCRT.@)
225  */
226 int MSVCRT___iscsym(int c)
227 {
228   return (c < 127 && (isalnum(c) || c == '_'));
229 }
230
231 /*********************************************************************
232  *              __iscsymf (MSVCRT.@)
233  */
234 int MSVCRT___iscsymf(int c)
235 {
236   return (c < 127 && (isalpha(c) || c == '_'));
237 }
238
239 /*********************************************************************
240  *              _toupper (MSVCRT.@)
241  */
242 int MSVCRT__toupper(int c)
243 {
244     return c - 0x20;  /* sic */
245 }
246
247 /*********************************************************************
248  *              _tolower (MSVCRT.@)
249  */
250 int MSVCRT__tolower(int c)
251 {
252     return c + 0x20;  /* sic */
253 }