[PATCH] Implement strlcat [BZ#178]
Zack Weinberg
zackw@panix.com
Fri Dec 4 14:20:00 GMT 2015
On 12/03/2015 05:42 PM, Paul Eggert wrote:
> On 12/03/2015 10:08 AM, Zack Weinberg wrote:
>> char *my_strdup(char *s)
>
> Sorry, I should have been clearer. I'd like to see real-world
> applications that care about these weird corner cases.
I really do not see this as a weird corner case. I see it as the
expected, natural behavior - if dstsize=0, nothing is written to the
destination, and the return value is unaffected; because nothing is
written to the destination when dstsize=0, it is safe to pass dest=NULL
when dstsize=0.
Again, this is consistent with snprintf, and I think maintaining that
consistency would be a compelling argument even if it wasn't the *BSD
behavior.
> I'm skeptical that such applications exist.
I do not have time to do more than a cursory search, which turns up no
such applications; however, I do not consider "we don't know of any such
applications" an acceptable excuse for deviating from the *BSD behavior.
I reiterate that
>> If we're going to have these functions at all, they need to work
>> _exactly_ as they do on *BSD.
If they don't work _exactly_ as they do on *BSD, people will not stop
using substitute definitions with glibc and there will have been no
point in adding them!
> There is no "_exactly_". The BSDs differ.
I would consider the example you gave (NetBSD not allowing dst=NULL when
dstsize=0) a bug in NetBSD, not to be emulated.
zw
More information about the Libc-alpha
mailing list