Author: jgardou Date: Thu Dec 13 21:13:06 2012 New Revision: 57910
URL: http://svn.reactos.org/svn/reactos?rev=57910&view=rev Log: [CRT] -fix __lc_codepage confusion -fix implementations of _mbsjistojms and _mbsjmstojis
Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec trunk/reactos/lib/sdk/crt/include/internal/mbstring.h trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h trunk/reactos/lib/sdk/crt/locale/locale.c trunk/reactos/lib/sdk/crt/mbstring/jistojms.c trunk/reactos/lib/sdk/crt/mbstring/jmstojis.c
Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/msvcrt.spe... ============================================================================== --- trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] Thu Dec 13 21:13:06 2012 @@ -156,7 +156,7 @@ @ cdecl __isascii(long) @ cdecl __iscsym(long) @ cdecl __iscsymf(long) -@ extern __lc_codepage MSVCRT___lc_codepage +@ extern __lc_codepage # @ stub __lc_collate # not in XP / 7 @ extern __lc_collate_cp MSVCRT___lc_collate_cp @ extern __lc_handle MSVCRT___lc_handle
Modified: trunk/reactos/lib/sdk/crt/include/internal/mbstring.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/interna... ============================================================================== --- trunk/reactos/lib/sdk/crt/include/internal/mbstring.h [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/include/internal/mbstring.h [iso-8859-1] Thu Dec 13 21:13:06 2012 @@ -39,7 +39,6 @@
#define MAX_LOCALE_LENGTH 256 extern unsigned char _mbctype[257]; -extern unsigned int MSVCRT___lc_codepage; extern char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH];
#if defined (_MSC_VER)
Modified: trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/interna... ============================================================================== --- trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h [iso-8859-1] Thu Dec 13 21:13:06 2012 @@ -25,7 +25,7 @@ #include "windef.h" #include "winbase.h"
-extern int __lc_codepage; +extern unsigned int __lc_codepage; extern int __lc_collate_cp; extern int __mb_cur_max; extern const unsigned short _ctype [257];
Modified: trunk/reactos/lib/sdk/crt/locale/locale.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/locale/locale.c... ============================================================================== --- trunk/reactos/lib/sdk/crt/locale/locale.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/locale/locale.c [iso-8859-1] Thu Dec 13 21:13:06 2012 @@ -31,7 +31,7 @@ #error _pctype should not be defined #endif
-unsigned int MSVCRT___lc_codepage = 0; +unsigned int __lc_codepage = 0; int MSVCRT___lc_collate_cp = 0; LCID MSVCRT___lc_handle[LC_MAX - LC_MIN + 1] = { 0 }; int __mb_cur_max = 1; @@ -622,7 +622,7 @@ */ unsigned int CDECL ___lc_codepage_func(void) { - return MSVCRT___lc_codepage; + return __lc_codepage; }
/********************************************************************* @@ -1391,7 +1391,7 @@ if(locinfo == MSVCRT_locale->locinfo) { int i;
- MSVCRT___lc_codepage = locinfo->lc_codepage; + __lc_codepage = locinfo->lc_codepage; MSVCRT___lc_collate_cp = locinfo->lc_collate_cp; __mb_cur_max = locinfo->mb_cur_max; _pctype = locinfo->pctype; @@ -1488,7 +1488,7 @@ return; 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; __mb_cur_max = MSVCRT_locale->locinfo->mb_cur_max; for(i=LC_MIN; i<=LC_MAX; i++)
Modified: trunk/reactos/lib/sdk/crt/mbstring/jistojms.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/jistoj... ============================================================================== --- trunk/reactos/lib/sdk/crt/mbstring/jistojms.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/mbstring/jistojms.c [iso-8859-1] Thu Dec 13 21:13:06 2012 @@ -33,7 +33,7 @@ { /* Conversion takes place only when codepage is 932. 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 && LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e) @@ -43,7 +43,7 @@ else c += 0x7d;
- if(LOBYTE(c) > 0x7F) + if(LOBYTE(c) >= 0x7F) c += 0x1;
c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
Modified: trunk/reactos/lib/sdk/crt/mbstring/jmstojis.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/jmstoj... ============================================================================== --- trunk/reactos/lib/sdk/crt/mbstring/jmstojis.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/mbstring/jmstojis.c [iso-8859-1] Thu Dec 13 21:13:06 2012 @@ -1,28 +1,34 @@ +#include <precomp.h> #include <mbstring.h> +#include <locale.h>
/* * @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; - c1 = c >> 8; - if (c1 < 0xf0 && _ismbblead(c1) && _ismbbtrail(c2)) { - if (c1 >= 0xe0) - c1 -= 0x40; - c1 -= 0x70; - c1 <<= 1; - if (c2 < 0x9f) { - c1 --; - c2 -= 0x1f; - if (c2 >= (0x80-0x1f)) - c2 --; - } else { - c2 -= 0x7e; + c = (((HIBYTE(c) - 0x81)*2 + 0x21) << 8) | LOBYTE(c); + + if(LOBYTE(c) > 0x7f) + c -= 0x1; + + if(LOBYTE(c) > 0x9d) + c += 0x83; + else + c -= 0x1f; } - return ((c1 << 8) | c2); + else + return 0; /* Codepage is 932, but c can't be converted */ } - return 0; + + return c; }