xref: /titanic_50/usr/src/lib/libbc/libc/gen/common/strncat.c (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23 	  /* from UCB 4.1 80/12/21 */
24 
25 /*
26  * Concatenate s2 on the end of s1.  S1's space must be large enough.
27  * At most n characters are moved.
28  * Return s1.
29  */
30 
31 char *
32 strncat(s1, s2, n)
33 	register char *s1, *s2;
34 	register n;
35 {
36 	register char *os1;
37 
38 	os1 = s1;
39 	while (*s1++)
40 		;
41 	--s1;
42 	while (*s1++ = *s2++)
43 		if (--n < 0) {
44 			*--s1 = '\0';
45 			break;
46 		}
47 	return (os1);
48 }
49