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.
12 * This routine also differs in that it returns a pointer to the end
13 * of the buffer, instead of strncat which returns a pointer to the start.
16 Strnpcat(char *const dst
, const char *const src
, size_t n
)
20 register const char *s
;
24 if (n
!= 0 && ((i
= strlen(dst
)) < (n
- 1))) {
27 /* If they specified a maximum of n characters, use n - 1 chars to
28 * hold the copy, and the last character in the array as a NUL.
29 * This is the difference between the regular strncpy routine.
30 * strncpy doesn't guarantee that your new string will have a
31 * NUL terminator, but this routine does.
36 ret
= d
; /* Return ptr to end byte. */
38 #if (STRNP_ZERO_PAD == 1)
42 #endif /* STRNP_ZERO_PAD */
47 /* If we get here, then we have a full string, with n - 1 characters,
48 * so now we NUL terminate it and go home.
51 return (d
); /* Return ptr to end byte. */