forked from len0rd/rockbox
* implement strstr
* clean up usb_arcotg_dcd_enable git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14740 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
689d5fd446
commit
2077cebca0
3 changed files with 142 additions and 100 deletions
45
firmware/common/strstr.c
Normal file
45
firmware/common/strstr.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2007 by Christian Gmeiner
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Locate substring.
|
||||
* @param search c string to be scanned.
|
||||
* @param find c string containing the sequence of characters to match.
|
||||
* @return a pointer to the first occurrence in search of any of the
|
||||
* entire sequence of characters specified in find, or a
|
||||
* null pointer if the sequence is not present in search.
|
||||
*/
|
||||
char *strstr(const char *search, const char *find)
|
||||
{
|
||||
char *hend;
|
||||
char *a, *b;
|
||||
|
||||
if (*find == 0) return (char*)search;
|
||||
hend = (char *)search + strlen(search) - strlen(find) + 1;
|
||||
while (search < hend) {
|
||||
if (*search == *find) {
|
||||
a = (char *)search;
|
||||
b = (char *)find;
|
||||
for (;;) {
|
||||
if (*b == 0) return (char*)search;
|
||||
if (*a++ != *b++) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
search++;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue