forked from len0rd/rockbox
import and use the Linux one instead, bound to be faster
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14741 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2077cebca0
commit
a20f32d2a5
1 changed files with 18 additions and 25 deletions
|
|
@ -7,39 +7,32 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id: $
|
* $Id: $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 by Christian Gmeiner
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||||
|
* (from linux/lib/string.c)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locate substring.
|
* strstr - Find the first substring in a %NUL terminated string
|
||||||
* @param search c string to be scanned.
|
* @s1: The string to be searched
|
||||||
* @param find c string containing the sequence of characters to match.
|
* @s2: The string to search for
|
||||||
* @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 *strstr(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
char *hend;
|
int l1, l2;
|
||||||
char *a, *b;
|
|
||||||
|
|
||||||
if (*find == 0) return (char*)search;
|
l2 = strlen(s2);
|
||||||
hend = (char *)search + strlen(search) - strlen(find) + 1;
|
if (!l2)
|
||||||
while (search < hend) {
|
return (char *)s1;
|
||||||
if (*search == *find) {
|
l1 = strlen(s1);
|
||||||
a = (char *)search;
|
while (l1 >= l2) {
|
||||||
b = (char *)find;
|
l1--;
|
||||||
for (;;) {
|
if (!memcmp(s1, s2, l2))
|
||||||
if (*b == 0) return (char*)search;
|
return (char *)s1;
|
||||||
if (*a++ != *b++) {
|
s1++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return NULL;
|
||||||
}
|
|
||||||
search++;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue