update for HEAD-2003091401
[reactos.git] / lib / crtdll / mbstring / ismblead.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/crtdll/mbstring/ismblead.c
5  * PURPOSE:     Checks for a lead byte 
6  * PROGRAMER:   Boudewijn Dekker
7  * UPDATE HISTORY:
8  *              Modified from Taiji Yamada japanese code system utilities
9  *              12/04/99: Created
10  */
11
12 #include <msvcrt/mbstring.h>
13 #include <msvcrt/stdlib.h>
14 #include <msvcrt/mbctype.h>
15
16 size_t _mbclen2(const unsigned int s);
17
18 char _jctype[257] = {
19 /*-1*/  ___,
20 /*0x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
21 /*1x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
22 /*2x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
23 /*3x*/  ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
24 /*4x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
25 /*5x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
26 /*6x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,
27 /*7x*/  __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,___,
28 /*8x*/  __2,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
29 /*9x*/  _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
30 /*Ax*/  __2,_P2,_P2,_P2,_P2,_P2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
31 /*Bx*/  _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
32 /*Cx*/  _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
33 /*Dx*/  _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,
34 /*Ex*/  _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,
35 /*Fx*/  _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___
36 };
37
38 char *_mbctype = _jctype;
39 /*
40  * @implemented
41  */
42 int _ismbblead(unsigned int c)
43 {
44         return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1);
45 }
46 //int _ismbblead(unsigned int byte)
47 //{
48 //
49 //      return (int)IsDBCSLeadByte(byte) 
50 //}
51
52 /*
53  * @implemented
54  */
55 int _ismbslead( const unsigned char *str, const unsigned char *t)
56 {
57         unsigned char *s = (unsigned char *)str;
58         while(*s != 0 && s != t) 
59         {
60                 
61                 s+= _mbclen2(*s);
62         }               
63         return _ismbblead( *s);
64 }
65