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 /*********************************************************************
19 * The parameter n is the number or characters to copy, not the size of
20 * the buffer. Use _mbsnbcpy for a function analogical to strncpy
22 unsigned char* CDECL
_mbsncpy(unsigned char* dst
, const unsigned char* src
, size_t n
)
24 unsigned char* ret
= dst
;
27 if (get_mbcinfo()->ismbcodepage
)
52 if (!(*dst
++ = *src
++)) break;
55 while (n
--) *dst
++ = 0;
59 /*********************************************************************
60 * _mbsnbcpy_s(MSVCRT.@)
62 * Unlike _mbsnbcpy this function does not pad the rest of the dest
65 int CDECL
_mbsnbcpy_s(unsigned char* dst
, size_t size
, const unsigned char* src
, size_t n
)
79 if(get_mbcinfo()->ismbcodepage
)
89 is_lead
= (!is_lead
&& _ismbblead(*src
));
94 if (is_lead
) /* if string ends with a lead, remove it */
124 /*********************************************************************
125 * _mbsnbcpy(MSVCRT.@)
127 * Like strncpy this function doesn't enforce the string to be
130 unsigned char* CDECL
_mbsnbcpy(unsigned char* dst
, const unsigned char* src
, size_t n
)
132 unsigned char* ret
= dst
;
135 if(get_mbcinfo()->ismbcodepage
)
140 is_lead
= (!is_lead
&& _ismbblead(*src
));
145 if (is_lead
) /* if string ends with a lead, remove it */
153 if (!(*dst
++ = *src
++)) break;
156 while (n
--) *dst
++ = 0;