6 * Concatenate src on the end of dst. The resulting string will have at most
7 * n-1 characters, not counting the NUL terminator which is always appended
8 * unlike strncat. The other big difference is that strncpy uses n as the
9 * max number of characters _appended_, while this routine uses n to limit
10 * the overall length of dst.
13 Strncat(char *const dst
, const char *const src
, const size_t n
)
17 register const char *s
;
19 if (n
!= 0 && ((i
= strlen(dst
)) < (n
- 1))) {
22 /* If they specified a maximum of n characters, use n - 1 chars to
23 * hold the copy, and the last character in the array as a NUL.
24 * This is the difference between the regular strncpy routine.
25 * strncpy doesn't guarantee that your new string will have a
26 * NUL terminator, but this routine does.
29 if ((*d
++ = *s
++) == 0) {
30 #if (STRN_ZERO_PAD == 1)
34 #endif /* STRN_ZERO_PAD */
38 /* If we get here, then we have a full string, with n - 1 characters,
39 * so now we NUL terminate it and go home.