1
0
Fork 0
forked from len0rd/rockbox
foxbox/firmware/libc/strstr.c
Rafaël Carré 6aff55b202 strstr: replace GPLv2-only implementation from Linux by LGPLv2.1 from uclibc
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27393 a1c6a512-1295-4272-9138-f99709370657
2010-07-11 19:55:18 +00:00

39 lines
1.1 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* 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
*
****************************************************************************/
#include <string.h>
/* NOTE: This is the simple-minded O(len(s1) * len(s2)) worst-case approach. */
char *strstr(const char *s1, const char *s2)
{
register const char *s = s1;
register const char *p = s2;
do {
if (!*p) {
return (char *) s1;;
}
if (*p == *s) {
++p;
++s;
} else {
p = s2;
if (!*s) {
return NULL;
}
s = ++s1;
}
} while (1);
}