34 #if 0 // PJ: not needed 35 #if defined(LIBC_SCCS) && !defined(lint) 36 static char sccsid[] =
"@(#)strstr.c 8.1 (Berkeley) 6/4/93";
38 #include <sys/cdefs.h> 39 __FBSDID(
"$FreeBSD: src/lib/libc/string/strnstr.c,v 1.5 2009/02/03 17:58:20 danger Exp $");
48 char*
strnstr(
const char* s,
const char* find,
size_t slen)
52 if((c = *find++) !=
'\0')
60 if(slen-- < 1 || (sc = *s++) ==
'\0')
73 }
while(
strncmp(s, find, len) != 0);
76 return ((
char*)(uintptr_t)s);
int strncmp(const char *s1, const char *s2, size_t n)
Compares at most n characters of two possibly null-terminated arrays.
size_t strlen(const char *str)
Returns the length of the given null-terminated byte string.
char * strnstr(const char *s, const char *find, size_t slen)
Finds the first occurrence of find in the initial slen characters of the object pointed to by s.