about summary refs log tree commit diff
path: root/steccpy.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-11-03 18:13:05 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-07-14 14:50:01 +0200
commit10374ca23413c7e2f85a8b773f90250b5408195e (patch)
treeea07fd347ae9eb286923c8d64fb680aaa1aa374c /steccpy.c
parentfce8d1ec3329a97fc8886cf71eb3d1a763d71ad7 (diff)
downloadlibste-master.tar.gz
libste-master.tar.xz
libste-master.zip
add steccpy HEAD master
Diffstat (limited to 'steccpy.c')
-rw-r--r--steccpy.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/steccpy.c b/steccpy.c
new file mode 100644
index 0000000..3bf8da1
--- /dev/null
+++ b/steccpy.c
@@ -0,0 +1,16 @@
+char *
+steccpy(char *dst, char *end, const char *src, int c)
+{
+	if (dst >= end)
+		return dst;
+
+	while (dst < end && *src != c && (*dst = *src))
+		src++, dst++;
+
+	if (dst == end)
+		dst[-1] = 0;
+	else if (*src == c)
+		dst[0] = 0;
+
+	return dst;
+}