about summary refs log tree commit diff
path: root/stecpy.c
blob: 02b69c6f2370045c27c550c8fadd32dce59167d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stddef.h>

char *
stecpy(char *dst, const char *end, const char *src)
{
        if (dst >= end)
                return dst;

	size_t n = end - dst;
	while (n && (*dst = *src))
		n--, src++, dst++;

	if (dst == end)
		dst[-1] = 0;

	return dst;
}