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>
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2001-04-26 21:26:47 +05:30
|
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
|
2020-06-30 12:03:02 +05:30
|
|
|
/* Find out if the last character of a string matches the one given */
|
2008-06-27 08:22:20 +05:30
|
|
|
char* FAST_FUNC last_char_is(const char *s, int c)
|
2001-04-26 21:26:47 +05:30
|
|
|
{
|
2020-06-30 12:03:02 +05:30
|
|
|
if (s) {
|
|
|
|
size_t sz = strlen(s);
|
|
|
|
/* Don't underrun the buffer if the string length is 0 */
|
|
|
|
if (sz != 0) {
|
|
|
|
s += sz - 1;
|
|
|
|
if ((unsigned char)*s == c)
|
|
|
|
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
|
|
|
}
|