141984Sbostic /*- 241984Sbostic * Copyright (c) 1990 The Regents of the University of California. 341984Sbostic * All rights reserved. 441984Sbostic * 541984Sbostic * This code is derived from software contributed to Berkeley by 641984Sbostic * Chris Torek. 741984Sbostic * 841984Sbostic * %sccs.include.redist.c% 941984Sbostic */ 1041984Sbostic 1141984Sbostic #if defined(LIBC_SCCS) && !defined(lint) 12*46144Sbostic static char sccsid[] = "@(#)strstr.c 5.2 (Berkeley) 01/26/91"; 1341984Sbostic #endif /* LIBC_SCCS and not lint */ 1441984Sbostic 15*46144Sbostic #include <sys/cdefs.h> 1641984Sbostic #include <string.h> 1741984Sbostic 1841984Sbostic /* 1941984Sbostic * Find the first occurrence of find in s. 2041984Sbostic */ 2141984Sbostic char * 2241984Sbostic strstr(s, find) 2341984Sbostic register const char *s, *find; 2441984Sbostic { 2541984Sbostic register char c, sc; 2641984Sbostic register size_t len; 2741984Sbostic 2841984Sbostic if ((c = *find++) != 0) { 2941984Sbostic len = strlen(find); 3041984Sbostic do { 3141984Sbostic do { 3241984Sbostic if ((sc = *s++) == 0) 3341984Sbostic return (NULL); 3441984Sbostic } while (sc != c); 3541984Sbostic } while (strncmp(s, find, len) != 0); 3641984Sbostic s--; 3741984Sbostic } 3841984Sbostic return ((char *)s); 3941984Sbostic } 40