Skip to content

Commit

Permalink
Fixing strncat
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Jul 15, 2020
1 parent af8c834 commit 6718594
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libc/include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ static __inline__ size_t strlen(const char * s) {

static __inline__ char * strncat(char * s1, const char * s2, size_t n) {
char * r = s1;
char c;

while (*s1)
s1++;
strncpy(s1, s2, n);

while (n-- && ((c = *s2++)))
*s1++ = c;

*s1 = 0;

return r;
}
Expand Down

0 comments on commit 6718594

Please sign in to comment.