Hi Paul, On Sun, Nov 12, 2023 at 03:52:06PM -0800, Paul Eggert wrote: > strncpy’s src need not be a string; it can be an array that > is not null-terminated. Reword so as to not imply that > the result always has some null padding. Use “byte” rather > than “character” to avoid issues with “character”, as > not every byte is a valid character in (for example) UTF-8 locales. > Replace “‐” (U+2020 HYPHEN) with “-” (U+002D HYPHEN-MINUS). I fixed the hyphen typo in a separate commit: <https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=6be4cc77bb91dd25c48952b647ff49d52c16ab7a> > --- > man3/string.3 | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/man3/string.3 b/man3/string.3 > index bd8b342a6..4037fce47 100644 > --- a/man3/string.3 > +++ b/man3/string.3 > @@ -185,8 +185,8 @@ bytes to > const char " src "[restrict ." n ], > .BI " size_t " n ); > .fi > -Fill a fixed‐width buffer with characters from a string > -and pad with null bytes. > +Fill a fixed-size buffer with non-null bytes from a source array, I'm not convinced by the array wording, as it could be understood as doing this: char d[3], s[3] = {'a', '\0', 'b'}; strncpy(d, s, 3); // "a\0b"? Or maybe "ab\0"? Did it copy the non-null byte 'b'? It is certainly part of the array, and is non-null. While saying that it only reads strings is incomplete, I'm not sure this alternative is complete either. > +padding with null bytes as needed. I've split the patch into several pieces: - Clarify that dst isn't padded if there's no room. <https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=1873da38de4be3d36bb67d011b907f6f774eef82> - Talk about bytes, not characters: <https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=f51cbcca1c0e12e94590bd9723e3e446ac50c33a> Thanks! Alex > .SH DESCRIPTION > The string functions perform operations on null-terminated > strings. > -- > 2.41.0 > > -- <https://www.alejandro-colomar.es/>
Attachment:
signature.asc
Description: PGP signature