summaryrefslogtreecommitdiff
path: root/src/string/strcpy.c
blob: f13a102cc9974fd2fa83fb8023915e087b18da7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <string.h>
#include "_safety.h"

/** copy string **/

char * strcpy(char * restrict s1, const char * restrict s2)
{
	char *p = s1;
	size_t len = 0;

	SIGNAL_SAFE(0);

	ASSERT_NONNULL(s1);
	ASSERT_NONNULL(s2);
	DANGEROUS_READ(s2, 0);
	len = strlen(s2);
	ASSERT_NOOVERLAP(s1, len, s2, len);
	DANGEROUS_WRITE(s1, len);

	while ((*s1++ = *s2++) != '\0') {
		continue;
	}

	DANGER_OVER();

	/*
	RETURN_ALWAYS(ARGUMENT(s1));
	*/
	return p;
}

CHECK_2(char *, 0, strcpy, char * restrict, const char * restrict)

/***
copies the string at ARGUMENT(s2) to ARGUMENT(s1), up to and
including the terminating CHAR(\0).
***/

/*
STDC(1)
*/