[BusyBox] last_char_is
Larry Doolittle
ldoolitt at recycle.lbl.gov
Mon May 7 13:58:44 UTC 2001
Evin observed:
> Well, if we take strrchr as an example (be the standard C library evil
> or not), we should just return char * and let the programmer shoot
> himself if he modifies the result.
The standard c library API is 20-30 years old, and was written before
the invention of const. In some cases const could be added cleanly,
retroactively. In the cases where the concept doesn't fit cleanly,
and in those cases I don't think libc is a shining example to follow.
> However, in this case, I think it would be better to use a chomp()
> function (as in Perl) since that seems to be the sole current use of
> writing over the result.
>
> int chomp(char *s, int c)
Sounds good to me. But now we are back to the lack of polymorphism
in c (as opposed to Perl), because we already have in libbb/chomp.c
void chomp(char *s)
So we have to make up a new name for one function or the other, or
convert all ten existing chomp()s to chomp(foo, '\n');
- Larry
More information about the busybox
mailing list