OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [string/] [strrchr.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
FUNCTION
3
        <<strrchr>>---reverse search for character in string
4
 
5
INDEX
6
        strrchr
7
 
8
ANSI_SYNOPSIS
9
        #include <string.h>
10
        char * strrchr(const char *<[string]>, int <[c]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <string.h>
14
        char * strrchr(<[string]>, <[c]>);
15
        char *<[string]>;
16
        int *<[c]>;
17
 
18
DESCRIPTION
19
        This function finds the last occurence of <[c]> (converted to
20
        a char) in the string pointed to by <[string]> (including the
21
        terminating null character).
22
 
23
RETURNS
24
        Returns a pointer to the located character, or a null pointer
25
        if <[c]> does not occur in <[string]>.
26
 
27
PORTABILITY
28
<<strrchr>> is ANSI C.
29
 
30
<<strrchr>> requires no supporting OS subroutines.
31
 
32
QUICKREF
33
        strrchr ansi pure
34
*/
35
 
36
#include <string.h>
37
 
38
char *
39
_DEFUN (strrchr, (s, i),
40
        _CONST char *s _AND
41
        int i)
42
{
43
  _CONST char *last = NULL;
44
  char c = i;
45
 
46
  while (*s)
47
    {
48
      if (*s == c)
49
        {
50
          last = s;
51
        }
52
      s++;
53
    }
54
 
55
  if (*s == c)
56
    {
57
      last = s;
58
    }
59
 
60
  return (char *) last;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.