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