Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* strstr( const char *, const char * )
  2.  
  3.    This file is part of the Public Domain C Library (PDCLib).
  4.    Permission is granted to use, modify, and / or redistribute at will.
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. char * strstr( const char * s1, const char * s2 )
  10. {
  11.     const char * p1 = s1;
  12.     const char * p2;
  13.  
  14.     while ( *s1 )
  15.     {
  16.         p2 = s2;
  17.  
  18.         while ( *p2 && ( *p1 == *p2 ) )
  19.         {
  20.             ++p1;
  21.             ++p2;
  22.         }
  23.  
  24.         if ( ! *p2 )
  25.         {
  26.             return ( char * ) s1;
  27.         }
  28.  
  29.         ++s1;
  30.         p1 = s1;
  31.     }
  32.  
  33.     return NULL;
  34. }