2 * msvcrt.dll ctype functions
4 * Copyright 2000 Jon Griffiths
8 #include "msvcrt/ctype.h"
10 DEFAULT_DEBUG_CHANNEL(msvcrt
);
12 /* Some abbreviations to make the following table readable */
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;
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 /*********************************************************************
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? */
75 char convert
[3], *pconv
= convert
;
77 if (MSVCRT__pctype
[(UINT
)c
>> 8] & _LEADBYTE
)
78 *pconv
++ = (UINT
)c
>> 8;
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
;
89 /*********************************************************************
92 int MSVCRT_isalnum(int c
)
94 return _isctype( c
, _ALPHA
| _DIGIT
);
97 /*********************************************************************
100 int MSVCRT_isalpha(int c
)
102 return _isctype( c
, _ALPHA
);
105 /*********************************************************************
108 int MSVCRT_iscntrl(int c
)
110 return _isctype( c
, _CONTROL
);
113 /*********************************************************************
116 int MSVCRT_isdigit(int c
)
118 return _isctype( c
, _DIGIT
);
121 /*********************************************************************
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 /*********************************************************************
140 int MSVCRT_islower(int c
)
142 return _isctype( c
, _LOWER
);
145 /*********************************************************************
148 int MSVCRT_isprint(int c
)
150 return _isctype( c
, _ALPHA
| _DIGIT
| _BLANK
| _PUNCT
);
153 /*********************************************************************
156 int MSVCRT_ispunct(int c
)
158 return _isctype( c
, _PUNCT
);
161 /*********************************************************************
164 int MSVCRT_isspace(int c
)
166 return _isctype( c
, _SPACE
);
169 /*********************************************************************
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 */