File:  [MW Coherent from dump] / coherent / b / lib / libc / string / strstr.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * strstr.c
 * ANSI 4.11.5.7.
 * Search string for string.
 */

#include <string.h>

char *strstr(s1, s2) char *s1; char *s2;
{
	register char *cp1, *cp2;
	register char c2;

	if (*s2 == '\0')
		return(s1);
	for ( ; *s1; s1++) {
		cp1 = s1;
		cp2 = s2;
		while ((c2 = *cp2++) && *cp1++ == c2)
			;
		if (c2 == '\0')
			return(s1);		/* match */
		else if (*--cp1 == '\0')
			return(NULL);		/* end of s1, failed */
	}
	return (NULL);				/* failed */
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.