wcpncpy.c revision 7efc2e3a0e70a9fd3c07470dc20e99bbb71628d5
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
9wchar_t*
10__wcpncpy(wchar_t* dest, const wchar_t* src, size_t n)
11{
12	const wchar_t* srcEnd = src + n;
13	wchar_t* destEnd = dest + n;
14
15	while (src < srcEnd && *src != L'\0')
16		*dest++ = *src++;
17
18	if (dest < destEnd) {
19		while (--destEnd >= dest)
20			*destEnd = L'\0';
21	}
22
23	return dest;
24}
25
26
27B_DEFINE_WEAK_ALIAS(__wcpncpy, wcpncpy);
28