]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/string/stpncpy.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / string / stpncpy.c
1 /*
2  * Copyright (C) 2002     Manuel Novoa III
3  * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7
8 #include "_string.h"
9
10 #ifdef WANT_WIDE
11 # define Wstpncpy wcpncpy
12 #else
13 # define Wstpncpy stpncpy
14 #endif
15
16 Wchar *Wstpncpy(register Wchar * __restrict s1,
17                                 register const Wchar * __restrict s2,
18                                 size_t n)
19 {
20         Wchar *s = s1;
21         const Wchar *p = s2;
22
23         while (n) {
24                 if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
25                 ++s;
26                 --n;
27         }
28         return s1 + (s2 - p);
29 }