xref: /haiku/src/system/libroot/posix/string/strrchr.c (revision 5e96d7d537fbec23bad4ae9b4c8e7b02e769f0c6)
1 /*
2  * Copyright 2001, Manuel J. Petit. All rights reserved.
3  * Distributed under the terms of the NewOS License.
4  */
5 
6 #include <sys/types.h>
7 #include <string.h>
8 
9 
10 char *
11 strrchr(char const *s, int c)
12 {
13 	char const *last = NULL;
14 
15 	for (;; s++) {
16 		if (*s == (char)c)
17 			last = s;
18 		if (*s == '\0')
19 			break;
20 	}
21 
22 	return (char *)last;
23 }
24 
25 
26 char *
27 rindex(char const *s, int c)
28 {
29 	return strrchr(s, c);
30 }
31 
32