groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memccpy(3) and stpcpy(3) status in C2x (was: stpecpy(): A better string


From: Alejandro Colomar (man-pages)
Subject: memccpy(3) and stpcpy(3) status in C2x (was: stpecpy(): A better string copy function)
Date: Sun, 13 Feb 2022 21:32:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

Hi Branden,

On 2/13/22 19:29, Alejandro Colomar (man-pages) wrote:
>> Oh, I was going to ask if you were aware of stpcpy(), but if I click the
>> link to codidact I see that you are.
>>
>> I expect/hope stpcpy to become the new norm for string copying, though
>> it will require overcoming much inertia and many dusty old books.
>>
>> It was introduced to POSIX in Issue 7 (2018).
>>
>> https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcpy.html
>>
>> Martin Sebor is sponsoring its inclusion in C2x.
>>
>> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2352.htm
>>
>> (It may have been accepted, or not--I haven't checked the status.)
> 
> No, stpcpy(3) was not accepted.  memccpy(3) was instead.  The problem
> wasn't stpcpy(3) as it seems, but stpncpy(3) about which I'll rant a bit
> below :).
> 

I forgot to link to the C2x document, which contains very interesting
information:

<http://www.open-std.org/JTC1/SC22/WG14/www/docs/n2349.htm>

TL;DR: That document considers strlcpy(3) to be "optimal", but not
widely supported enough, and then selects memccpy(3) as "good enough"
and way more widespread.

Cheers,

Alex


-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]