xref: /reactos/sdk/lib/crt/mbstring/mbsset.c (revision 40462c92)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/sdk/crt/mbstring/mbsset.c
5  * PURPOSE:     Fills a string with a multibyte character
6  * PROGRAMER:   Ariadne
7  * UPDATE HISTORY:
8  *              12/04/99: Created
9  */
10 
11 #include <mbstring.h>
12 
13 size_t _mbclen2(const unsigned int s);
14 
15 /*
16  * @implemented
17  */
18 unsigned char * _mbsset(unsigned char *src, unsigned int c)
19 {
20 	unsigned char *char_src = src;
21 	unsigned short *short_src = (unsigned short *)src;
22 
23 	if ( _mbclen2(c) == 1 ) {
24 
25 		while(*char_src != 0) {
26 			*char_src = c;
27 			char_src++;
28 		}
29 		*char_src = 0;
30 	}
31 	else {
32 		while(*short_src != 0) {
33 			*short_src = c;
34 			short_src++;
35 		}
36 		*short_src = 0;
37 	}
38 
39 	return src;
40 }
41