Author: jgardou
Date: Sun Dec 9 11:42:02 2012
New Revision: 57838
URL:
http://svn.reactos.org/svn/reactos?rev=57838&view=rev
Log:
[CRT]
- make some functions locale aware
- add implementation of ___mb_cur_max_func and _isctype_l
[MSVCRT20]
- keep up with msvcrt
[MSVCRT40]
- ditto
Modified:
trunk/reactos/dll/win32/msvcrt/msvcrt.spec
trunk/reactos/dll/win32/msvcrt20/msvcrt20.c
trunk/reactos/dll/win32/msvcrt40/msvcrt40.c
trunk/reactos/lib/sdk/crt/include/internal/locale.h
trunk/reactos/lib/sdk/crt/mbstring/iskana.c
trunk/reactos/lib/sdk/crt/mbstring/ismbkaln.c
trunk/reactos/lib/sdk/crt/mbstring/ismblead.c
trunk/reactos/lib/sdk/crt/mbstring/ismbpun.c
trunk/reactos/lib/sdk/crt/mbstring/ismbtrl.c
trunk/reactos/lib/sdk/crt/misc/environ.c
trunk/reactos/lib/sdk/crt/string/ctype.c
Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/msvcrt.sp…
==============================================================================
--- trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -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
Modified: trunk/reactos/dll/win32/msvcrt20/msvcrt20.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt20/msvcrt2…
==============================================================================
--- trunk/reactos/dll/win32/msvcrt20/msvcrt20.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msvcrt20/msvcrt20.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -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 @@
/* 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 @@
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);
@@ -169,4 +165,4 @@
__wgetmainargs( argc, wargv, wenvp, expand_wildcards, &new_mode );
}
-/* EOF */
+/* EOF */
Modified: trunk/reactos/dll/win32/msvcrt40/msvcrt40.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt40/msvcrt4…
==============================================================================
--- trunk/reactos/dll/win32/msvcrt40/msvcrt40.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msvcrt40/msvcrt40.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -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 @@
/* 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 @@
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);
@@ -140,4 +136,4 @@
return TRUE;
}
-/* EOF */
+/* EOF */
Modified: trunk/reactos/lib/sdk/crt/include/internal/locale.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/intern…
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/locale.h [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/locale.h [iso-8859-1] Sun Dec 9 11:42:02
2012
@@ -33,7 +33,7 @@
int ismbcodepage;
int mblcid;
unsigned short mbulinfo[6];
- char mbctype[257];
+ unsigned char mbctype[257];
char mbcasemap[256];
} MSVCRT_threadmbcinfo;
Modified: trunk/reactos/lib/sdk/crt/mbstring/iskana.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/iskan…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/iskana.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/iskana.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -17,5 +17,5 @@
*/
int _ismbbkana(unsigned int c)
{
- return (_mbctype[c & 0xff] & _MBKANA);
+ return (get_mbcinfo()->mbctype[c & 0xff] & _MBKANA);
}
Modified: trunk/reactos/lib/sdk/crt/mbstring/ismbkaln.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/ismbk…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/ismbkaln.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/ismbkaln.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -16,5 +16,5 @@
*/
int _ismbbkalnum( unsigned int c )
{
- return (_mbctype[c & 0xff] & _MKMOJI);
+ return (get_mbcinfo()->mbctype[c & 0xff] & _MKMOJI);
}
Modified: trunk/reactos/lib/sdk/crt/mbstring/ismblead.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/ismbl…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/ismblead.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/ismblead.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -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 @@
*/
unsigned char *__p__mbctype(void)
{
- return _mbctype;
+ return get_mbcinfo()->mbctype;
}
Modified: trunk/reactos/lib/sdk/crt/mbstring/ismbpun.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/ismbp…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/ismbpun.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/ismbpun.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -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)
Modified: trunk/reactos/lib/sdk/crt/mbstring/ismbtrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/ismbt…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/ismbtrl.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/ismbtrl.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -22,7 +22,7 @@
*/
int _ismbbtrail(unsigned int c)
{
- return (_mbctype[(c&0xff) + 1] & _M2) != 0;
+ return (get_mbcinfo()->mbctype[(c&0xff) + 1] & _M2) != 0;
}
Modified: trunk/reactos/lib/sdk/crt/misc/environ.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/misc/environ.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/misc/environ.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/misc/environ.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -426,7 +426,15 @@
*/
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;
}
/*
Modified: trunk/reactos/lib/sdk/crt/string/ctype.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/ctype.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/ctype.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/ctype.c [iso-8859-1] Sun Dec 9 11:42:02 2012
@@ -2,6 +2,10 @@
#undef __MINGW_IMPORT
#define __MINGW_IMPORT
#include <ctype.h>
+
+#ifndef _LIBCNT_
+#include <precomp.h>
+#endif
#undef _pctype
#undef _pwctype
@@ -567,10 +571,50 @@
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