• Main Page
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

missing/strstr.c

Go to the documentation of this file.
00001 /* public domain rewrite of strstr(3) */
00002 
00003 char *
00004 strstr(const char *haystack, const char *needle)
00005 {
00006     const char *hend;
00007     const char *a, *b;
00008 
00009     if (*needle == 0) return (char *)haystack;
00010     hend = haystack + strlen(haystack) - strlen(needle) + 1;
00011     while (haystack < hend) {
00012         if (*haystack == *needle) {
00013             a = haystack;
00014             b = needle;
00015             for (;;) {
00016                 if (*b == 0) return (char *)haystack;
00017                 if (*a++ != *b++) {
00018                     break;
00019                 }
00020             }
00021         }
00022         haystack++;
00023     }
00024     return 0;
00025 }
00026 

Generated on Wed Sep 8 2010 09:56:02 for Ruby by  doxygen 1.7.1