Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / string / strrchr.c
blob35a7060d2ab77c2ac6b3671b34682ad0ba0d0d26
1 /*
2 FUNCTION
3 <<strrchr>>---reverse search for character in string
5 INDEX
6 strrchr
8 SYNOPSIS
9 #include <string.h>
10 char * strrchr(const char *<[string]>, int <[c]>);
12 DESCRIPTION
13 This function finds the last occurence of <[c]> (converted to
14 a char) in the string pointed to by <[string]> (including the
15 terminating null character).
17 RETURNS
18 Returns a pointer to the located character, or a null pointer
19 if <[c]> does not occur in <[string]>.
21 PORTABILITY
22 <<strrchr>> is ANSI C.
24 <<strrchr>> requires no supporting OS subroutines.
26 QUICKREF
27 strrchr ansi pure
30 #include <string.h>
32 char *
33 strrchr (const char *s,
34 int i)
36 const char *last = NULL;
37 char c = i;
39 if (c)
41 while ((s=strchr(s, c)))
43 last = s;
44 s++;
47 else
49 last = strchr(s, c);
52 return (char *) last;