about summary refs log tree commit diff
path: root/stecpe.c
blob: 0cfbaad26519c949223271cd037a72a1c7ee4b46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stddef.h>
#include <string.h>

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

	size_t l = end - dst - 1;
	size_t t = 1;
	if (srcend - src < l) {
		l = srcend - src;
		t = 0;
	}

	memcpy(dst, src, l);
	dst[l] = 0;

	return dst + l + t;
}