wm: teppich

ref: a3d9c8a50f2bd94224725e329b1d2482a7b0718d
dir: /libc/strncpy.c/

View raw version
#include <u.h>

char*
strncpy(char *dst, const char *src, size_t num)
{
	char *dst_p = dst;

	if (num != 0) {

		do {
			if ((*dst++ = *src++) == 0) {
				/* NULL pad the remaining n-1 bytes */
				while (--num != 0)
					*dst++ = 0;
				break;
			}
		} while (--num != 0);
	}
	return (dst_p);
}