home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / string / strstr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-26  |  433 b   |  24 lines

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3. #include <libc/unconst.h>
  4.  
  5. char *
  6. strstr(const char *s, const char *find)
  7. {
  8.   char c, sc;
  9.   size_t len;
  10.  
  11.   if ((c = *find++) != 0)
  12.   {
  13.     len = strlen(find);
  14.     do {
  15.       do {
  16.     if ((sc = *s++) == 0)
  17.       return 0;
  18.       } while (sc != c);
  19.     } while (strncmp(s, find, len) != 0);
  20.     s--;
  21.   }
  22.   return unconst(s, char *);
  23. }
  24.