*
*/
+#include <string.h>
#include "libbb.h"
/* Find out if the last character of a string matches the one given Don't
* underrun the buffer if the string length is 0. Also avoids a possible
* space-hogging inline of strlen() per usage.
*/
-int last_char_is(const char *s, const int c)
+char * last_char_is(const char *s, int c)
{
- int l = strlen(s);
- if (l==0) return 0;
- return (s[l-1] == c);
+ char *sret = (char *)s;
+ if (sret) {
+ sret = strrchr(sret, c);
+ if(sret != NULL && *(sret+1) != 0)
+ sret = NULL;
+ }
+ return sret;
}