[BusyBox] last_char_is

Vladimir N. Oleynik dzo at simtreas.ru
Thu May 10 01:23:15 UTC 2001


Larry,
 
> 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.

20 years back were not functions strchr(). It seems to me, that its declaration
optimally
and correctly reflects its sense when function does not change the line
argument, but the
user can write in the returned pointer, and also there is no necessity in
casting. 
I think, that Evin rights, the best variant would be to make the declaration of
function last_char_is () similarly declarations strchr(): 

char * last_char_is(const char *s, int c);

 
--w
vodz





More information about the busybox mailing list