rockbox/apps/plugins/lua/strpbrk.c
William Wilgus 1aa739e3c3 lua misc tweaks and cleanup
checks button_status in rockev
strpbrk_n custom implementation allows setting max search len in source string
add some branch prediction where appropriate
fix formatting in splash_scroller script

Change-Id: Id5d8e9d83f4b3e361ccb67b403af8f9a8a31b8f0
2020-10-04 04:00:54 -04:00

17 lines
475 B
C

#include "rocklibc.h"
#undef strpbrk
/* custom strbbrk allowing you to define search len of s*/
const char *strpbrk_n(const char *s, int smax, const char *accept) {
register int i;
register const char *a = accept;
for (i=0; __likely(s[i] && i < smax); i++, a=accept)
while(__likely(a++[0]))
if ((s[i] == a[0]))
return &s[i];
return NULL;
}
inline char *strpbrk(const char *s, const char *accept) {
return (char*)strpbrk_n(s, INT_MAX, accept);
}