xref: /reactos/sdk/lib/crt/mbstring/ismblead.c (revision 321bcc05)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/sdk/crt/mbstring/ismblead.c
5  * PURPOSE:      Checks for a leading byte
6  * PROGRAMERS:
7  *              Copyright 1999 Ariadne, Taiji Yamada
8  *              Copyright 1999 Alexandre Julliard
9  *              Copyright 2000 Jon Griffths
10  *              Copyright 2008 Samuel Serapion adapted from PROJECT C Library
11  *
12  */
13 
14 #include <precomp.h>
15 #include <mbctype.h>
16 
17 /*
18  * @implemented
19  */
20 int _ismbblead(unsigned int c)
21 {
22   return (get_mbcinfo()->mbctype[(c&0xff) + 1] & _M1) != 0;
23 }
24 
25 /*
26  * @implemented
27  */
28 int _ismbslead( const unsigned char *start, const unsigned char *str)
29 {
30   int lead = 0;
31 
32   /* Lead bytes can also be trail bytes so we need to analyse the string
33    */
34   while (start <= str)
35   {
36     if (!*start)
37       return 0;
38     lead = !lead && _ismbblead(*start);
39     start++;
40   }
41 
42   return lead ? -1 : 0;
43 }
44 
45 /*
46  * @implemented
47  */
48 unsigned char *__p__mbctype(void)
49 {
50   return get_mbcinfo()->mbctype;
51 }
52 
53 
54