[PATCH] libbb/last_char_is: rewrite for smaller and faster code

Kang-Che Sung explorer09 at gmail.com
Sat Jul 4 16:22:48 UTC 2020


On Saturday, July 4, 2020, Harald van Dijk <harald at gigawatt.nl> wrote:
>
> This is really the same problem as with standard library functions such
as strchr(). The function should have a return type of char* if its
argument has type char*. The function should have a return type of const
char* if its argument has type const char*. The current signature is the
only signature that allows all code that should be valid, at the expense of
not rejecting code that should be invalid.

Just to give a note: The const-correctness problem could have been avoided
if the function API returns an offset (of `size_t` type) rather than the
pointer directly. But it may be too late for the standard library to
correct this historical mistake.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20200705/177560a2/attachment.html>


More information about the busybox mailing list