Hi DJ, On Wed, Nov 08, 2023 at 02:58:24PM -0500, DJ Delorie wrote: > > Perhaps an example that shows the problem? Maybe. > > EXAMPLES > > strncpy (buf, "1", 5); > { '1', 0, 0, 0, 0 } > > strncpy (buf, "1234", 5); > { '1', '2', '3', '4', 0 } > > strncpy (buf, "12345", 5); > { '1', '2', '3', '4', '5' } > > strncpy (buf, "123456", 5); > { '1', '2', '3', '4', '5' } Would you mind reading the latest versions of strcpy(3), strncpy(3), and string_copying(7), as in the git repository, and comment your thoughts? You don't even need to install the pages from git. You can read them with this: $ git clone https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/ $ cd man-pages/ $ man ./man3/strcpy.3 $ man ./man3/strncpy.3 $ man ./man7/string_copying.7 Also check the examples and suggest if anything could be clearer. Thanks! > > Maybe strcpy and strncpy shouldn't even share man pages, since they're > not as related as we once thought? They don't (anymore): $ pwd /home/alx/src/linux/man-pages/man-pages/master $ git log --oneline -1 b8584be14 (HEAD -> master, korg/master, alx/main, main) bcmp.3: wfix $ grep -e '\.TH ' -e '\.so ' man3/strcpy.3 .TH strcpy 3 (date) "Linux man-pages (unreleased)" $ grep -e '\.TH ' -e '\.so ' man3/stpcpy.3 .so man3/strcpy.3 $ grep -e '\.TH ' -e '\.so ' man3/strncpy.3 .so man3/stpncpy.3 $ grep -e '\.TH ' -e '\.so ' man3/stpncpy.3 .TH stpncpy 3 (date) "Linux man-pages (unreleased)" The only shared page is string_copying(7), which attempts to clarify all of this. It was only in old versions of the Linux man-pages where they shared page. $ pwd /home/alx/src/linux/man-pages/man-pages/5/5.13 $ git log --oneline -1 091fbf1fe (HEAD, tag: man-pages-5.13) Ready for 5.13 $ grep -e '\.TH ' -e '\.so ' man3/strcpy.3 .TH STRCPY 3 2021-03-22 "GNU" "Linux Programmer's Manual" $ grep -e '\.TH ' -e '\.so ' man3/stpcpy.3 .TH STPCPY 3 2021-03-22 "GNU" "Linux Programmer's Manual" $ grep -e '\.TH ' -e '\.so ' man3/strncpy.3 .so man3/strcpy.3 $ grep -e '\.TH ' -e '\.so ' man3/stpncpy.3 .TH STPNCPY 3 2021-03-22 "GNU" "Linux Programmer's Manual" I've spent the last year working on shadow-utils' string handling code, while at the same time wrote string_copying(7) as a complete guide to *cpy() functions, detailing what they do and what they don't, and also rewrote all the pages for these functions with shorter reference guides that refer to string_copying(7) for more details. Cheers, Alex -- <https://www.alejandro-colomar.es/>
Attachment:
signature.asc
Description: PGP signature