diff --git a/apps/plugin.c b/apps/plugin.c index 04e664674a..c35491f788 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -868,6 +868,7 @@ static const struct plugin_api rockbox_api = { gesture_vel_process, gesture_vel_get, #endif + strstr, }; static int plugin_buffer_handle; diff --git a/apps/plugin.h b/apps/plugin.h index 98b4e3e70c..e71afe3b52 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -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 */ diff --git a/apps/plugins/lua/README b/apps/plugins/lua/README index a56b500091..39dea02c6f 100644 --- a/apps/plugins/lua/README +++ b/apps/plugins/lua/README @@ -3,4 +3,3 @@ version 0.31 which is licensed under the GPL version 2: gmtime.c strftime.c - strstr.c diff --git a/apps/plugins/lua/SOURCES b/apps/plugins/lua/SOURCES index a188915a38..d30552343b 100644 --- a/apps/plugins/lua/SOURCES +++ b/apps/plugins/lua/SOURCES @@ -33,7 +33,6 @@ rocklib_img.c tlsf_helper.c strftime.c strpbrk.c -strstr.c rocklua.c luadir.c rocklib_events.c diff --git a/apps/plugins/lua/rockconf.h b/apps/plugins/lua/rockconf.h index 9ff42e1d6c..0f97135340 100644 --- a/apps/plugins/lua/rockconf.h +++ b/apps/plugins/lua/rockconf.h @@ -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_ */ diff --git a/apps/plugins/lua/strstr.c b/apps/plugins/lua/strstr.c deleted file mode 100644 index 2db47f4adf..0000000000 --- a/apps/plugins/lua/strstr.c +++ /dev/null @@ -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; -} diff --git a/apps/plugins/mikmod/SOURCES b/apps/plugins/mikmod/SOURCES index cfc0df4509..5ce67c10a0 100644 --- a/apps/plugins/mikmod/SOURCES +++ b/apps/plugins/mikmod/SOURCES @@ -32,7 +32,6 @@ munitrk.c npertab.c sloader.c //strdup.c -strstr.c virtch.c virtch2.c virtch_common.c diff --git a/apps/plugins/mikmod/mikmod_supp.h b/apps/plugins/mikmod/mikmod_supp.h index fdd9d8f24f..3fde618dda 100644 --- a/apps/plugins/mikmod/mikmod_supp.h +++ b/apps/plugins/mikmod/mikmod_supp.h @@ -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) diff --git a/apps/plugins/mikmod/strstr.c b/apps/plugins/mikmod/strstr.c deleted file mode 100644 index c2cf97ecde..0000000000 --- a/apps/plugins/mikmod/strstr.c +++ /dev/null @@ -1,21 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#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; -} diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h index 711d663da9..56abe7db7e 100644 --- a/apps/plugins/pdbox/pdbox.h +++ b/apps/plugins/pdbox/pdbox.h @@ -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 diff --git a/apps/plugins/sdl/include/SDL_config_rockbox.h b/apps/plugins/sdl/include/SDL_config_rockbox.h index 18057d800b..5a88378b89 100644 --- a/apps/plugins/sdl/include/SDL_config_rockbox.h +++ b/apps/plugins/sdl/include/SDL_config_rockbox.h @@ -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 diff --git a/apps/plugins/sdl/redefines.txt b/apps/plugins/sdl/redefines.txt index 5287f9b942..36a069b7c5 100644 --- a/apps/plugins/sdl/redefines.txt +++ b/apps/plugins/sdl/redefines.txt @@ -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