From 3da125839d61e0bb603b56965ac026380ded42b0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 20 Feb 2004 20:15:47 +0000 Subject: Add a simple implementation of strncpy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11672 91177308-0d34-0410-b5e6-96231b3b80d8 --- runtime/GCCLibraries/libc/string.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/GCCLibraries/libc/string.c b/runtime/GCCLibraries/libc/string.c index c13b11266c..9cff5ece85 100644 --- a/runtime/GCCLibraries/libc/string.c +++ b/runtime/GCCLibraries/libc/string.c @@ -35,6 +35,12 @@ char *strcpy(char *s1, const char *s2) { return dest; } +char *strncpy(char *s1, const char *s2, size_t n) { + char *dest = s1; + while (n-- && (*s1++ = *s2++)); + return dest; +} + char *strcat(char *s1, const char *s2) { strcpy(s1+strlen(s1), s2); return s1; -- cgit v1.2.3