chiark / gitweb /
[PATCH] update klibc to 0.194
[elogind.git] / klibc / klibc / strncat.c
1 /*
2  * strncat.c
3  */
4
5 #include <string.h>
6 #include <klibc/compiler.h>
7
8 char *strncat(char *dst, const char *src, size_t n)
9 {
10   char *q = strchr(dst, '\0');
11   const char *p = src;
12   char ch;
13   size_t nn = q-dst;
14
15   if ( __likely(nn <= n) )
16     n -= nn;
17
18   while (n--) {
19     *q++ = ch = *p++;
20     if ( !ch )
21       break;
22   }
23
24   return dst;
25 }