Re: [PATCH] stpncpy.3, string_copying.7: Clarify that st[rp]ncpy() do NOT produce a string

Alejandro Colomar
2023-11-09T14:35:23Z

[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]

Hi Jonny,

On Thu, Nov 09, 2023 at 02:11:14PM +0000, Jonny Grant wrote:
> On 08/11/2023 23:06, Paul Eggert wrote:
> > On 11/8/23 14:17, Alejandro Colomar wrote:
> >> These copy*from*  a string
> >
> > Not necessarily. For example, in strncpy (DST, SRC, N), SRC need not be a string.
> >
> > By the way, have you looked at the recent (i.e., this-year) changes to the glibc manual's string section? They're relevant.
>
> That's a great reference page Paul, lots of useful information in the manual.
> https://www.gnu.org/software/libc/manual/html_node/String-and-Array-Utilities.html
>
> Re this man page:
>
> https://man7.org/linux/man-pages/man3/string.3.html
>
> Obsolete functions
> char *strncpy(char dest[restrict .n], const char src[restrict .n],
> size_t n);
> Copy at most n bytes from string src to dest, returning a
> pointer to the start of dest.

Uh, I forgot about that page. I'll have a look at it and update it. At
least, I need to remove that "Obsolete functions".

>
>
> It could clarify
> "Copy at most n bytes from string src to ARRAY dest, returning a
> pointer to the start of ARRAY dest."

I think I prefer DJ's suggestion:

"Fill a fixed‐width null‐padded buffer with bytes from a string."

Thanks!
Alex

>
> (caps for my emphasis in this email)
>
> Kind regards
> Jonny

--
<https://www.alejandro-colomar.es/>