shithub: scc

Download patch

ref: 372d84a719b53b7672607046e335572f8ae9edf1
parent: c42057cb7f05df361506718c77a1fb36a2f38e5b
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Feb 16 17:37:23 EST 2017

[libc] Add strncat()

--- a/libc/src/Makefile
+++ b/libc/src/Makefile
@@ -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
 
--- /dev/null
+++ b/libc/src/strncat.c
@@ -1,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;
+}