summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lua/strpbrk.c
diff options
context:
space:
mode:
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 @@
#include "rocklibc.h"
#undef strpbrk
-char *strpbrk(const char *s, const char *accept) {
- register int i,l=strlen(accept);
- for (; *s; s++)
- for (i=0; i<l; i++)
- if (*s == accept[i])
- return (char*)s;
- return 0;
+/* 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);
}