ppc: cleanup unsupported ppc64 code
[uclibc-ng.git] / libc / string / strlcpy.c
blob83787049a1096707bed33aa5381d71a31110bc1d
1 /*
2 * Copyright (C) 2002 Manuel Novoa III
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
8 #include "_string.h"
10 #ifdef WANT_WIDE
11 # define Wstrlcpy __wcslcpy
12 # define Wstrxfrm wcsxfrm
13 #else
14 # define Wstrlcpy strlcpy
15 # define Wstrxfrm strxfrm
16 #endif
18 /* OpenBSD function:
19 * Copy at most n-1 chars from src to dst and nul-terminate dst.
20 * Returns strlen(src), so truncation occurred if the return value is >= n. */
22 size_t Wstrlcpy(register Wchar *__restrict dst,
23 register const Wchar *__restrict src,
24 size_t n)
26 const Wchar *src0 = src;
27 Wchar dummy[1];
29 if (!n) {
30 dst = dummy;
31 } else {
32 --n;
35 while ((*dst = *src) != 0) {
36 if (n) {
37 --n;
38 ++dst;
40 ++src;
43 return src - src0;
45 #ifndef WANT_WIDE
46 libc_hidden_def(strlcpy)
47 #endif
49 #ifndef __UCLIBC_HAS_LOCALE__
50 strong_alias(Wstrlcpy,Wstrxfrm)
51 #endif