summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath2002-12-03 20:34:36 +0000
committerGlenn L McGrath2002-12-03 20:34:36 +0000
commitbf91f2eb1bb1a9b3ae621f3941d62d91ff30e50f (patch)
tree37adf08a5d1ea5540e05b6aa85a1b894d714da00
parent69b5756594452619acf5831a8fff173ec62ca83c (diff)
downloadbusybox-bf91f2eb1bb1a9b3ae621f3941d62d91ff30e50f.zip
busybox-bf91f2eb1bb1a9b3ae621f3941d62d91ff30e50f.tar.gz
Save 10 bytes or so, last_patch_70 from Vladimir N. Oleynik
-rw-r--r--libbb/last_char_is.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libbb/last_char_is.c b/libbb/last_char_is.c
index 4e2ee92..9bd7099 100644
--- a/libbb/last_char_is.c
+++ b/libbb/last_char_is.c
@@ -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;
}