mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:45:40 +00:00
[CRT]
-fix __lc_codepage confusion -fix implementations of _mbsjistojms and _mbsjmstojis svn path=/trunk/; revision=57910
This commit is contained in:
parent
bc5d860b9e
commit
301e93be58
6 changed files with 32 additions and 27 deletions
|
@ -156,7 +156,7 @@
|
||||||
@ cdecl __isascii(long)
|
@ cdecl __isascii(long)
|
||||||
@ cdecl __iscsym(long)
|
@ cdecl __iscsym(long)
|
||||||
@ cdecl __iscsymf(long)
|
@ cdecl __iscsymf(long)
|
||||||
@ extern __lc_codepage MSVCRT___lc_codepage
|
@ extern __lc_codepage
|
||||||
# @ stub __lc_collate # not in XP / 7
|
# @ stub __lc_collate # not in XP / 7
|
||||||
@ extern __lc_collate_cp MSVCRT___lc_collate_cp
|
@ extern __lc_collate_cp MSVCRT___lc_collate_cp
|
||||||
@ extern __lc_handle MSVCRT___lc_handle
|
@ extern __lc_handle MSVCRT___lc_handle
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#define MAX_LOCALE_LENGTH 256
|
#define MAX_LOCALE_LENGTH 256
|
||||||
extern unsigned char _mbctype[257];
|
extern unsigned char _mbctype[257];
|
||||||
extern unsigned int MSVCRT___lc_codepage;
|
|
||||||
extern char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH];
|
extern char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH];
|
||||||
|
|
||||||
#if defined (_MSC_VER)
|
#if defined (_MSC_VER)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
|
||||||
extern int __lc_codepage;
|
extern unsigned int __lc_codepage;
|
||||||
extern int __lc_collate_cp;
|
extern int __lc_collate_cp;
|
||||||
extern int __mb_cur_max;
|
extern int __mb_cur_max;
|
||||||
extern const unsigned short _ctype [257];
|
extern const unsigned short _ctype [257];
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#error _pctype should not be defined
|
#error _pctype should not be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int MSVCRT___lc_codepage = 0;
|
unsigned int __lc_codepage = 0;
|
||||||
int MSVCRT___lc_collate_cp = 0;
|
int MSVCRT___lc_collate_cp = 0;
|
||||||
LCID MSVCRT___lc_handle[LC_MAX - LC_MIN + 1] = { 0 };
|
LCID MSVCRT___lc_handle[LC_MAX - LC_MIN + 1] = { 0 };
|
||||||
int __mb_cur_max = 1;
|
int __mb_cur_max = 1;
|
||||||
|
@ -622,7 +622,7 @@ LCID* CDECL ___lc_handle_func(void)
|
||||||
*/
|
*/
|
||||||
unsigned int CDECL ___lc_codepage_func(void)
|
unsigned int CDECL ___lc_codepage_func(void)
|
||||||
{
|
{
|
||||||
return MSVCRT___lc_codepage;
|
return __lc_codepage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -1391,7 +1391,7 @@ char* CDECL setlocale(int category, const char* locale)
|
||||||
if(locinfo == MSVCRT_locale->locinfo) {
|
if(locinfo == MSVCRT_locale->locinfo) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
MSVCRT___lc_codepage = locinfo->lc_codepage;
|
__lc_codepage = locinfo->lc_codepage;
|
||||||
MSVCRT___lc_collate_cp = locinfo->lc_collate_cp;
|
MSVCRT___lc_collate_cp = locinfo->lc_collate_cp;
|
||||||
__mb_cur_max = locinfo->mb_cur_max;
|
__mb_cur_max = locinfo->mb_cur_max;
|
||||||
_pctype = locinfo->pctype;
|
_pctype = locinfo->pctype;
|
||||||
|
@ -1488,7 +1488,7 @@ void __init_global_locale()
|
||||||
return;
|
return;
|
||||||
global_locale = MSVCRT__create_locale(0, "C");
|
global_locale = MSVCRT__create_locale(0, "C");
|
||||||
|
|
||||||
MSVCRT___lc_codepage = MSVCRT_locale->locinfo->lc_codepage;
|
__lc_codepage = MSVCRT_locale->locinfo->lc_codepage;
|
||||||
MSVCRT___lc_collate_cp = MSVCRT_locale->locinfo->lc_collate_cp;
|
MSVCRT___lc_collate_cp = MSVCRT_locale->locinfo->lc_collate_cp;
|
||||||
__mb_cur_max = MSVCRT_locale->locinfo->mb_cur_max;
|
__mb_cur_max = MSVCRT_locale->locinfo->mb_cur_max;
|
||||||
for(i=LC_MIN; i<=LC_MAX; i++)
|
for(i=LC_MIN; i<=LC_MAX; i++)
|
||||||
|
|
|
@ -33,7 +33,7 @@ unsigned int _mbcjistojms(unsigned int c)
|
||||||
{
|
{
|
||||||
/* Conversion takes place only when codepage is 932.
|
/* Conversion takes place only when codepage is 932.
|
||||||
In all other cases, c is returned unchanged */
|
In all other cases, c is returned unchanged */
|
||||||
if(MSVCRT___lc_codepage == 932)
|
if(get_mbcinfo()->mbcodepage == 932)
|
||||||
{
|
{
|
||||||
if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
|
if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
|
||||||
LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
|
LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
|
||||||
|
@ -43,7 +43,7 @@ unsigned int _mbcjistojms(unsigned int c)
|
||||||
else
|
else
|
||||||
c += 0x7d;
|
c += 0x7d;
|
||||||
|
|
||||||
if(LOBYTE(c) > 0x7F)
|
if(LOBYTE(c) >= 0x7F)
|
||||||
c += 0x1;
|
c += 0x1;
|
||||||
|
|
||||||
c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
|
c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
|
||||||
|
|
|
@ -1,28 +1,34 @@
|
||||||
|
#include <precomp.h>
|
||||||
#include <mbstring.h>
|
#include <mbstring.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
unsigned int _mbcjmstojis(unsigned int c)
|
unsigned int __cdecl _mbcjmstojis(unsigned int c)
|
||||||
{
|
{
|
||||||
int c1, c2;
|
/* Conversion takes place only when codepage is 932.
|
||||||
|
In all other cases, c is returned unchanged */
|
||||||
|
if(get_mbcinfo()->mbcodepage == 932)
|
||||||
|
{
|
||||||
|
if(_ismbclegal(c) && HIBYTE(c) < 0xf0)
|
||||||
|
{
|
||||||
|
if(HIBYTE(c) >= 0xe0)
|
||||||
|
c -= 0x4000;
|
||||||
|
|
||||||
c2 = (unsigned char)c;
|
c = (((HIBYTE(c) - 0x81)*2 + 0x21) << 8) | LOBYTE(c);
|
||||||
c1 = c >> 8;
|
|
||||||
if (c1 < 0xf0 && _ismbblead(c1) && _ismbbtrail(c2)) {
|
if(LOBYTE(c) > 0x7f)
|
||||||
if (c1 >= 0xe0)
|
c -= 0x1;
|
||||||
c1 -= 0x40;
|
|
||||||
c1 -= 0x70;
|
if(LOBYTE(c) > 0x9d)
|
||||||
c1 <<= 1;
|
c += 0x83;
|
||||||
if (c2 < 0x9f) {
|
else
|
||||||
c1 --;
|
c -= 0x1f;
|
||||||
c2 -= 0x1f;
|
|
||||||
if (c2 >= (0x80-0x1f))
|
|
||||||
c2 --;
|
|
||||||
} else {
|
|
||||||
c2 -= 0x7e;
|
|
||||||
}
|
}
|
||||||
return ((c1 << 8) | c2);
|
else
|
||||||
|
return 0; /* Codepage is 932, but c can't be converted */
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue