summaryrefslogtreecommitdiffstats
path: root/pbl
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-08-19 14:49:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-08-19 14:49:39 +0200
commit9a9e8156d21f171368c136696abcfbd74978bc4b (patch)
treecca12942f26604db053f2e2f401ec6a2aaf86755 /pbl
parent4e731e48d49ab77c1a331cda089b60406234ae6b (diff)
downloadbarebox-9a9e8156d21f171368c136696abcfbd74978bc4b.tar.gz
barebox-9a9e8156d21f171368c136696abcfbd74978bc4b.tar.xz
pbl: Implement strrchr
strrchr is needed for libfdt. Add support for it to the pbl. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'pbl')
-rw-r--r--pbl/string.c16
1 files changed, 16 insertions, 0 deletions
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;
+}