groff
[Top][All Lists]
Advanced

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

Fwd: stpecpy(): A better string copy function


From: Alejandro Colomar (man-pages)
Subject: Fwd: stpecpy(): A better string copy function
Date: Sun, 13 Feb 2022 18:09:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

Hi Branden,

I'm forwarding our conversation to the groff mailing list, since it's
becoming very interesting, and I plan to invite more people to the
discussion, starting by Martin, which you mentioned.  That way, they
(and a future me) will be able to read the full conversation in the list
archive.  Since it started as a spin off of a groff discussion, I'll
post it there, even though it's a bit irrelevant to groff (at least
directly).

I'll also forward your answer as a reply, and then will reply to that.

Cheers,

Alex

P.S.: Martin, you'll understand why you're CCd here in the following
emails in this thread.


-------- Forwarded Message --------
Subject: stpecpy(): A better string copy function (was: CHECKSTYLE:
Report consecutive .?P (paragraph macros))
Date: Sun, 13 Feb 2022 01:05:13 +0100
From: Alejandro Colomar (man-pages) <alx.manpages@gmail.com>
To: G. Branden Robinson <g.branden.robinson@gmail.com>

Hi Branden,

On 2/2/22 01:49, Alejandro Colomar (man-pages) wrote:
> On 2/1/22 21:22, G. Branden Robinson wrote:
>>     I digress, but because I can already hear fundamentalists sweatily
>>     reaching for their Bibles, I'll append some links to heretical
>>     literature.
>>
>>     
>> https://web.archive.org/web/20201001070605/https://symas.com/the-sad-state-of-c-strings/
> 
> That one was quite interesting.  strecpy() is soooo clean of a C string
> copy function!
> 

I designed some string copying function that attempts to improve
strecopy(), and of course the common/standard ones, including
strlcpy(3BSD) and strscpy(9), ....

Would you mind having a look at it? :-)

<https://software.codidact.com/posts/285946>

The definition is:


char *
stpecpy(char *dst, char *src, char *end)
{
        for (/* void */; dst <= end; dst++) {
                *dst = *src++;
                if (!*dst)
                        return dst;
        }
        /* truncation detected */
        *end = '\0';
        return dst;
}


Thanks,

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]