[BusyBox] micro last_patch_is patch
Vladimir N. Oleynik
dzo at simtreas.ru
Tue Dec 3 04:17:04 UTC 2002
Larry.
I found the obscure reducing 11 bytes for libbb/last_char_is.c :-0
--w
vodz
-------------- next part --------------
diff -rbu busybox.orig/libbb/last_char_is.c busybox/libbb/last_char_is.c
--- busybox.orig/libbb/last_char_is.c Sat Jul 7 08:27:35 2001
+++ busybox/libbb/last_char_is.c Tue Dec 3 13:55:56 2002
@@ -28,13 +28,11 @@
*/
char * last_char_is(const char *s, int c)
{
- char *sret;
- if (!s)
- return NULL;
- sret = (char *)s+strlen(s)-1;
- if (sret>=s && *sret == c) {
- return sret;
- } else {
- return NULL;
+ char *sret = (char *)s;
+ if (sret) {
+ sret = strrchr(sret, c);
+ if(sret != NULL && *(sret+1) != 0)
+ sret = NULL;
}
+ return sret;
}
More information about the busybox
mailing list