Re: [PATCH 1/2] man/man3/{mem,strn}*(): SYNOPSIS, STANDARDS: Document these as provided by <memory.h>

Alejandro Colomar <[email protected]> Sat, 1 Aug 2026 00:33:12 +0200
Newsgroups gmane.linux.man,gmane.comp.lib.gnulib.bugs,gmane.comp.lib.glibc.alpha
Message-ID <am0h6_aBF2iEvpu5@devuan>
Hi Joseph,

> Date: 2026-07-31 22:16:14+0000
> From: Joseph Myers <[email protected]>
>
> On Sat, 1 Aug 2026, Alejandro Colomar wrote:
> 
> > That's 37 years.  During these 37 years we have gathered a lot of
> > experience and data about this.  And the conclusion is that it was
> > a huge mistake.  Programmers have struggled to understand this, and
> 
> No, there's no such conclusion.  Two functions, strncpy and strncat, are 
> with hindsight confusing (but it's the names and semantics rather than the 
> header that are confusing).

Those are the most misused, indeed.

>  I don't think there's any kind of community 
> consensus at all that there's any problem with mem* being in <string.h>, 
> or any functions other than those two.

But it's a consistent solution that keeps all existing functions (thus,
not a breaking change), and puts them in a header file that is
appropriate (and which has been their header since 1986).

> The committee writing C89 had to come up with a compromise between 
> functions such as memcpy and strchr and functions such as bcopy and index.  
> They chose to adopt memcpy and strchr,

This was a good choice.  mem*() were more portable back then.

> and chose to put them in 
> <string.h>,

This wasn't a good choice.  They were already in <memory.h> in existing
systems.

> and there's no evidence since then to suggest a problem with 
> either choice.

We disagree.


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmptIqMACgkQ64mZXMKQ
wqkgIw//YZrXoP8T3hdgRvd3mLy00t4tYe0KQbAlv06JqfO/5DdRrV6bkX2L+HVM
g1CiVU7OoMBgII4UZVbPWGYFknM/+ednzUzRn6axVKpkw022gmMRnuT751gssH/z
bReFD8XdyWWr1pc/CnPJLoBTnq+imZyJLi91r98lX+IQ58RjO+4Zn84SwpOea7Lc
CIM+UT+qVSVfIgzX7s582qujydRhsFqa/ppY6j5DD0U4iAiIfO8nbAgZknbo2vwp
TjEQdo08uLe6whtuFPn+6NxyZCekK0RP+RfzUSHo/k2IfQyE0opt8vVbGmPGpCDw
vO3QfVD93vyGCj3YuzFXMWnWrZhmM5+tdns42pQYIQU9NCmXa9B2/OP3YVjBRQtP
T3wR24Gn4m8CqSFwa+UleClpXApoXytrev2haprhuUqWDo1raZ4i48X9qzQKbFoM
nogNLSe9TIeGGwkUcQSODKQJ8ozRTRl/JyPdLFeL1lF7hkWlkmo4I2kMwWpidaF3
dqPKEs/HGjkcgQXkEn74mqaLu/jtqovPp8DCwTSg/N4lVJHxiAoRKVCbRG6McBV9
2T69knm8D5kyXgKFLU28vPi1t/BtSyoS7OBKOs2mizx8YDnEaI1xNGMFu06ouMGV
PURxuu7Ky48Re+20LAbNW5pmK0R+bXIYVWlRqk/YSLtSFdzsmcQ=
=Rzxw
-----END PGP SIGNATURE-----