2001-01-10 23:59:25 +00:00
|
|
|
/*
|
|
|
|
* msvcrt.dll ctype functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
|
|
|
*/
|
|
|
|
#include "msvcrt.h"
|
|
|
|
|
2001-04-10 23:25:25 +00:00
|
|
|
#include "msvcrt/ctype.h"
|
2001-01-10 23:59:25 +00:00
|
|
|
|
2001-04-10 23:25:25 +00:00
|
|
|
DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-04-10 21:16:07 +00:00
|
|
|
|
2001-04-10 23:25:25 +00:00
|
|
|
/* Some abbreviations to make the following table readable */
|
2001-04-10 21:16:07 +00:00
|
|
|
#define _C_ _CONTROL
|
|
|
|
#define _S_ _SPACE
|
|
|
|
#define _P_ _PUNCT
|
|
|
|
#define _D_ _DIGIT
|
|
|
|
#define _H_ _HEX
|
|
|
|
#define _U_ _UPPER
|
|
|
|
#define _L_ _LOWER
|
2001-01-10 23:59:25 +00:00
|
|
|
|
|
|
|
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_,
|
2001-04-10 21:16:07 +00:00
|
|
|
_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_BLANK,
|
2001-01-10 23:59:25 +00:00
|
|
|
_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;
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-04-10 21:16:07 +00:00
|
|
|
* __p__pctype (MSVCRT.@)
|
2001-01-10 23:59:25 +00:00
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
WORD** __p__pctype(void)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
return &MSVCRT__pctype;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _isctype (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int _isctype(int c, int type)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2001-04-10 21:16:07 +00:00
|
|
|
if (MSVCRT__pctype[(UINT)c >> 8] & _LEADBYTE)
|
2001-01-10 23:59:25 +00:00
|
|
|
*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.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isalnum(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _ALPHA | _DIGIT );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isalpha (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isalpha(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _ALPHA );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iscntrl (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_iscntrl(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _CONTROL );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isdigit (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isdigit(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _DIGIT );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isgraph (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isgraph(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _ALPHA | _DIGIT | _PUNCT );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isleadbyte (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isleadbyte(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _LEADBYTE );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* islower (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_islower(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _LOWER );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isprint (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isprint(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _ALPHA | _DIGIT | _BLANK | _PUNCT );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ispunct (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_ispunct(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _PUNCT );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isspace (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isspace(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _SPACE );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isupper (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isupper(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _UPPER );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isxdigit (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_isxdigit(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-04-10 21:16:07 +00:00
|
|
|
return _isctype( c, _HEX );
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __isascii (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT___isascii(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
return isascii((unsigned)c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __toascii (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT___toascii(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
return (unsigned)c & 0x7f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iswascii (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT_iswascii(WCHAR c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
return ((unsigned)c < 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __iscsym (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT___iscsym(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
return (c < 127 && (isalnum(c) || c == '_'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __iscsymf (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT___iscsymf(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
|
|
|
return (c < 127 && (isalpha(c) || c == '_'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _toupper (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT__toupper(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-01-15 19:57:48 +00:00
|
|
|
return c - 0x20; /* sic */
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _tolower (MSVCRT.@)
|
|
|
|
*/
|
2001-04-10 21:16:07 +00:00
|
|
|
int MSVCRT__tolower(int c)
|
2001-01-10 23:59:25 +00:00
|
|
|
{
|
2001-01-15 19:57:48 +00:00
|
|
|
return c + 0x20; /* sic */
|
2001-01-10 23:59:25 +00:00
|
|
|
}
|