From 9a9e8156d21f171368c136696abcfbd74978bc4b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 19 Aug 2019 14:49:37 +0200 Subject: pbl: Implement strrchr strrchr is needed for libfdt. Add support for it to the pbl. Signed-off-by: Sascha Hauer --- pbl/string.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pbl') diff --git a/pbl/string.c b/pbl/string.c index 927c92dc05..46bf0b32b3 100644 --- a/pbl/string.c +++ b/pbl/string.c @@ -133,3 +133,19 @@ size_t strnlen(const char * s, size_t count) /* nothing */; return sc - s; } + +/** + * strrchr - Find the last occurrence of a character in a string + * @s: The string to be searched + * @c: The character to search for + */ +char * _strrchr(const char * s, int c) +{ + const char *p = s + strlen(s); + + do { + if (*p == (char)c) + return (char *)p; + } while (--p >= s); + return NULL; +} -- cgit v1.2.3