6 * Copy src to dst, truncating or null-padding to always copy n-1 bytes.
8 * This routine differs from strncpy in that it returns a pointer to the end
9 * of the buffer, instead of strncat which returns a pointer to the start.
12 Strnpcpy(char *const dst
, const char *const src
, size_t n
)
15 register const char *s
;
23 /* If they specified a maximum of n characters, use n - 1 chars to
24 * hold the copy, and the last character in the array as a NUL.
25 * This is the difference between the regular strncpy routine.
26 * strncpy doesn't guarantee that your new string will have a
27 * NUL terminator, but this routine does.
32 ret
= d
; /* Return ptr to end byte. */
34 #if (STRNP_ZERO_PAD == 1)
38 #endif /* STRNP_ZERO_PAD */
43 /* If we get here, then we have a full string, with n - 1 characters,
44 * so now we NUL terminate it and go home.
47 return (d
); /* Return ptr to end byte. */
51 return (d
); /* Return ptr to end byte. */