summaryrefslogtreecommitdiff
path: root/libc/string
diff options
context:
space:
mode:
Diffstat (limited to 'libc/string')
-rw-r--r--libc/string/Makefile2
-rw-r--r--libc/string/string.c17
2 files changed, 18 insertions, 1 deletions
diff --git a/libc/string/Makefile b/libc/string/Makefile
index c9b70829e..748a935eb 100644
--- a/libc/string/Makefile
+++ b/libc/string/Makefile
@@ -26,7 +26,7 @@ include $(TOPDIR)Rules.mak
MSRC=string.c
MOBJ=strlen.o strcat.o strcpy.o strchr.o strcmp.o strncat.o strncpy.o \
strncmp.o strrchr.o strdup.o memcpy.o memccpy.o memset.o \
- memmove.o memcmp.o memchr.o ffs.o strnlen.o strxfrm.o stpcpy.o
+ memmove.o memcmp.o memchr.o ffs.o strnlen.o strxfrm.o stpcpy.o stpncpy.o
ifeq ($(HAS_LOCALE),true)
MOBJ += strcoll.o
diff --git a/libc/string/string.c b/libc/string/string.c
index d8b8e9f37..7ccc55733 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -79,6 +79,23 @@ char *stpcpy(char *dst, const char *src)
}
#endif
+/********************** Function stpncpy ************************************/
+
+#ifdef L_stpncpy
+char *stpncpy(char *dst, const char *src, size_t len)
+{
+ while (len--) {
+ if (*src)
+ *dst++ = *src++;
+ else
+ *dst++ = '\0';
+ }
+
+ return dst;
+}
+#endif
+
+
/********************** Function strcmp ************************************/
#ifdef L_strcmp