[hackers] [scc] [libc] Add strncat() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 16 Feb 2017 22:37:54 +0100 (CET)

commit 446d6cf7334ec3d1532ab59611d58889467c5004
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Feb 16 22:37:23 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 16 22:37:23 2017 +0100

    [libc] Add strncat()

diff --git a/libc/src/Makefile b/libc/src/Makefile
index 4de1e42..af1f966 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -2,7 +2,7 @@
 .POSIX:
 
 LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
- strrchr.o strcat.o strncpy.o
+ strrchr.o strcat.o strncpy.o strncat.o
 
 all: libc.a
 
diff --git a/libc/src/strncat.c b/libc/src/strncat.c
new file mode 100644
index 0000000..38e6e74
--- /dev/null
+++ b/libc/src/strncat.c
_AT_@ -0,0 +1,16 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+char *
+strncat(char *dst, const char *src, size_t n)
+{
+ char *ret = dst;
+
+ while (*dst)
+ ++dst;
+ while (n-- > 0 && *src)
+ *dst++ = *src++;
+ *dst = '\0';
+ return ret;
+}
Received on Thu Feb 16 2017 - 22:37:54 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 16 2017 - 22:48:16 CET