Change llist_add_* to take the address of the list rather than returning the new
[oweals/busybox.git] / libbb / last_char_is.c
index 4e2ee92ed9a71a2231a4bdafeaef1062e972ea98..9bd70996c03f362833f6f49748579069dd8545e3 100644 (file)
  */
 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;
 }