xref: /csrg-svn/lib/libcompat/4.1/strcatn.c (revision 26530)
11982Swnj /*
221396Smckusick  * Copyright (c) 1980 Regents of the University of California.
321396Smckusick  * All rights reserved.  The Berkeley software License Agreement
421396Smckusick  * specifies the terms and conditions for redistribution.
521396Smckusick  */
621396Smckusick 
7*26530Sdonn #if defined(LIBC_SCCS) && !defined(lint)
8*26530Sdonn static char sccsid[] = "@(#)strcatn.c	4.3 (Berkeley) 03/09/86";
9*26530Sdonn #endif LIBC_SCCS and not lint
1021396Smckusick 
1121396Smckusick /*
121982Swnj  * Concatenate s2 on the end of s1.  S1's space must be large enough.
131982Swnj  * At most n characters are moved.
141982Swnj  * Return s1.
151982Swnj  */
161982Swnj 
171982Swnj char *
strcatn(s1,s2,n)181982Swnj strcatn(s1, s2, n)
191982Swnj register char *s1, *s2;
201982Swnj register n;
211982Swnj {
221982Swnj 	register char *os1;
231982Swnj 
241982Swnj 	os1 = s1;
251982Swnj 	while (*s1++)
261982Swnj 		;
271982Swnj 	--s1;
281982Swnj 	while (*s1++ = *s2++)
291982Swnj 		if (--n < 0) {
301982Swnj 			*--s1 = '\0';
311982Swnj 			break;
321982Swnj 		}
331982Swnj 	return(os1);
341982Swnj }
35