On 5 Feb 2003 at 14:21, Bram Moolenaar wrote:
> Right, the manpage of strncpy() does mention the padding with NUL bytes.
> I've always considered the design of strncpy() wrong. There is no
> reason to pad with NUL bytes, while it's essential to terminate a string
> with a NUL even when it doesn't fit in the buffer.
Like a lot of things, not to break old C code. I remember stories of
being used to pad Unix directory entries to a fixed size. Ah, the
following may be of interest in C programming trivia:
(Yep, it's wrapped - sorry).
> I don't see why someone would need to rely on vim_strncpy() doing
> padding. I'll add a note about this in the comments to avoid
Hmm, may be better to alter the name as the old timers may just
think, ah, strncpy() - does nul padding. How about
vim_strncpy_nopad()? A bit cumbersome I know.
The search for happiness is one of the chief sources of unhappiness.