msvcrt: Export various locale and codepage variables.

This commit is contained in:
Alexandre Julliard 2007-01-16 12:08:59 +01:00
parent 6a058830f3
commit 6f9ad1b981
4 changed files with 23 additions and 18 deletions

View File

@ -45,7 +45,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
#define MAX_LOCALE_LENGTH 256
char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH];
LCID MSVCRT_current_lc_all_lcid;
int msvcrt_current_lc_all_cp;
int MSVCRT___lc_codepage;
int MSVCRT___lc_collate_cp;
HANDLE MSVCRT___lc_handle[MSVCRT_LC_MAX - MSVCRT_LC_MIN + 1];
/* MT */
#define LOCK_LOCALE _mlock(_SETLOCALE_LOCK);
@ -275,7 +277,8 @@ static void msvcrt_set_ctype(unsigned int codepage, LCID lcid)
unsigned char *traverse = (unsigned char *)cp.LeadByte;
memset(MSVCRT_current_ctype, 0, sizeof(MSVCRT__ctype));
msvcrt_current_lc_all_cp = codepage;
MSVCRT___lc_codepage = codepage;
MSVCRT___lc_collate_cp = codepage;
/* Switch ctype macros to MBCS if needed */
MSVCRT___mb_cur_max = cp.MaxCharSize;
@ -342,7 +345,8 @@ char* CDECL MSVCRT_setlocale(int category, const char* locale)
{
MSVCRT_current_lc_all[0] = 'C';
MSVCRT_current_lc_all[1] = '\0';
msvcrt_current_lc_all_cp = GetACP();
MSVCRT___lc_codepage = GetACP();
MSVCRT___lc_collate_cp = GetACP();
switch (category) {
case MSVCRT_LC_ALL:
@ -535,22 +539,22 @@ int CDECL _setmbcp(int cp)
LOCK_LOCALE;
if ( cp > _MB_CP_SBCS)
{
if( msvcrt_current_lc_all_cp != cp)
if( MSVCRT___lc_codepage != cp)
/* FIXME: set ctype behaviour for this cp */
msvcrt_current_lc_all_cp = cp;
MSVCRT___lc_codepage = cp;
}
else if(cp == _MB_CP_ANSI)
{
msvcrt_current_lc_all_cp = GetACP();
MSVCRT___lc_codepage = GetACP();
}
else if(cp == _MB_CP_OEM)
{
msvcrt_current_lc_all_cp = GetOEMCP();
MSVCRT___lc_codepage = GetOEMCP();
}
else if(cp == _MB_CP_LOCALE)
{
GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER,
(WCHAR *)&msvcrt_current_lc_all_cp, sizeof(INT)/sizeof(WCHAR) );
(WCHAR *)&MSVCRT___lc_codepage, sizeof(INT)/sizeof(WCHAR) );
}
else if(cp == _MB_CP_SBCS)
{
@ -560,8 +564,9 @@ int CDECL _setmbcp(int cp)
{
FIXME ("Unreal codepages (e.g. %d) not implemented\n", cp);
}
MSVCRT___lc_collate_cp = MSVCRT___lc_codepage;
UNLOCK_LOCALE;
TRACE("(%d) -> %d\n", cp, msvcrt_current_lc_all_cp);
TRACE("(%d) -> %d\n", cp, MSVCRT___lc_codepage);
return 0;
}
@ -570,7 +575,7 @@ int CDECL _setmbcp(int cp)
*/
int CDECL _getmbcp(void)
{
return msvcrt_current_lc_all_cp;
return MSVCRT___lc_codepage;
}
/*********************************************************************

View File

@ -46,7 +46,7 @@ static MSVCRT_wchar_t msvcrt_mbc_to_wc(unsigned int ch)
mbch[1] = ch & 0xff;
n_chars = 2;
}
if (!MultiByteToWideChar(msvcrt_current_lc_all_cp, 0, mbch, n_chars, &chW, 1))
if (!MultiByteToWideChar(MSVCRT___lc_codepage, 0, mbch, n_chars, &chW, 1))
{
WARN("MultiByteToWideChar failed on %x\n", ch);
return 0;
@ -745,7 +745,7 @@ unsigned int CDECL _mbbtombc(unsigned int c)
int CDECL _ismbbkana(unsigned int c)
{
/* FIXME: use lc_ctype when supported, not lc_all */
if(msvcrt_current_lc_all_cp == 932)
if(MSVCRT___lc_codepage == 932)
{
/* Japanese/Katakana, CP 932 */
return (c >= 0xa1 && c <= 0xdf);
@ -855,7 +855,7 @@ int CDECL _ismbcpunct(unsigned int ch)
int CDECL _ismbchira(unsigned int c)
{
/* FIXME: use lc_ctype when supported, not lc_all */
if(msvcrt_current_lc_all_cp == 932)
if(MSVCRT___lc_codepage == 932)
{
/* Japanese/Hiragana, CP 932 */
return (c >= 0x829f && c <= 0x82f1);
@ -869,7 +869,7 @@ int CDECL _ismbchira(unsigned int c)
int CDECL _ismbckata(unsigned int c)
{
/* FIXME: use lc_ctype when supported, not lc_all */
if(msvcrt_current_lc_all_cp == 932)
if(MSVCRT___lc_codepage == 932)
{
if(c < 256)
return _ismbbkana(c);

View File

@ -111,7 +111,7 @@ typedef struct __thread_data thread_data_t;
extern thread_data_t *msvcrt_get_thread_data(void);
extern int msvcrt_current_lc_all_cp;
extern int MSVCRT___lc_codepage;
void msvcrt_set_errno(int);
char* msvcrt_strndup(const char*,unsigned int);

View File

@ -96,9 +96,10 @@
@ cdecl __isascii(long) MSVCRT___isascii
@ cdecl __iscsym(long) MSVCRT___iscsym
@ cdecl __iscsymf(long) MSVCRT___iscsymf
# extern __lc_codepage
@ extern __lc_codepage MSVCRT___lc_codepage
@ stub __lc_collate
# extern __lc_handle
@ extern __lc_collate_cp MSVCRT___lc_collate_cp
@ extern __lc_handle MSVCRT___lc_handle
@ cdecl __lconv_init()
@ extern __mb_cur_max MSVCRT___mb_cur_max
@ cdecl __p___argc()
@ -767,4 +768,3 @@
@ cdecl wctomb(ptr long) MSVCRT_wctomb
@ varargs wprintf(wstr) MSVCRT_wprintf
@ varargs wscanf(wstr) MSVCRT_wscanf
# extern __lc_collate_cp