xref: /haiku/src/system/libroot/posix/wchar/wcsncpy.c (revision 7ee53ed3bd2222305c93a4959f8c587c373ed97c)
1 /*
2 ** Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
5 
6 #include <wchar_private.h>
7 
8 
9 wchar_t*
10 __wcsncpy(wchar_t* destIn, const wchar_t* src, size_t n)
11 {
12 	wchar_t* dest = destIn;
13 	const wchar_t* srcEnd = src + n;
14 	const wchar_t* destEnd = dest + n;
15 
16 	while (src < srcEnd && *src != L'\0')
17 		*dest++ = *src++;
18 	while (dest < destEnd)
19 		*dest++ = L'\0';
20 
21 	return destIn;
22 }
23 
24 
25 B_DEFINE_WEAK_ALIAS(__wcsncpy, wcsncpy);
26