1 /******************************************************************************
2 * libc strrchr() implementation
3 *
4 * This program and the accompanying materials are made available under
5 * the terms of the BSD License which accompanies this distribution, and
6 * is available at http://www.opensource.org/licenses/bsd-license.php
7 *
8 * Contributors:
9 * Thomas Huth - initial implementation
10 *****************************************************************************/
11
12 #include <string.h>
13
14 char *
strrchr(const char * s,int c)15 strrchr(const char *s, int c)
16 {
17 char cb = c;
18 char *ptr = (char *)s + strlen(s) - 1;
19
20 while (ptr >= s) {
21 if (*ptr == cb) {
22 return ptr;
23 }
24 --ptr;
25 }
26
27 return NULL;
28 }
29