Fixes so "make allnoconfig" works again.
[oweals/busybox.git] / libbb / last_char_is.c
index ae2d24bf71894d479778cded3ed7643729f661bb..9bd70996c03f362833f6f49748579069dd8545e3 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include <string.h>
 #include "libbb.h"
 
 /* Find out if the last character of a string matches the one given Don't
  */
 char * last_char_is(const char *s, int c)
 {
-       char *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;
 }