24 lines
402 B
C
24 lines
402 B
C
#ifndef lint
|
|
static char sccsid[] = "@(#)strncpy.c 1.1 92/07/30 SMI"; /* from S5R2 1.3 */
|
|
#endif
|
|
|
|
/*LINTLIBRARY*/
|
|
/*
|
|
* Copy s2 to s1, truncating or null-padding to always copy n bytes
|
|
* return s1
|
|
*/
|
|
|
|
char *
|
|
strncpy(s1, s2, n)
|
|
register char *s1, *s2;
|
|
register int n;
|
|
{
|
|
register char *os1 = s1;
|
|
|
|
while (--n >= 0)
|
|
if ((*s1++ = *s2++) == '\0')
|
|
while (--n >= 0)
|
|
*s1++ = '\0';
|
|
return (os1);
|
|
}
|