shithub: npe

ref: ba4b0723d9e6d6ec72ca54016a932e72fbae46f7
dir: /libnpe/strlcpy.c/

View raw version
#include <string.h>

size_t
strlcpy(char *dst, char *src, size_t sz)
{
	char *start;

	start = src;
	if(sz == 0)
		return strlen(start);

	while(sz-- > 0 && (*dst++ = *src++) != '\0')
		;
	if(dst[-1] != '\0')
		dst[-1] = '\0';
	while(*src++)
		;
	return src - start - 1;
}