Author: gschneider
Date: Thu Dec 18 12:58:43 2008
New Revision: 38173
URL:
http://svn.reactos.org/svn/reactos?rev=38173&view=rev
Log:
- Remove duplicate harcoded _mbctype, rename MSVCRT_mbctype to fit the new role
- Update related functions _ismbblead, _ismbslead, _ismbbtrail, _ismbstrail to use Wine
_mbctype indexing
- Fixes 28 msvcrt string tests, 33 left
- Minor header updates
Modified:
trunk/reactos/lib/sdk/crt/locale/locale.c
trunk/reactos/lib/sdk/crt/mbstring/ismbc.c
trunk/reactos/lib/sdk/crt/mbstring/ismblead.c
trunk/reactos/lib/sdk/crt/mbstring/ismbtrl.c
Modified: trunk/reactos/lib/sdk/crt/locale/locale.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/locale/locale.…
==============================================================================
--- 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 18 12:58:43 2008
@@ -27,7 +27,7 @@
*/
#define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
-unsigned char MSVCRT_mbctype[257] = { 0 };
+unsigned char _mbctype[257] = { 0 };
static int g_mbcp_is_multibyte = 0;
/* It seems that the data about valid trail bytes is not available from kernel32
@@ -671,13 +671,13 @@
}
/* setup the _mbctype */
- memset(MSVCRT_mbctype, 0, sizeof(MSVCRT_mbctype));
+ memset(_mbctype, 0, sizeof(_mbctype));
bytes = cpi.LeadByte;
while (bytes[0] || bytes[1])
{
for (i = bytes[0]; i <= bytes[1]; i++)
- MSVCRT_mbctype[i + 1] |= _M1;
+ _mbctype[i + 1] |= _M1;
bytes += 2;
}
@@ -698,7 +698,7 @@
while (bytes[0] || bytes[1])
{
for (i = bytes[0]; i <= bytes[1]; i++)
- MSVCRT_mbctype[i + 1] |= _M2;
+ _mbctype[i + 1] |= _M2;
bytes += 2;
}
break;
@@ -713,7 +713,7 @@
*/
charcount = 0;
for (i = 0; i < 256; i++)
- if (!(MSVCRT_mbctype[i + 1] & _M1))
+ if (!(_mbctype[i + 1] & _M1))
bufA[charcount++] = i;
ret = MultiByteToWideChar(newcp, 0, bufA, charcount, bufW, charcount);
@@ -724,12 +724,12 @@
curr_type = chartypes;
for (i = 0; i < 256; i++)
- if (!(MSVCRT_mbctype[i + 1] & _M1))
+ if (!(_mbctype[i + 1] & _M1))
{
if ((*curr_type) & C1_UPPER)
- MSVCRT_mbctype[i + 1] |= _SBUP;
+ _mbctype[i + 1] |= _SBUP;
if ((*curr_type) & C1_LOWER)
- MSVCRT_mbctype[i + 1] |= _SBLOW;
+ _mbctype[i + 1] |= _SBLOW;
curr_type++;
}
@@ -741,9 +741,9 @@
* also faster execution.
*/
for (i = 161; i <= 165; i++)
- MSVCRT_mbctype[i + 1] |= _MP;
+ _mbctype[i + 1] |= _MP;
for (i = 166; i <= 223; i++)
- MSVCRT_mbctype[i + 1] |= _MS;
+ _mbctype[i + 1] |= _MS;
}
MSVCRT___lc_collate_cp = MSVCRT___lc_codepage = newcp;
Modified: trunk/reactos/lib/sdk/crt/mbstring/ismbc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/ismbc…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/ismbc.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/ismbc.c [iso-8859-1] Thu Dec 18 12:58:43 2008
@@ -13,26 +13,6 @@
#include <precomp.h>
#include <mbstring.h>
#include <mbctype.h>
-
-unsigned char _mbctype[257] = {
- 0, /* EOF */
- 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , /* 0 */
- 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , /* 1 */
- B ,P ,P ,P ,P ,P ,P ,P ,P ,P ,P ,P ,P ,P ,P ,P , /* 2 */
- D ,D ,D ,P ,D ,D ,D ,D ,D ,D ,P ,P ,P ,P ,P ,P , /* 3 */
- PT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT, /* 4 */
- AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,PT,PT,PT,PT,PT, /* 5 */
- PT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT, /* 6 */
- AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,AT,PT,PT,PT,PT,0 , /* 7 */
- T ,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT, /* 8 */
- LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT, /* 9 */
- T ,GT,GT,GT,GT,GT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT, /* A */
- KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT, /* B */
- KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT, /* C */
- KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,KT,GT,GT, /* D */
- LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT, /* E */
- LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,LT,0 ,0 ,0 , /* F */
-};
/*
* @implemented
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] Thu Dec 18 12:58:43 2008
@@ -1,16 +1,18 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/sdk/crt/mbstring/iskana.c
- * PURPOSE:
- * PROGRAMER:
- * UPDATE HISTORY:
- * 12/04/99: Ariadne, Taiji Yamada Created
- * 05/30/08: Samuel Serapion adapted from PROJECT C Library
+ * FILE: lib/sdk/crt/mbstring/ismblead.c
+ * PURPOSE: Checks for a leading byte
+ * PROGRAMERS:
+ * Copyright 1999 Ariadne, Taiji Yamada
+ * Copyright 1999 Alexandre Julliard
+ * Copyright 2000 Jon Griffths
+ * Copyright 2008 Samuel Serapion adapted from PROJECT C Library
*
*/
#include <precomp.h>
+#include <mbctype.h>
size_t _mbclen2(const unsigned int s);
@@ -19,21 +21,27 @@
*/
int _ismbblead(unsigned int c)
{
- return (_mbctype[c & 0xff] & _MLEAD);
+ return (_mbctype[(c&0xff) + 1] & _M1) != 0;
}
/*
* @implemented
*/
-int _ismbslead( const unsigned char *str, const unsigned char *t)
+int _ismbslead( const unsigned char *start, const unsigned char *str)
{
- unsigned char *s = (unsigned char *)str;
- while(*s != 0 && s != t)
- {
+ int lead = 0;
- s+= _mbclen2(*s);
- }
- return _ismbblead( *s);
+ /* Lead bytes can also be trail bytes so we need to analyse the string
+ */
+ while (start <= str)
+ {
+ if (!*start)
+ return 0;
+ lead = !lead && _ismbblead(*start);
+ start++;
+ }
+
+ return lead ? -1 : 0;
}
/*
@@ -41,7 +49,7 @@
*/
const unsigned char *__p__mbctype(void)
{
- return _mbctype;
+ return _mbctype;
}
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] Thu Dec 18 12:58:43 2008
@@ -1,14 +1,17 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/mbstring/ismbtrl.c
+ * FILE: lib/sdk/crt/mbstring/ismbtrl.c
* PURPOSE: Checks for a trailing byte
- * PROGRAMER: Ariadne
- * UPDATE HISTORY:
- * 12/04/99: Created
+ * PROGRAMERS:
+ * Copyright 1999 Ariadne
+ * Copyright 1999 Alexandre Julliard
+ * Copyright 2000 Jon Griffths
+ *
*/
#include <precomp.h>
+#include <mbctype.h>
size_t _mbclen2(const unsigned int s);
@@ -19,21 +22,18 @@
*/
int _ismbbtrail(unsigned int c)
{
- return (_mbctype[c & 0xff] & _MTRAIL);
+ return (_mbctype[(c&0xff) + 1] & _M2) != 0;
}
/*
* @implemented
*/
-int _ismbstrail( const unsigned char *str, const unsigned char *t)
+int _ismbstrail( const unsigned char *start, const unsigned char *str)
{
- unsigned char *s = (unsigned char *)str;
- while(*s != 0 && s != t)
- {
-
- s+= _mbclen2(*s);
- }
-
- return _ismbbtrail(*s);
+ /* Note: this function doesn't check _ismbbtrail */
+ if ((str > start) && _ismbslead(start, str-1))
+ return -1;
+ else
+ return 0;
}