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"
|
|
|
|
|
2006-12-17 03:48:44 +05:30
|
|
|
/* Find out if the last character of a string matches the one given.
|
|
|
|
* Don't underrun the buffer if the string length is 0.
|
2001-04-26 21:26:47 +05:30
|
|
|
*/
|
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
|
|
|
{
|
2006-12-17 03:48:44 +05:30
|
|
|
if (s && *s) {
|
|
|
|
size_t sz = strlen(s) - 1;
|
|
|
|
s += sz;
|
|
|
|
if ( (unsigned char)*s == c)
|
2006-11-25 04:12:44 +05:30
|
|
|
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
|
|
|
}
|