- 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

svn path=/trunk/; revision=38173
This commit is contained in:
Gregor Schneider 2008-12-18 18:58:43 +00:00
parent 10ffe93130
commit 1c8d9a1277
4 changed files with 47 additions and 59 deletions

View file

@ -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 @@ size_t _mbclen2(const unsigned int s);
*/
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 @@ int _ismbslead( const unsigned char *str, const unsigned char *t)
*/
const unsigned char *__p__mbctype(void)
{
return _mbctype;
return _mbctype;
}