3 <<wcslcat>>---concatenate wide-character strings to specified length
7 size_t wcslcat(wchar_t *<[dst]>, const wchar_t *<[src]>, size_t <[siz]>);
11 size_t wcslcat(<[dst]>, <[src]>, <[siz]>
13 const wchar_t *<[src]>;
17 The <<wcslcat>> function appends wide-characters from <[src]> to
18 end of the <[dst]> wide-character string so that the resultant
19 wide-character string is not more than <[siz]> wide-characters
20 including terminating null wide-character code. A terminating
21 null wide-character is always added unless <[siz]> is 0. Thus,
22 the maximum number of wide-characters that can be appended from
23 <[src]> is <[siz]> - 1. If copying takes place between objects
24 that overlap, the behaviour is undefined.
27 Wide-character string length of initial <[dst]> plus the
28 wide-character string length of <[src]> (does not include
29 terminating null wide-characters). If the return value is
30 greater than or equal to <[siz]>, then truncation occurred and
31 not all wide-characters from <[src]> were appended.
34 No supporting OS subroutines are required.
37 /* $NetBSD: wcslcat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $ */
38 /* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */
41 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
42 * All rights reserved.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. The name of the author may not be used to endorse or promote products
53 * derived from this software without specific prior written permission.
55 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
56 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
57 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
58 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
59 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
60 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
61 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
62 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
63 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
64 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71 * Appends src to string dst of size siz (unlike wcsncat, siz is the
72 * full size of dst, not space left). At most siz-1 characters
73 * will be copied. Always NUL terminates (unless siz == 0).
74 * Returns wcslen(initial dst) + wcslen(src); if retval >= siz,
75 * truncation occurred.
78 _DEFUN (wcslcat
, (dst
, src
, siz
),
80 _CONST
wchar_t * src _AND
84 _CONST
wchar_t *s
= src
;
88 /* Find the end of dst and adjust bytes left but don't go past end */
89 while (*d
!= '\0' && n
-- != 0)
95 return (dlen
+ wcslen (s
));
107 return (dlen
+ (s
- src
)); /* count does not include NUL */