|
|
1.1 ! root 1: /* ! 2: * strstr.c ! 3: * ANSI 4.11.5.7. ! 4: * Search string for string. ! 5: */ ! 6: ! 7: #include <string.h> ! 8: ! 9: char *strstr(s1, s2) char *s1; char *s2; ! 10: { ! 11: register char *cp1, *cp2; ! 12: register char c2; ! 13: ! 14: if (*s2 == '\0') ! 15: return(s1); ! 16: for ( ; *s1; s1++) { ! 17: cp1 = s1; ! 18: cp2 = s2; ! 19: while ((c2 = *cp2++) && *cp1++ == c2) ! 20: ; ! 21: if (c2 == '\0') ! 22: return(s1); /* match */ ! 23: else if (*--cp1 == '\0') ! 24: return(NULL); /* end of s1, failed */ ! 25: } ! 26: return (NULL); /* failed */ ! 27: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.