[PATCH 3/8] pbl: Implement strrchr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



strrchr is needed for libfdt. Add support for it to the pbl.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 pbl/string.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

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;
+}
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux