From: Chris Lattner Date: Fri, 20 Feb 2004 20:15:47 +0000 (+0000) Subject: Add a simple implementation of strncpy X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3da125839d61e0bb603b56965ac026380ded42b0;p=oota-llvm.git Add a simple implementation of strncpy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11672 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/runtime/GCCLibraries/libc/string.c b/runtime/GCCLibraries/libc/string.c index c13b11266cb..9cff5ece858 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;