2006-07-02 19:47:05 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
2001-04-26 15:56:47 +00:00
|
|
|
/*
|
|
|
|
* busybox library eXtended function
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Larry Doolittle, <ldoolitt@recycle.lbl.gov>
|
|
|
|
*
|
2010-08-16 18:14:46 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2001-04-26 15:56:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libbb.h"
|
|
|
|
|
2006-12-16 22:18:44 +00:00
|
|
|
/* 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 15:56:47 +00:00
|
|
|
*/
|
2008-06-27 02:52:20 +00:00
|
|
|
char* FAST_FUNC last_char_is(const char *s, int c)
|
2001-04-26 15:56:47 +00:00
|
|
|
{
|
2006-12-16 22:18:44 +00:00
|
|
|
if (s && *s) {
|
|
|
|
size_t sz = strlen(s) - 1;
|
|
|
|
s += sz;
|
|
|
|
if ( (unsigned char)*s == c)
|
2006-11-24 22:42:44 +00:00
|
|
|
return (char*)s;
|
2001-05-07 23:10:16 +00:00
|
|
|
}
|
2006-11-24 21:55:55 +00:00
|
|
|
return NULL;
|
2001-04-26 15:56:47 +00:00
|
|
|
}
|