source: trunk/libs/newlib/src/newlib/libc/string/strrchr.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 813 bytes
Line 
1/*
2FUNCTION
3        <<strrchr>>---reverse search for character in string
4
5INDEX
6        strrchr
7
8SYNOPSIS
9        #include <string.h>
10        char * strrchr(const char *<[string]>, int <[c]>);
11
12DESCRIPTION
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).
16
17RETURNS
18        Returns a pointer to the located character, or a null pointer
19        if <[c]> does not occur in <[string]>.
20
21PORTABILITY
22<<strrchr>> is ANSI C.
23
24<<strrchr>> requires no supporting OS subroutines.
25
26QUICKREF
27        strrchr ansi pure
28*/
29
30#include <string.h>
31
32char *
33strrchr (const char *s,
34        int i)
35{
36  const char *last = NULL;
37
38  if (i)
39    {
40      while ((s=strchr(s, i)))
41        {
42          last = s;
43          s++;
44        }
45    }
46  else
47    {
48      last = strchr(s, i);
49    }
50                 
51  return (char *) last;
52}
Note: See TracBrowser for help on using the repository browser.