From b8b22cf2887860bccf81793f041c309ccb9dfcac Mon Sep 17 00:00:00 2001
From: andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Date: Mon, 7 May 2001 23:10:16 +0000
Subject: This is Vladimir's update to last_char_is().  Since 'char *' is the
 least common denominator, I modified it to use that (not const), which will
 minimize the need for casting elsewhere.

git-svn-id: svn://busybox.net/trunk/busybox@2568 69ca8d6d-28ef-0310-b511-8ec308f3f277
---
 libbb/last_char_is.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'libbb')

diff --git a/libbb/last_char_is.c b/libbb/last_char_is.c
index b4bb7ec32..36b695b40 100644
--- a/libbb/last_char_is.c
+++ b/libbb/last_char_is.c
@@ -25,9 +25,12 @@
  * 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(char *s, int c)
 {
-	int  l = strlen(s);
-	if (l==0) return 0;
-	return (s[l-1] == c);
+	char *sret  = s+strlen(s)-1;
+	if (sret>=s && *sret == c) { 
+		return sret;
+	} else {
+		return NULL;
+	}
 }
-- 
cgit v1.2.3-55-g6feb