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
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
#include "msvcrt.h"
|
2006-07-10 11:54:10 +02:00
|
|
|
#include "winnls.h"
|
2011-05-12 11:38:23 +02:00
|
|
|
#include "wine/unicode.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 */
|
2004-06-25 03:19:15 +02:00
|
|
|
#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
|
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_,
|
2004-06-25 03:19:15 +02:00
|
|
|
_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|MSVCRT__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
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2011-05-19 16:44:09 +02:00
|
|
|
unsigned short *MSVCRT__pctype = NULL;
|
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
|
|
|
*/
|
2011-05-19 16:44:09 +02:00
|
|
|
const unsigned short* CDECL MSVCRT___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
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2011-05-12 11:37:37 +02:00
|
|
|
* _isctype_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
int CDECL MSVCRT__isctype_l(int c, int type, MSVCRT__locale_t locale)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-05-24 17:22:32 +02:00
|
|
|
MSVCRT_pthreadlocinfo locinfo;
|
|
|
|
|
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;
|
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if (locinfo->pctype[(UINT)c >> 8] & MSVCRT__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
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if (GetStringTypeExA(locinfo->lc_handle[MSVCRT_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.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
int CDECL MSVCRT__isctype(int c, int type)
|
2011-05-12 11:37:37 +02:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l(c, type, NULL);
|
2011-05-12 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isalnum_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isalnum_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__ALPHA | MSVCRT__DIGIT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isalnum (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isalnum(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isalpha_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isalpha_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__ALPHA, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isalpha (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isalpha(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__ALPHA );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _iscntrl_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__iscntrl_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__CONTROL, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* iscntrl (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_iscntrl(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__CONTROL );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isdigit_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isdigit_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__DIGIT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isdigit (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isdigit(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__DIGIT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isgraph_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isgraph_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__PUNCT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isgraph (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isgraph(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__PUNCT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isleadbyte_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isleadbyte_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__LEADBYTE, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isleadbyte (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isleadbyte(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__LEADBYTE );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _islower_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__islower_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__LOWER, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* islower (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_islower(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__LOWER );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isprint_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isprint_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__BLANK | MSVCRT__PUNCT, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isprint (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isprint(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__ALPHA | MSVCRT__DIGIT | MSVCRT__BLANK | MSVCRT__PUNCT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ispunct (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_ispunct(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__PUNCT );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isspace_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isspace_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__SPACE, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isspace (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isspace(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__SPACE );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isupper_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isupper_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__UPPER, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isupper (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isupper(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__UPPER );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-05-12 11:37:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _isxdigit_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__isxdigit_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype_l( c, MSVCRT__HEX, locale );
|
2011-05-12 11:37:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* isxdigit (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_isxdigit(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-06-03 15:28:32 +02:00
|
|
|
return MSVCRT__isctype( c, MSVCRT__HEX );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __isascii (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT___isascii(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return isascii((unsigned)c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __toascii (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT___toascii(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return (unsigned)c & 0x7f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iswascii (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_iswascii(MSVCRT_wchar_t c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return ((unsigned)c < 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __iscsym (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT___iscsym(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return (c < 127 && (isalnum(c) || c == '_'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __iscsymf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT___iscsymf(int c)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return (c < 127 && (isalpha(c) || c == '_'));
|
|
|
|
}
|
|
|
|
|
2011-05-12 11:38:23 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _toupper_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__toupper_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-05-24 17:22:32 +02:00
|
|
|
MSVCRT_pthreadlocinfo locinfo;
|
|
|
|
|
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
|
|
|
|
|
|
|
if(c < 256)
|
2011-06-03 15:28:56 +02:00
|
|
|
return locinfo->pcumap[(unsigned char)c];
|
2011-05-12 11:38:23 +02:00
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
|
2011-05-12 11:38:23 +02:00
|
|
|
{
|
|
|
|
WCHAR wide, upper;
|
|
|
|
char str[2], *p = str;
|
|
|
|
*p++ = (c>>8) & 255;
|
|
|
|
*p++ = c & 255;
|
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if(!MultiByteToWideChar(locinfo->lc_codepage,
|
2011-05-12 11:38:23 +02:00
|
|
|
MB_ERR_INVALID_CHARS, str, 2, &wide, 1))
|
|
|
|
return c;
|
|
|
|
|
|
|
|
upper = toupperW(wide);
|
|
|
|
if(upper == wide)
|
|
|
|
return c;
|
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
WideCharToMultiByte(locinfo->lc_codepage, 0,
|
2011-05-12 11:38:23 +02:00
|
|
|
&upper, 1, str, 2, NULL, NULL);
|
|
|
|
|
|
|
|
return str[0] + (str[1]<<8);
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* toupper (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT_toupper(int c)
|
|
|
|
{
|
|
|
|
return MSVCRT__toupper_l(c, NULL);
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _toupper (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT__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.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__tolower_l(int c, MSVCRT__locale_t locale)
|
|
|
|
{
|
2011-05-24 17:22:32 +02:00
|
|
|
MSVCRT_pthreadlocinfo locinfo;
|
|
|
|
|
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
|
|
|
|
|
|
|
if(c < 256)
|
2011-06-03 15:28:56 +02:00
|
|
|
return locinfo->pclmap[(unsigned char)c];
|
2011-05-12 11:38:32 +02:00
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
|
2011-05-12 11:38:32 +02:00
|
|
|
{
|
|
|
|
WCHAR wide, upper;
|
|
|
|
char str[2], *p = str;
|
|
|
|
*p++ = (c>>8) & 255;
|
|
|
|
*p++ = c & 255;
|
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
if(!MultiByteToWideChar(locinfo->lc_codepage,
|
2011-05-12 11:38:32 +02:00
|
|
|
MB_ERR_INVALID_CHARS, str, 2, &wide, 1))
|
|
|
|
return c;
|
|
|
|
|
|
|
|
upper = tolowerW(wide);
|
|
|
|
if(upper == wide)
|
|
|
|
return c;
|
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
WideCharToMultiByte(locinfo->lc_codepage, 0,
|
2011-05-12 11:38:32 +02:00
|
|
|
&upper, 1, str, 2, NULL, NULL);
|
|
|
|
|
|
|
|
return str[0] + (str[1]<<8);
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* tolower (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT_tolower(int c)
|
|
|
|
{
|
|
|
|
return MSVCRT__tolower_l(c, NULL);
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _tolower (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT__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
|
|
|
}
|