1 /* 2 ** Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved. 3 ** Distributed under the terms of the MIT License. 4 */ 5 6 #include <wchar_private.h> 7 8 9 wchar_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 27 B_DEFINE_WEAK_ALIAS(__wcpncpy, wcpncpy); 28