aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-07 23:10:16 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-07 23:10:16 +0000
commitb8b22cf2887860bccf81793f041c309ccb9dfcac (patch)
tree01324734c757fcccb90765f2a0fe1bf82fd35f13
parentd7375906c92c82592f8345c759648657636412c8 (diff)
downloadbusybox-w32-b8b22cf2887860bccf81793f041c309ccb9dfcac.tar.gz
busybox-w32-b8b22cf2887860bccf81793f041c309ccb9dfcac.tar.bz2
busybox-w32-b8b22cf2887860bccf81793f041c309ccb9dfcac.zip
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
-rw-r--r--libbb/last_char_is.c11
1 files changed, 7 insertions, 4 deletions
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 @@
25 * underrun the buffer if the string length is 0. Also avoids a possible 25 * underrun the buffer if the string length is 0. Also avoids a possible
26 * space-hogging inline of strlen() per usage. 26 * space-hogging inline of strlen() per usage.
27 */ 27 */
28int last_char_is(const char *s, const int c) 28char * last_char_is(char *s, int c)
29{ 29{
30 int l = strlen(s); 30 char *sret = s+strlen(s)-1;
31 if (l==0) return 0; 31 if (sret>=s && *sret == c) {
32 return (s[l-1] == c); 32 return sret;
33 } else {
34 return NULL;
35 }
33} 36}