2006-07-03 01:17:05 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2001-04-26 21:26:47 +05:30
|
|
|
/*
|
|
|
|
* busybox library eXtended function
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Larry Doolittle, <ldoolitt@recycle.lbl.gov>
|
|
|
|
*
|
2006-07-10 17:11:19 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2001-04-26 21:26:47 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#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.
|
|
|
|
*/
|
2006-11-25 03:25:55 +05:30
|
|
|
char* last_char_is(const char *s, int c)
|
2001-04-26 21:26:47 +05:30
|
|
|
{
|
2006-11-25 03:25:55 +05:30
|
|
|
if (s) {
|
2006-11-25 04:12:44 +05:30
|
|
|
s = strrchr(s, c);
|
|
|
|
if (s && !s[1])
|
|
|
|
return (char*)s;
|
2001-05-08 04:40:16 +05:30
|
|
|
}
|
2006-11-25 03:25:55 +05:30
|
|
|
return NULL;
|
2001-04-26 21:26:47 +05:30
|
|
|
}
|