407a8204cda276c24cc63197485ffe9259e67e23
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/msvcrt/mbstring/mbsncpy.c
5 * PURPOSE: Copies a string to a maximum of n bytes or characters
7 * Copyright 1999 Ariadne
8 * Copyright 1999 Alexandre Julliard
9 * Copyright 2000 Jon Griffths
16 extern int g_mbcp_is_multibyte
;
21 unsigned char* _mbsncpy(unsigned char *dst
, const unsigned char *src
, size_t n
)
23 unsigned char* ret
= dst
;
26 if (g_mbcp_is_multibyte
)
51 if (!(*dst
++ = *src
++)) break;
54 while (n
--) *dst
++ = 0;
60 * The _mbsnbcpy function copies count bytes from src to dest. If src is shorter
61 * than dest, the string is padded with null characters. If dest is less than or
62 * equal to count it is not terminated with a null character.
66 unsigned char * _mbsnbcpy(unsigned char *dst
, const unsigned char *src
, size_t n
)
68 unsigned char* ret
= dst
;
71 if(g_mbcp_is_multibyte
)
76 is_lead
= (!is_lead
&& _ismbblead(*src
));
81 if (is_lead
) /* if string ends with a lead, remove it */
89 if (!(*dst
++ = *src
++)) break;
92 while (n
--) *dst
++ = 0;
97 * Unlike _mbsnbcpy this function does not pad the rest of the dest
100 int CDECL
_mbsnbcpy_s(unsigned char* dst
, size_t size
, const unsigned char* src
, size_t n
)
104 if(!dst
|| size
== 0)
114 if(g_mbcp_is_multibyte
)
124 is_lead
= (!is_lead
&& _ismbblead(*src
));
129 if (is_lead
) /* if string ends with a lead, remove it */