OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / 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 libc_hidden_proto(stpncpy)
14 # define Wstpncpy stpncpy
15 #endif
16
17 Wchar *Wstpncpy(register Wchar * __restrict s1,
18                                 register const Wchar * __restrict s2,
19                                 size_t n)
20 {
21         Wchar *s = s1;
22         const Wchar *p = s2;
23
24 #ifdef __BCC__
25         while (n--) {
26                 if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
27                 ++s;
28         }
29         return s1 + (s2 - p);
30 #else
31         while (n) {
32                 if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
33                 ++s;
34                 --n;
35         }
36         return s1 + (s2 - p);
37 #endif
38 }
39
40 #ifndef WANT_WIDE
41 libc_hidden_def(stpncpy)
42 #endif