xref: /haiku/src/system/libroot/posix/wchar/wcslcpy.c (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2 ** Copyright 2002, Manuel J. Petit.
3 ** Copyright 2011, Oliver Tappe <zooey@hirschkafer.de>.
4 ** All rights reserved. Distributed under the terms of the NewOS License.
5 */
6 
7 #include <wchar_private.h>
8 
9 
10 size_t
11 __wcslcpy(wchar_t* dest, const wchar_t* source, size_t maxLength)
12 {
13 	size_t i;
14 
15 	if (maxLength == 0)
16 		return __wcslen(source);
17 
18 	for (i = 0; i < maxLength - 1 && *source != L'\0'; ++i)
19 		*dest++ = *source++;
20 
21 	*dest++ = 0;
22 
23 	return i + __wcslen(source);
24 }
25 
26 
27 B_DEFINE_WEAK_ALIAS(__wcslcpy, wcslcpy);
28