lib: Add implementation for strrchr
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com> Change-Id: I57c549fae0fa8b2321794e9256da63b0a2fe6eaf
This commit is contained in:
parent
e8b43cbc81
commit
24a2fb19f9
2 changed files with 21 additions and 0 deletions
|
@ -29,6 +29,7 @@ extern "C" {
|
|||
extern char *strcpy(char *_Restrict d, const char *_Restrict s);
|
||||
extern char *strncpy(char *_Restrict d, const char *_Restrict s, size_t n);
|
||||
extern char *strchr(const char *s, int c);
|
||||
extern char *strrchr(const char *s, int c);
|
||||
extern size_t strlen(const char *s);
|
||||
extern int strcmp(const char *s1, const char *s2);
|
||||
extern int strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
|
|
@ -84,6 +84,26 @@ char *strchr(const char *s, int c)
|
|||
return (*s == tmp) ? (char *) s : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue