non-AT&T implementations of frexp.c in machine/gen/frexp.c
[unix-history] / usr / src / lib / libc / string / strstr.c
CommitLineData
80aa332f
KB
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
a64329b4 12static char sccsid[] = "@(#)strstr.c 5.2 (Berkeley) %G%";
80aa332f
KB
13#endif /* LIBC_SCCS and not lint */
14
a64329b4 15#include <sys/cdefs.h>
80aa332f 16#include <string.h>
80aa332f
KB
17
18/*
19 * Find the first occurrence of find in s.
20 */
21char *
22strstr(s, find)
23 register const char *s, *find;
24{
25 register char c, sc;
26 register size_t len;
27
28 if ((c = *find++) != 0) {
29 len = strlen(find);
30 do {
31 do {
32 if ((sc = *s++) == 0)
33 return (NULL);
34 } while (sc != c);
35 } while (strncmp(s, find, len) != 0);
36 s--;
37 }
38 return ((char *)s);
39}