2007-09-17 23:06:23 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
2010-07-11 19:55:18 +00:00
|
|
|
* Copyright (C) 2002 Manuel Novoa III
|
|
|
|
* Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
|
|
|
|
*
|
|
|
|
* Licensed under the LGPL v2.1, code originally in uclibc
|
2007-09-17 23:06:23 +00:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include <string.h>
|
|
|
|
|
2010-07-11 19:55:18 +00:00
|
|
|
/* NOTE: This is the simple-minded O(len(s1) * len(s2)) worst-case approach. */
|
|
|
|
|
2007-09-18 07:04:05 +00:00
|
|
|
char *strstr(const char *s1, const char *s2)
|
2007-09-17 23:06:23 +00:00
|
|
|
{
|
2010-07-11 22:37:31 +00:00
|
|
|
register const char *s = s1;
|
|
|
|
register const char *p = s2;
|
2007-09-17 23:06:23 +00:00
|
|
|
|
2010-07-11 22:37:31 +00:00
|
|
|
do {
|
|
|
|
if (!*p) {
|
|
|
|
return (char *) s1;
|
|
|
|
}
|
|
|
|
if (*p == *s) {
|
|
|
|
++p;
|
|
|
|
++s;
|
|
|
|
} else {
|
|
|
|
p = s2;
|
|
|
|
if (!*s) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
s = ++s1;
|
|
|
|
}
|
|
|
|
} while (1);
|
2007-09-17 23:06:23 +00:00
|
|
|
}
|