38b05d8d62d304e004ef7a3eb12a8b89c7500044
[reactos.git] / reactos / lib / crtdll / old cruft / mbstring / mbsncat.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/crtdll/mbstring/mbsset.c
5 * PURPOSE: Concatenate two multi byte string to maximum of n characters or bytes
6 * PROGRAMER: Boudewijn Dekker
7 * UPDATE HISTORY:
8 * 12/04/99: Created
9 */
10
11 #include <msvcrt/mbstring.h>
12 #include <msvcrt/string.h>
13
14 size_t _mbclen2(const unsigned int s);
15
16 /*
17 * @implemented
18 */
19 unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n)
20 {
21 char *d = (char *)dst;
22 char *s = (char *)src;
23 if (n != 0) {
24 d = dst + strlen(dst); // get the end of string
25 d += _mbclen2(*d); // move 1 or 2 up
26
27 do {
28 if ((*d++ = *s++) == 0)
29 {
30 while (--n != 0)
31 *d++ = 0;
32 break;
33 }
34 if (!_ismbblead(*s) )
35 n--;
36 } while (n > 0);
37 }
38 return dst;
39 }
40
41 /*
42 * @implemented
43 */
44 unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n)
45 {
46 char *d;
47 char *s = (char *)src;
48 if (n != 0) {
49 d = dst + strlen(dst); // get the end of string
50 d += _mbclen2(*d); // move 1 or 2 up
51
52 do {
53 if ((*d++ = *s++) == 0)
54 {
55 while (--n != 0)
56 *d++ = 0;
57 break;
58 }
59 if ( !(n==1 && _ismbblead(*s)) )
60 n--;
61 } while (n > 0);
62 }
63 return dst;
64 }