diff options
author | William Wilgus <wilgus.william@gmail.com> | 2020-10-03 22:45:27 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2020-10-04 04:00:54 -0400 |
commit | 1aa739e3c3d1ce25cdebe285847c3c493756d5d6 (patch) | |
tree | 554a5500c2483032fddb06bd5ff8589e942d86be /apps/plugins/lua/rockaux.c | |
parent | f3ae48f552e2d12e1d60e86198ff7ee26aabc2ec (diff) | |
download | rockbox-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/rockaux.c')
-rw-r--r-- | apps/plugins/lua/rockaux.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c index 7ed82f616d..25bace3451 100644 --- a/apps/plugins/lua/rockaux.c +++ b/apps/plugins/lua/rockaux.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "lib/pluginlib_actions.h" | 27 | #include "lib/pluginlib_actions.h" |
28 | 28 | ||
29 | extern long strtol(const char *nptr, char **endptr, int base); | 29 | extern long strtol(const char *nptr, char **endptr, int base); |
30 | extern const char *strpbrk_n(const char *s, int smax, const char *accept); | ||
30 | 31 | ||
31 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 32 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
32 | int errno = 0; | 33 | int errno = 0; |
@@ -58,7 +59,7 @@ int splash_scroller(int timeout, const char* str) | |||
58 | const int max_lines = LCD_HEIGHT / ch_h - 1; | 59 | const int max_lines = LCD_HEIGHT / ch_h - 1; |
59 | const int wrap_thresh = (LCD_WIDTH / 3); | 60 | const int wrap_thresh = (LCD_WIDTH / 3); |
60 | const char *ch; | 61 | const char *ch; |
61 | char *brk; | 62 | const char *brk; |
62 | 63 | ||
63 | const int max_ch = (LCD_WIDTH / ch_w - 1) * 2; | 64 | const int max_ch = (LCD_WIDTH / ch_w - 1) * 2; |
64 | char line[max_ch + 2]; /* display buffer */ | 65 | char line[max_ch + 2]; /* display buffer */ |
@@ -98,9 +99,10 @@ int splash_scroller(int timeout, const char* str) | |||
98 | rb->lcd_getstringsize(line, &w, NULL); | 99 | rb->lcd_getstringsize(line, &w, NULL); |
99 | 100 | ||
100 | /* try to not split in middle of words */ | 101 | /* try to not split in middle of words */ |
101 | if (w + wrap_thresh >= max_w && strpbrk (&line[linepos], break_chars)) | 102 | if (w + wrap_thresh >= max_w && |
103 | strpbrk_n(ch, 1, break_chars)) | ||
102 | { | 104 | { |
103 | brk = strpbrk(ch+1, break_chars); | 105 | brk = strpbrk_n(ch+1, max_ch, break_chars); |
104 | chars_next_break = (brk - ch); | 106 | chars_next_break = (brk - ch); |
105 | if (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w) | 107 | if (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w) |
106 | { | 108 | { |