OSDN Git Service

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