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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc2/] [newlib/] [libc/] [string/] [strrchr.c] - Diff between revs 207 and 520

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 520
/*
/*
FUNCTION
FUNCTION
        <<strrchr>>---reverse search for character in string
        <<strrchr>>---reverse search for character in string
 
 
INDEX
INDEX
        strrchr
        strrchr
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <string.h>
        #include <string.h>
        char * strrchr(const char *<[string]>, int <[c]>);
        char * strrchr(const char *<[string]>, int <[c]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <string.h>
        #include <string.h>
        char * strrchr(<[string]>, <[c]>);
        char * strrchr(<[string]>, <[c]>);
        char *<[string]>;
        char *<[string]>;
        int *<[c]>;
        int *<[c]>;
 
 
DESCRIPTION
DESCRIPTION
        This function finds the last occurence of <[c]> (converted to
        This function finds the last occurence of <[c]> (converted to
        a char) in the string pointed to by <[string]> (including the
        a char) in the string pointed to by <[string]> (including the
        terminating null character).
        terminating null character).
 
 
RETURNS
RETURNS
        Returns a pointer to the located character, or a null pointer
        Returns a pointer to the located character, or a null pointer
        if <[c]> does not occur in <[string]>.
        if <[c]> does not occur in <[string]>.
 
 
PORTABILITY
PORTABILITY
<<strrchr>> is ANSI C.
<<strrchr>> is ANSI C.
 
 
<<strrchr>> requires no supporting OS subroutines.
<<strrchr>> requires no supporting OS subroutines.
 
 
QUICKREF
QUICKREF
        strrchr ansi pure
        strrchr ansi pure
*/
*/
 
 
#include <string.h>
#include <string.h>
 
 
char *
char *
_DEFUN (strrchr, (s, i),
_DEFUN (strrchr, (s, i),
        _CONST char *s _AND
        _CONST char *s _AND
        int i)
        int i)
{
{
  _CONST char *last = NULL;
  _CONST char *last = NULL;
 
 
  if (i)
  if (i)
    {
    {
      while ((s=strchr(s, i)))
      while ((s=strchr(s, i)))
        {
        {
          last = s;
          last = s;
          s++;
          s++;
        }
        }
    }
    }
  else
  else
    {
    {
      last = strchr(s, i);
      last = strchr(s, i);
    }
    }
 
 
  return (char *) last;
  return (char *) last;
}
}
 
 

powered by: WebSVN 2.1.0

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