about summary refs log tree commit diff
path: root/stecpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'stecpy.c')
-rw-r--r--stecpy.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/stecpy.c b/stecpy.c
new file mode 100644
index 0000000..02b69c6
--- /dev/null
+++ b/stecpy.c
@@ -0,0 +1,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;
+}