Hi Collin,

On Fri, Jul 04, 2025 at 05:15:27PM -0700, Collin Funk wrote:
> Alejandro Colomar <a...@kernel.org> writes:
> 
> > BTW, I was trying to find out the history of memccpy(3), and why it was
> > introduced in 4.4BSD.  Does anyone know the history?  I find it a weird
> > function that doesn't have any good use case, or I don't seem to see it.
> > Every use case I see, such as a poor-man's strlcpy(3), seems to be prone
> > to off-by-one errors, or have other APIs that would be more ergonomic.
> > What were the original uses in 4.4BSD?
> 
> In the sources for 2.11 BSD you can find the following in
> include/strings.h:
> 
>     /* Routines described in memory(BA_LIB); System V compatibility */
>     char      *memccpy(), *memchr(), *memcpy(), *memset(), *strchr(),
>       *strdup(), *strpbrk(), *strrchr(), *strsep(), *strtok();
> 
> The first time I can see the function defined is in Eigth Edition Unix.

Hmmm, so the FreeBSD manual page seems incorrect:

$ find -type f | grep memccpy.3 | MANWIDTH=72 xargs man 2>/dev/null | sed -n 
'/HISTORY/,$p'
HISTORY
       The  memccpy()  function  first appeared in 4.4BSD and was first
       specified in the .  The restrict keyword was added to the proto‐
       type in FreeBSD 5.0.0 in accordance with the updated  specifica‐
       tion of IEEE Std 1003.1-2004 (“POSIX.1”).

Debian                      December 5, 2023                 MEMCCPY(3)

Okay, I'll look into V8 Unix.  At least now I know where to search.
Thanks!  :)

> You can look for yourself here, <https://www.tuhs.org/cgi-bin/utree.pl>.
> 

Yup, thanks!  I was thinking it would be in 4.4BSD, according to
FreeBSD.  Unix should be easier to search.


Have a lovely day!
Alex

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

Attachment: signature.asc
Description: PGP signature

Reply via email to