2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll ctype functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-07-10 11:54:10 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
#include <locale.h>
|
2001-01-11 00:59:25 +01:00
|
|
|
#include "msvcrt.h"
|
2006-07-10 11:54:10 +02:00
|
|
|
#include "winnls.h"
|
2001-04-10 23:16:07 +02:00
|
|
|
|
2001-04-11 01:25:25 +02:00
|
|
|
/* Some abbreviations to make the following table readable */
|
2020-12-01 13:51:51 +01:00
|
|
|
#define _C_ _CONTROL
|
|
|
|
#define _S_ _SPACE
|
|
|
|
#define _P_ _PUNCT
|
|
|
|
#define _D_ _DIGIT
|
|
|
|
#define _H_ _HEX
|
|
|
|
#define _U_ _UPPER
|
|
|
|
#define _L_ _LOWER
|
2001-01-11 00:59:25 +01: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_,
|
2020-12-01 13:51:51 +01:00
|
|
|
_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_BLANK,
|
2001-01-11 00:59:25 +01: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
|
|
|
|
};
|
|
|
|
|
2020-07-21 12:21:08 +02:00
|
|
|
#if _MSVCR_VER <= 110
|
2020-12-01 13:51:51 +01:00
|
|
|
# define B110 _BLANK
|
2020-07-21 12:21:08 +02:00
|
|
|
#else
|
|
|
|
# define B110 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _MSVCR_VER == 120
|
|
|
|
# define D120 0
|
|
|
|
#else
|
|
|
|
# define D120 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _MSVCR_VER >= 140
|
2020-12-01 13:51:51 +01:00
|
|
|
# define S140 _SPACE
|
|
|
|
# define L140 _LOWER | 0x100
|
|
|
|
# define C140 _CONTROL
|
2020-07-21 12:21:08 +02:00
|
|
|
#else
|
|
|
|
# define S140 0
|
|
|
|
# define L140 0
|
|
|
|
# define C140 0
|
|
|
|
#endif
|
|
|
|
WORD MSVCRT__wctype[257] =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
/* 00 */
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
|
|
|
|
0x0020, 0x0028 | B110, 0x0028, 0x0028, 0x0028, 0x0028, 0x0020, 0x0020,
|
|
|
|
/* 10 */
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
|
|
|
|
/* 20 */
|
|
|
|
0x0048, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
|
|
|
|
0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
|
|
|
|
/* 30 */
|
|
|
|
0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084,
|
|
|
|
0x0084, 0x0084, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
|
|
|
|
/* 40 */
|
|
|
|
0x0010, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0101,
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
|
|
|
|
/* 50 */
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
|
|
|
|
/* 60 */
|
|
|
|
0x0010, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0102,
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
|
|
|
|
/* 70 */
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0010, 0x0010, 0x0010, 0x0010, 0x0020,
|
|
|
|
/* 80 */
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020 | S140, 0x0020, 0x0020,
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
|
|
|
|
/* 90 */
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
|
|
|
|
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
|
|
|
|
/* a0 */
|
|
|
|
0x0008 | B110, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
|
|
|
|
0x0010, 0x0010, 0x0010 | L140, 0x0010, 0x0010, 0x0010 | C140, 0x0010, 0x0010,
|
|
|
|
/* b0 */
|
|
|
|
0x0010, 0x0010, 0x0010 | D120, 0x0010 | D120, 0x0010, 0x0010 | L140, 0x0010, 0x0010,
|
|
|
|
0x0010, 0x0010 | D120, 0x0010 | L140, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
|
|
|
|
/* c0 */
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101,
|
|
|
|
/* d0 */
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0010,
|
|
|
|
0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0102,
|
|
|
|
/* e0 */
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102,
|
|
|
|
/* f0 */
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0010,
|
|
|
|
0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102
|
|
|
|
};
|
|
|
|
|
2020-07-21 12:21:16 +02:00
|
|
|
WORD *MSVCRT__pwctype = MSVCRT__wctype + 1;
|
|
|
|
|
2011-06-17 20:29:57 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __p__pctype (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
unsigned short** CDECL __p__pctype(void)
|
2011-06-17 20:29:57 +02:00
|
|
|
{
|
|
|
|
return &get_locinfo()->pctype;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2008-12-15 16:03:32 +01:00
|
|
|
* __pctype_func (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
const unsigned short* CDECL __pctype_func(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-05-24 17:22:32 +02:00
|
|
|
return get_locinfo()->pctype;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 17:04:34 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __p__pwctype (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
unsigned short** CDECL __p__pwctype(void)
|
|
|
|
{
|
|
|
|
return &MSVCRT__pwctype;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __pwctype_func (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
const unsigned short* CDECL __pwctype_func(void)
|
|
|
|
{
|
|
|
|
return MSVCRT__pwctype;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2011-05-12 11:37:37 +02:00
|
|
|
* _isctype_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isctype_l(int c, int type, _locale_t locale)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2011-05-24 17:22:32 +02:00
|
|
|
|
2011-05-12 11:37:37 +02:00
|
|
|
if(!locale)
|
2011-05-24 17:22:32 +02:00
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
2010-04-15 14:26:47 +02:00
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
if (c >= -1 && c <= 255)
|
2011-05-24 17:22:32 +02:00
|
|
|
return locinfo->pctype[c] & type;
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if (locinfo->mb_cur_max != 1 && c > 0)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
/* FIXME: Is there a faster way to do this? */
|
|
|
|
WORD typeInfo;
|
|
|
|
char convert[3], *pconv = convert;
|
|
|
|
|
2020-12-01 13:51:51 +01:00
|
|
|
if (locinfo->pctype[(UINT)c >> 8] & _LEADBYTE)
|
2001-01-11 00:59:25 +01:00
|
|
|
*pconv++ = (UINT)c >> 8;
|
|
|
|
*pconv++ = c & 0xff;
|
|
|
|
*pconv = 0;
|
2011-03-31 17:09:09 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if (GetStringTypeExA(locinfo->lc_handle[LC_CTYPE],
|
2010-04-15 14:25:13 +02:00
|
|
|
CT_CTYPE1, convert, convert[1] ? 2 : 1, &typeInfo))
|
2001-01-11 00:59:25 +01:00
|
|
|
return typeInfo & type;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:37 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isctype (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isctype(int c, int type)
|
2011-05-12 11:37:37 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l(c, type, NULL);
|
2011-05-12 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isalnum_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isalnum_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _ALPHA | _DIGIT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isalnum (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isalnum(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _ALPHA | _DIGIT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isalpha_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isalpha_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _ALPHA, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isalpha (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isalpha(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _ALPHA );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _iscntrl_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _iscntrl_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _CONTROL, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* iscntrl (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL iscntrl(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _CONTROL );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isdigit_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isdigit_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _DIGIT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isdigit (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isdigit(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _DIGIT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isgraph_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isgraph_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _ALPHA | _DIGIT | _PUNCT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isgraph (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isgraph(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _ALPHA | _DIGIT | _PUNCT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isleadbyte_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isleadbyte_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _LEADBYTE, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isleadbyte (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isleadbyte(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _LEADBYTE );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _islower_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _islower_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _LOWER, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* islower (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL islower(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _LOWER );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isprint_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isprint_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _ALPHA | _DIGIT | _BLANK | _PUNCT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isprint (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isprint(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _ALPHA | _DIGIT | _BLANK | _PUNCT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ispunct (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL ispunct(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _PUNCT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2020-01-27 03:14:09 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _ispunct_l (MSVCR80.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _ispunct_l(int c, _locale_t locale)
|
2020-01-27 03:14:09 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _PUNCT, locale );
|
2020-01-27 03:14:09 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isspace_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isspace_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _SPACE, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isspace (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isspace(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _SPACE );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isupper_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isupper_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _UPPER, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isupper (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isupper(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _UPPER );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isxdigit_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isxdigit_l(int c, _locale_t locale)
|
2011-05-12 11:37:48 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype_l( c, _HEX, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isxdigit (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isxdigit(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return _isctype( c, _HEX );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2017-04-03 18:24:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isblank_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _isblank_l(int c, _locale_t locale)
|
2017-04-03 18:24:40 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return c == '\t' || _isctype_l( c, _BLANK, locale );
|
2017-04-03 18:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isblank (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL isblank(int c)
|
2017-04-03 18:24:40 +02:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return c == '\t' || _isctype( c, _BLANK );
|
2017-04-03 18:24:40 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __isascii (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL __isascii(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-18 16:03:27 +01:00
|
|
|
return ((unsigned)c < 0x80);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __toascii (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL __toascii(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return (unsigned)c & 0x7f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iswascii (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL iswascii(wchar_t c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return ((unsigned)c < 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __iscsym (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL __iscsym(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return (c < 127 && (isalnum(c) || c == '_'));
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __iscsymf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL __iscsymf(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-01 13:52:34 +01:00
|
|
|
return (c < 127 && (isalpha(c) || c == '_'));
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:38:23 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _toupper_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _toupper_l(int c, _locale_t locale)
|
2011-05-12 11:38:23 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-07-16 14:47:15 +02:00
|
|
|
unsigned char str[2], *p = str, ret[2];
|
2011-05-24 17:22:32 +02:00
|
|
|
|
2011-05-12 11:38:23 +02:00
|
|
|
if(!locale)
|
2011-05-24 17:22:32 +02:00
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
2011-05-12 11:38:23 +02:00
|
|
|
|
2014-03-13 14:13:02 +01:00
|
|
|
if((unsigned)c < 256)
|
|
|
|
return locinfo->pcumap[c];
|
2011-05-12 11:38:23 +02:00
|
|
|
|
2020-12-01 13:51:51 +01:00
|
|
|
if(locinfo->pctype[(c>>8)&255] & _LEADBYTE)
|
2011-05-12 11:38:23 +02:00
|
|
|
*p++ = (c>>8) & 255;
|
2014-03-13 14:13:02 +01:00
|
|
|
else {
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2014-03-13 14:13:02 +01:00
|
|
|
str[1] = 0;
|
|
|
|
}
|
|
|
|
*p++ = c & 255;
|
2011-05-12 11:38:23 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
switch(__crtLCMapStringA(locinfo->lc_handle[LC_CTYPE], LCMAP_UPPERCASE,
|
2020-07-16 14:47:15 +02:00
|
|
|
(char*)str, p-str, (char*)ret, 2, locinfo->lc_codepage, 0))
|
|
|
|
{
|
2014-03-13 14:13:02 +01:00
|
|
|
case 0:
|
|
|
|
return c;
|
|
|
|
case 1:
|
2020-07-16 14:47:15 +02:00
|
|
|
return ret[0];
|
2014-03-13 14:13:02 +01:00
|
|
|
default:
|
2020-07-16 14:47:15 +02:00
|
|
|
return ret[0] + (ret[1]<<8);
|
2011-05-12 11:38:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* toupper (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL toupper(int c)
|
2011-05-12 11:38:23 +02:00
|
|
|
{
|
2019-01-23 11:59:11 +01:00
|
|
|
if(initial_locale)
|
|
|
|
return c>='a' && c<='z' ? c-'a'+'A' : c;
|
2020-12-01 13:52:34 +01:00
|
|
|
return _toupper_l(c, NULL);
|
2011-05-12 11:38:23 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _toupper (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _toupper(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-01-15 20:57:48 +01:00
|
|
|
return c - 0x20; /* sic */
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:38:32 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _tolower_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _tolower_l(int c, _locale_t locale)
|
2011-05-12 11:38:32 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-07-16 14:46:47 +02:00
|
|
|
unsigned char str[2], *p = str, ret[2];
|
2011-05-24 17:22:32 +02:00
|
|
|
|
2011-05-12 11:38:32 +02:00
|
|
|
if(!locale)
|
2011-05-24 17:22:32 +02:00
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
2011-05-12 11:38:32 +02:00
|
|
|
|
2014-03-13 14:12:41 +01:00
|
|
|
if((unsigned)c < 256)
|
|
|
|
return locinfo->pclmap[c];
|
2011-05-12 11:38:32 +02:00
|
|
|
|
2020-12-01 13:51:51 +01:00
|
|
|
if(locinfo->pctype[(c>>8)&255] & _LEADBYTE)
|
2011-05-12 11:38:32 +02:00
|
|
|
*p++ = (c>>8) & 255;
|
2014-03-13 14:12:41 +01:00
|
|
|
else {
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2014-03-13 14:12:41 +01:00
|
|
|
str[1] = 0;
|
|
|
|
}
|
|
|
|
*p++ = c & 255;
|
2011-05-12 11:38:32 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
switch(__crtLCMapStringA(locinfo->lc_handle[LC_CTYPE], LCMAP_LOWERCASE,
|
2020-07-16 14:46:47 +02:00
|
|
|
(char*)str, p-str, (char*)ret, 2, locinfo->lc_codepage, 0))
|
|
|
|
{
|
2014-03-13 14:12:41 +01:00
|
|
|
case 0:
|
|
|
|
return c;
|
|
|
|
case 1:
|
2020-07-16 14:46:47 +02:00
|
|
|
return ret[0];
|
2014-03-13 14:12:41 +01:00
|
|
|
default:
|
2020-07-16 14:46:47 +02:00
|
|
|
return ret[0] + (ret[1]<<8);
|
2011-05-12 11:38:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* tolower (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL tolower(int c)
|
2011-05-12 11:38:32 +02:00
|
|
|
{
|
2019-01-23 11:59:05 +01:00
|
|
|
if(initial_locale)
|
|
|
|
return c>='A' && c<='Z' ? c-'A'+'a' : c;
|
2020-12-01 13:52:34 +01:00
|
|
|
return _tolower_l(c, NULL);
|
2011-05-12 11:38:32 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _tolower (MSVCRT.@)
|
|
|
|
*/
|
2020-12-01 13:52:34 +01:00
|
|
|
int CDECL _tolower(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-01-15 20:57:48 +01:00
|
|
|
return c + 0x20; /* sic */
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
2017-04-14 18:21:21 +02:00
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=120
|
2017-04-14 18:21:21 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wctype (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
unsigned short __cdecl wctype(const char *property)
|
|
|
|
{
|
|
|
|
static const struct {
|
|
|
|
const char *name;
|
|
|
|
unsigned short mask;
|
|
|
|
} properties[] = {
|
2020-12-01 13:51:51 +01:00
|
|
|
{ "alnum", _DIGIT|_ALPHA },
|
|
|
|
{ "alpha", _ALPHA },
|
|
|
|
{ "cntrl", _CONTROL },
|
|
|
|
{ "digit", _DIGIT },
|
|
|
|
{ "graph", _DIGIT|_PUNCT|_ALPHA },
|
|
|
|
{ "lower", _LOWER },
|
|
|
|
{ "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
|
|
|
|
{ "punct", _PUNCT },
|
|
|
|
{ "space", _SPACE },
|
|
|
|
{ "upper", _UPPER },
|
|
|
|
{ "xdigit", _HEX }
|
2017-04-14 18:21:21 +02:00
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
|
2018-07-26 00:05:52 +02:00
|
|
|
for(i=0; i<ARRAY_SIZE(properties); i++)
|
2017-04-14 18:21:21 +02:00
|
|
|
if(!strcmp(property, properties[i].name))
|
|
|
|
return properties[i].mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif
|