mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-01-22 01:30:35 -05:00
plugins: add strstr() to plugin API
Multiple plugins carry their own strstr() implementation because the in-core version wasn't exported to the plugin API. Change-Id: Ib57a9b63754c89fb3447ec1d3958963d23145105
This commit is contained in:
parent
2e1af37536
commit
a30f822500
12 changed files with 11 additions and 42 deletions
|
|
@ -868,6 +868,7 @@ static const struct plugin_api rockbox_api = {
|
|||
gesture_vel_process,
|
||||
gesture_vel_get,
|
||||
#endif
|
||||
strstr,
|
||||
};
|
||||
|
||||
static int plugin_buffer_handle;
|
||||
|
|
|
|||
|
|
@ -1019,6 +1019,7 @@ struct plugin_api {
|
|||
const struct touchevent *ev);
|
||||
bool (*gesture_vel_get)(struct gesture_vel *gv, int *xvel, int *yvel);
|
||||
#endif
|
||||
char* (*strstr)(const char *s1, const char *s2);
|
||||
};
|
||||
|
||||
/* plugin header */
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@ version 0.31 which is licensed under the GPL version 2:
|
|||
|
||||
gmtime.c
|
||||
strftime.c
|
||||
strstr.c
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ rocklib_img.c
|
|||
tlsf_helper.c
|
||||
strftime.c
|
||||
strpbrk.c
|
||||
strstr.c
|
||||
rocklua.c
|
||||
luadir.c
|
||||
rocklib_events.c
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ int splash_scroller(int timeout, const char* str);
|
|||
#define strlen rb->strlen
|
||||
#define strtol rb->strtol
|
||||
#define strtoul rb->strtoul
|
||||
#define strstr rb->strstr
|
||||
#define yield() rb->yield()
|
||||
|
||||
#endif /* _ROCKCONF_H_ */
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
#include "rocklibc.h"
|
||||
|
||||
char *strstr(const char *haystack, const char *needle) {
|
||||
size_t nl=strlen(needle);
|
||||
size_t hl=strlen(haystack);
|
||||
int i;
|
||||
if (!nl) goto found;
|
||||
if (nl>hl) return 0;
|
||||
for (i=hl-nl+1; __likely(i); --i) {
|
||||
if (*haystack==*needle && !memcmp(haystack,needle,nl))
|
||||
found:
|
||||
return (char*)haystack;
|
||||
++haystack;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@ munitrk.c
|
|||
npertab.c
|
||||
sloader.c
|
||||
//strdup.c
|
||||
strstr.c
|
||||
virtch.c
|
||||
virtch2.c
|
||||
virtch_common.c
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#define strncmp(a,b,c) rb->strncmp(a,b,c)
|
||||
#undef strcasecmp
|
||||
#define strcasecmp(a,b) rb->strcasecmp(a,b)
|
||||
#undef strstr
|
||||
#define strstr(a,b) rb->strstr(a,b)
|
||||
|
||||
#undef open
|
||||
#define open(a,b) rb->open(a,b)
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mikmod_supp.h"
|
||||
|
||||
char *strstr(const char *haystack, const char *needle)
|
||||
{
|
||||
const char *scan;
|
||||
size_t len;
|
||||
char firstc;
|
||||
|
||||
firstc = *needle;
|
||||
len = strlen(needle);
|
||||
for (scan = haystack; *scan != firstc || strncmp(scan, needle, len); )
|
||||
if (!*scan++)
|
||||
return NULL;
|
||||
return (char *)scan;
|
||||
}
|
||||
|
|
@ -195,6 +195,10 @@ void pd_init(void);
|
|||
#define ftoan rb_ftoan
|
||||
#undef strtok_r
|
||||
#define strtok_r rb->strtok_r
|
||||
|
||||
// NOTE: historically strstr() was not exported in the plugin API so this
|
||||
// has been defined as strcasestr(). It's likely this is wrong, but
|
||||
// changing it now could break user scripts...
|
||||
#define strstr rb->strcasestr
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@
|
|||
#define HAVE_STRLCPY 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRSTR 1
|
||||
|
||||
#undef strdup
|
||||
|
||||
|
|
@ -172,7 +173,7 @@
|
|||
#define strpbrk strpbrk_wrapper
|
||||
#endif
|
||||
#define strrchr rb->strrchr
|
||||
#define strstr SDL_strstr
|
||||
#define strstr rb->strstr
|
||||
#define strtok strtok_wrapper
|
||||
#define strtok_r rb->strtok_r
|
||||
#define HAVE_STRTOL 1
|
||||
|
|
|
|||
|
|
@ -345,7 +345,6 @@ SDL_strncasecmp rb_SDL_strncasecmp
|
|||
SDL_strncmp rb_SDL_strncmp
|
||||
SDL_strrchr rb_SDL_strrchr
|
||||
SDL_strrev rb_SDL_strrev
|
||||
SDL_strstr rb_SDL_strstr
|
||||
SDL_strtod rb_SDL_strtod
|
||||
SDL_strtoll.localalias.2 rb_SDL_strtoll.localalias.2
|
||||
SDL_strtoll rb_SDL_strtoll
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue