wcsncat.c revision 77117
1214117Sjamie/*-
2214117Sjamie * Copyright (c)1999 Citrus Project,
3223190Sjamie * All rights reserved.
4214117Sjamie *
5214117Sjamie * Redistribution and use in source and binary forms, with or without
6214117Sjamie * modification, are permitted provided that the following conditions
7214117Sjamie * are met:
8214117Sjamie * 1. Redistributions of source code must retain the above copyright
9214117Sjamie *    notice, this list of conditions and the following disclaimer.
10214117Sjamie * 2. Redistributions in binary form must reproduce the above copyright
11214117Sjamie *    notice, this list of conditions and the following disclaimer in the
12214117Sjamie *    documentation and/or other materials provided with the distribution.
13214117Sjamie *
14214117Sjamie * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15214117Sjamie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16214117Sjamie * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17214117Sjamie * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18214117Sjamie * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19214117Sjamie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20214117Sjamie * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21214117Sjamie * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22214117Sjamie * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23214117Sjamie * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24214117Sjamie * SUCH DAMAGE.
25214117Sjamie *
26214117Sjamie *	citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
27214117Sjamie */
28214117Sjamie
29214117Sjamie#include <sys/cdefs.h>
30214117Sjamie#if defined(LIBC_SCCS) && !defined(lint)
31214117Sjamie__RCSID("$NetBSD: wcsncat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
32214117Sjamie#endif /* LIBC_SCCS and not lint */
33214117Sjamie#ifndef lint
34214117Sjamiestatic const char rcsid[] =
35214117Sjamie  "$FreeBSD: head/lib/libc/string/wcsncat.c 77117 2001-05-24 08:47:42Z obrien $";
36214117Sjamie#endif
37214117Sjamie
38214117Sjamie#include <assert.h>
39214117Sjamie#include <wchar.h>
40214117Sjamie
41214117Sjamiewchar_t *
42214117Sjamiewcsncat(s1, s2, n)
43214117Sjamie	wchar_t *s1;
44214117Sjamie	const wchar_t *s2;
45214117Sjamie	size_t n;
46214117Sjamie{
47214117Sjamie	wchar_t *p;
48214117Sjamie	wchar_t *q;
49214117Sjamie	const wchar_t *r;
50214117Sjamie
51214117Sjamie	p = s1;
52214117Sjamie	while (*p)
53214117Sjamie		p++;
54214117Sjamie	q = p;
55214117Sjamie	r = s2;
56214117Sjamie	while (*r && n) {
57214117Sjamie		*q++ = *r++;
58214117Sjamie		n--;
59214117Sjamie	}
60214117Sjamie	*q = '\0';
61214117Sjamie	return s1;
62214117Sjamie}
63214117Sjamie