summaryrefslogtreecommitdiff
path: root/xen/lib/strrchr.c
blob: 0d53dd9518d68f94b4d049ac46308f8b3d300002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 *  Copyright (C) 1991, 1992  Linus Torvalds
 */

#include <xen/string.h>

/**
 * 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);

	for (; *p != (char)c; --p)
		if (p == s)
			return NULL;

	return (char *)p;
}

/*
 * Local variables:
 * mode: C
 * c-file-style: "BSD"
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 */