forked from len0rd/rockbox
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
This commit is contained in:
parent
f3ae48f552
commit
1aa739e3c3
6 changed files with 25 additions and 24 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "lib/pluginlib_actions.h"
|
||||
|
||||
extern long strtol(const char *nptr, char **endptr, int base);
|
||||
extern const char *strpbrk_n(const char *s, int smax, const char *accept);
|
||||
|
||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||
int errno = 0;
|
||||
|
@ -58,7 +59,7 @@ int splash_scroller(int timeout, const char* str)
|
|||
const int max_lines = LCD_HEIGHT / ch_h - 1;
|
||||
const int wrap_thresh = (LCD_WIDTH / 3);
|
||||
const char *ch;
|
||||
char *brk;
|
||||
const char *brk;
|
||||
|
||||
const int max_ch = (LCD_WIDTH / ch_w - 1) * 2;
|
||||
char line[max_ch + 2]; /* display buffer */
|
||||
|
@ -98,9 +99,10 @@ int splash_scroller(int timeout, const char* str)
|
|||
rb->lcd_getstringsize(line, &w, NULL);
|
||||
|
||||
/* try to not split in middle of words */
|
||||
if (w + wrap_thresh >= max_w && strpbrk (&line[linepos], break_chars))
|
||||
if (w + wrap_thresh >= max_w &&
|
||||
strpbrk_n(ch, 1, break_chars))
|
||||
{
|
||||
brk = strpbrk(ch+1, break_chars);
|
||||
brk = strpbrk_n(ch+1, max_ch, break_chars);
|
||||
chars_next_break = (brk - ch);
|
||||
if (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue