- make some functions locale aware
 - add implementation of ___mb_cur_max_func and _isctype_l
[MSVCRT20]
 - keep up with msvcrt
[MSVCRT40]
 - ditto

svn path=/trunk/; revision=57838
This commit is contained in:
Jérôme Gardou 2012-12-09 11:42:02 +00:00
parent 90b34c856c
commit cece806823
11 changed files with 71 additions and 27 deletions

View file

@ -133,7 +133,7 @@
@ cdecl ___lc_codepage_func()
# @ cdecl ___lc_collate_cp_func()
@ cdecl ___lc_handle_func()
# @ cdecl ___mb_cur_max_func() MSVCRT___mb_cur_max_func
@ cdecl ___mb_cur_max_func()
@ cdecl ___setlc_active_func()
@ cdecl ___unguarded_readlc_active_add_func()
@ extern __argc
@ -492,7 +492,7 @@
@ cdecl _isatty(long)
# stub _iscntrl_l
@ cdecl _isctype(long long)
# stub _isctype_l
@ cdecl _isctype_l(long long ptr)
# stub _isdigit_l
# stub _isgraph_l
# stub _isleadbyte_l

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <windows.h>
#include <internal/wine/msvcrt.h>
#include <internal/locale.h>
#include <locale.h>
#include <mbctype.h>
@ -93,17 +94,11 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
/* Initialization of the WINE code */
msvcrt_init_mt_locks();
//if(!msvcrt_init_locale()) {
// msvcrt_free_mt_locks();
// msvcrt_free_tls_mem();
// return FALSE;
//}
//msvcrt_init_math();
msvcrt_init_io();
//msvcrt_init_console();
//msvcrt_init_args();
//msvcrt_init_signals();
_setmbcp(_MB_CP_LOCALE);
TRACE("Attach done\n");
break;
@ -126,7 +121,8 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
msvcrt_free_tls_mem();
if (!msvcrt_free_tls())
return FALSE;
//MSVCRT__free_locale(MSVCRT_locale);
if(global_locale)
MSVCRT__free_locale(global_locale);
if (__winitenv && __winitenv != _wenviron)
FreeEnvironment((char**)__winitenv);

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <windows.h>
#include <internal/wine/msvcrt.h>
#include <internal/locale.h>
#include <locale.h>
#include <mbctype.h>
@ -88,17 +89,11 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
/* Initialization of the WINE code */
msvcrt_init_mt_locks();
//if(!msvcrt_init_locale()) {
// msvcrt_free_mt_locks();
// msvcrt_free_tls_mem();
// return FALSE;
//}
//msvcrt_init_math();
msvcrt_init_io();
//msvcrt_init_console();
//msvcrt_init_args();
//msvcrt_init_signals();
_setmbcp(_MB_CP_LOCALE);
TRACE("Attach done\n");
break;
@ -121,7 +116,8 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
msvcrt_free_tls_mem();
if (!msvcrt_free_tls())
return FALSE;
//MSVCRT__free_locale(MSVCRT_locale);
if(global_locale)
MSVCRT__free_locale(global_locale);
if (__winitenv && __winitenv != _wenviron)
FreeEnvironment((char**)__winitenv);

View file

@ -33,7 +33,7 @@ typedef struct MSVCRT_threadmbcinfostruct {
int ismbcodepage;
int mblcid;
unsigned short mbulinfo[6];
char mbctype[257];
unsigned char mbctype[257];
char mbcasemap[256];
} MSVCRT_threadmbcinfo;

View file

@ -17,5 +17,5 @@
*/
int _ismbbkana(unsigned int c)
{
return (_mbctype[c & 0xff] & _MBKANA);
return (get_mbcinfo()->mbctype[c & 0xff] & _MBKANA);
}

View file

@ -16,5 +16,5 @@
*/
int _ismbbkalnum( unsigned int c )
{
return (_mbctype[c & 0xff] & _MKMOJI);
return (get_mbcinfo()->mbctype[c & 0xff] & _MKMOJI);
}

View file

@ -19,7 +19,7 @@
*/
int _ismbblead(unsigned int c)
{
return (_mbctype[(c&0xff) + 1] & _M1) != 0;
return (get_mbcinfo()->mbctype[(c&0xff) + 1] & _M1) != 0;
}
/*
@ -47,7 +47,7 @@ int _ismbslead( const unsigned char *start, const unsigned char *str)
*/
unsigned char *__p__mbctype(void)
{
return _mbctype;
return get_mbcinfo()->mbctype;
}

View file

@ -18,7 +18,7 @@
int _ismbbpunct(unsigned int c)
{
// (0xA1 <= c <= 0xA6)
return (_mbctype[c & 0xff] & _MBPUNCT);
return (get_mbcinfo()->mbctype[c & 0xff] & _MBPUNCT);
}
//iskana() :(0xA1 <= c <= 0xDF)

View file

@ -22,7 +22,7 @@ size_t _mbclen2(const unsigned int s);
*/
int _ismbbtrail(unsigned int c)
{
return (_mbctype[(c&0xff) + 1] & _M2) != 0;
return (get_mbcinfo()->mbctype[(c&0xff) + 1] & _M2) != 0;
}

View file

@ -426,7 +426,15 @@ errno_t _get_osplatform(unsigned int *pValue)
*/
int *__p___mb_cur_max(void)
{
return &__mb_cur_max;
return &get_locinfo()->mb_cur_max;
}
/*********************************************************************
* ___mb_cur_max_func(MSVCRT.@)
*/
int CDECL ___mb_cur_max_func(void)
{
return get_locinfo()->mb_cur_max;
}
/*

View file

@ -3,6 +3,10 @@
#define __MINGW_IMPORT
#include <ctype.h>
#ifndef _LIBCNT_
#include <precomp.h>
#endif
#undef _pctype
#undef _pwctype
@ -567,10 +571,50 @@ const unsigned short* __cdecl __pwctype_func(void)
return _pwctype;
}
int _isctype (int c, int ctypeFlags)
#ifdef _LIBCNT_
int __cdecl _isctype (int c, int ctypeFlags)
{
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
}
#else
/*********************************************************************
* _isctype_l (MSVCRT.@)
*/
int __cdecl _isctype_l(int c, int type, _locale_t locale)
{
MSVCRT_pthreadlocinfo locinfo;
if(!locale)
locinfo = get_locinfo();
else
locinfo = ((MSVCRT__locale_t)locale)->locinfo;
if (c >= -1 && c <= 255)
return locinfo->pctype[c] & type;
if (locinfo->mb_cur_max != 1 && c > 0)
{
/* FIXME: Is there a faster way to do this? */
WORD typeInfo;
char convert[3], *pconv = convert;
if (locinfo->pctype[(UINT)c >> 8] & _LEADBYTE)
*pconv++ = (UINT)c >> 8;
*pconv++ = c & 0xff;
*pconv = 0;
if (GetStringTypeExA(locinfo->lc_handle[LC_CTYPE],
CT_CTYPE1, convert, convert[1] ? 2 : 1, &typeInfo))
return typeInfo & type;
}
return 0;
}
int __cdecl _isctype (int c, int ctypeFlags)
{
return _isctype_l(c, ctypeFlags, NULL);
}
#endif /* _LIBCNT_ */
/*
* @implemented