xref: /reactos/sdk/lib/crt/mbstring/mbslwr.c (revision 40462c92)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/sdk/crt/mbstring/mbslwr.c
5  * PURPOSE:     Multibyte lowercase functions
6  * PROGRAMER:   Eric Kohl
7  *              Samuel Serapion, adapted from PROJECT C Library
8  */
9 
10 #include <precomp.h>
11 #include <mbstring.h>
12 #include <ctype.h>
13 
14 unsigned int _mbbtolower(unsigned int c)
15 {
16 	if (!_ismbblead(c) )
17 		return tolower(c);
18 	return c;
19 }
20 
21 /*
22  * @implemented
23  */
24 unsigned int _mbctolower(unsigned int c)
25 {
26     return _ismbcupper (c) ? c + 0x21 : c;
27 }
28 
29 /*
30  * @implemented
31  */
32 unsigned char * _mbslwr(unsigned char *x)
33 {
34     unsigned char *y=x;
35 
36     if (x == NULL)
37     {
38         return NULL;
39     }
40 
41     while (*y)
42     {
43         if (!_ismbblead(*y))
44         {
45             *y = tolower(*y);
46             y++;
47         }
48         else
49         {
50             *y = _mbctolower(*(unsigned short *)y);
51             y++;
52         }
53     }
54     return x;
55 }
56