summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/strpbrk.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-10-03 22:45:27 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-10-04 04:00:54 -0400
commit1aa739e3c3d1ce25cdebe285847c3c493756d5d6 (patch)
tree554a5500c2483032fddb06bd5ff8589e942d86be /apps/plugins/lua/strpbrk.c
parentf3ae48f552e2d12e1d60e86198ff7ee26aabc2ec (diff)
downloadrockbox-1aa739e3c3d1ce25cdebe285847c3c493756d5d6.tar.gz
rockbox-1aa739e3c3d1ce25cdebe285847c3c493756d5d6.zip
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
Diffstat (limited to 'apps/plugins/lua/strpbrk.c')
-rw-r--r--apps/plugins/lua/strpbrk.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/plugins/lua/strpbrk.c b/apps/plugins/lua/strpbrk.c
index 1e0491f779..efa9cbd2bb 100644
--- a/apps/plugins/lua/strpbrk.c
+++ b/apps/plugins/lua/strpbrk.c
@@ -1,11 +1,17 @@
1#include "rocklibc.h" 1#include "rocklibc.h"
2 2
3#undef strpbrk 3#undef strpbrk
4char *strpbrk(const char *s, const char *accept) { 4/* custom strbbrk allowing you to define search len of s*/
5 register int i,l=strlen(accept); 5const char *strpbrk_n(const char *s, int smax, const char *accept) {
6 for (; *s; s++) 6 register int i;
7 for (i=0; i<l; i++) 7 register const char *a = accept;
8 if (*s == accept[i]) 8 for (i=0; __likely(s[i] && i < smax); i++, a=accept)
9 return (char*)s; 9 while(__likely(a++[0]))
10 return 0; 10 if ((s[i] == a[0]))
11 return &s[i];
12 return NULL;
13}
14
15inline char *strpbrk(const char *s, const char *accept) {
16 return (char*)strpbrk_n(s, INT_MAX, accept);
11} 17}