about summary refs log tree commit diff
path: root/stecpy.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2021-11-05 18:52:11 +0100
committerLeah Neukirchen <leah@vuxu.org>2021-11-05 18:52:46 +0100
commit75ea20675d012e692996bc6beae9149b0deb08b0 (patch)
treeab1569403e1c5f8e76f5f93f969a3335275c54a5 /stecpy.c
downloadlibste-75ea20675d012e692996bc6beae9149b0deb08b0.tar.gz
libste-75ea20675d012e692996bc6beae9149b0deb08b0.tar.xz
libste-75ea20675d012e692996bc6beae9149b0deb08b0.zip
initial commit
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;
+}