lib: Add implementation for strrchr Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com> Change-Id: I57c549fae0fa8b2321794e9256da63b0a2fe6eaf
diff --git a/lib/libc/minimal/source/string/string.c b/lib/libc/minimal/source/string/string.c index 7a18e1a..793c10b 100644 --- a/lib/libc/minimal/source/string/string.c +++ b/lib/libc/minimal/source/string/string.c
@@ -86,6 +86,26 @@ /** * + * @brief String scanning operation + * + * @return pointer to last instance of found byte, or NULL if not found + */ + +char *strrchr(const char *s, int c) +{ + char *match = NULL; + + do { + if (*s == (char)c) { + match = (char *)s; + } + } while (*s++); + + return match; +} + +/** + * * @brief Get string length * * @return number of bytes in string <s>