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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [string/] [strstr.c] - Diff between revs 1010 and 1765

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

Rev 1010 Rev 1765
/*
/*
FUNCTION
FUNCTION
        <<strstr>>---find string segment
        <<strstr>>---find string segment
 
 
INDEX
INDEX
        strstr
        strstr
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <string.h>
        #include <string.h>
        char *strstr(const char *<[s1]>, const char *<[s2]>);
        char *strstr(const char *<[s1]>, const char *<[s2]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <string.h>
        #include <string.h>
        char *strstr(<[s1]>, <[s2]>)
        char *strstr(<[s1]>, <[s2]>)
        char *<[s1]>;
        char *<[s1]>;
        char *<[s2]>;
        char *<[s2]>;
 
 
DESCRIPTION
DESCRIPTION
        Locates the first occurence in the string pointed to by <[s1]> of
        Locates the first occurence in the string pointed to by <[s1]> of
        the sequence of characters in the string pointed to by <[s2]>
        the sequence of characters in the string pointed to by <[s2]>
        (excluding the terminating null  character).
        (excluding the terminating null  character).
 
 
RETURNS
RETURNS
        Returns a pointer to the located string segment, or a null
        Returns a pointer to the located string segment, or a null
        pointer if the string <[s2]> is not found. If <[s2]> points to
        pointer if the string <[s2]> is not found. If <[s2]> points to
        a string with zero length, the <[s1]> is returned.
        a string with zero length, the <[s1]> is returned.
 
 
PORTABILITY
PORTABILITY
<<strstr>> is ANSI C.
<<strstr>> is ANSI C.
 
 
<<strstr>> requires no supporting OS subroutines.
<<strstr>> requires no supporting OS subroutines.
 
 
QUICKREF
QUICKREF
        strstr ansi pure
        strstr ansi pure
*/
*/
 
 
#include <string.h>
#include <string.h>
 
 
char *
char *
_DEFUN (strstr, (searchee, lookfor),
_DEFUN (strstr, (searchee, lookfor),
        _CONST char *searchee _AND
        _CONST char *searchee _AND
        _CONST char *lookfor)
        _CONST char *lookfor)
{
{
  if (*searchee == 0)
  if (*searchee == 0)
    {
    {
      if (*lookfor)
      if (*lookfor)
        return (char *) NULL;
        return (char *) NULL;
      return (char *) searchee;
      return (char *) searchee;
    }
    }
 
 
  while (*searchee)
  while (*searchee)
    {
    {
      size_t i;
      size_t i;
      i = 0;
      i = 0;
 
 
      while (1)
      while (1)
        {
        {
          if (lookfor[i] == 0)
          if (lookfor[i] == 0)
            {
            {
              return (char *) searchee;
              return (char *) searchee;
            }
            }
 
 
          if (lookfor[i] != searchee[i])
          if (lookfor[i] != searchee[i])
            {
            {
              break;
              break;
            }
            }
          i++;
          i++;
        }
        }
      searchee++;
      searchee++;
    }
    }
 
 
  return (char *) NULL;
  return (char *) NULL;
}
}
 
 

powered by: WebSVN 2.1.0

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