1
0
Fork 0
forked from len0rd/rockbox

touchscreen regions:

a) check for trailing '|' so that it doesn't match wrong strings (a not-yet-existing "playlist" would match the existing "play")
b) don't recalculate the array length in each iteration

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21998 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-07-22 21:14:47 +00:00
parent 8d194f08d7
commit 23e46b3d98

View file

@ -1168,7 +1168,7 @@ static int parse_touchregion(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data) struct wps_token *token, struct wps_data *wps_data)
{ {
(void)token; (void)token;
unsigned i; unsigned i, imax;
struct touchregion *region; struct touchregion *region;
const char *ptr = wps_bufptr; const char *ptr = wps_bufptr;
const char *action; const char *action;
@ -1219,10 +1219,14 @@ static int parse_touchregion(const char *wps_bufptr,
else else
region->repeat = false; region->repeat = false;
imax = ARRAYLEN(touchactions);
while ((region->action == ACTION_NONE) && while ((region->action == ACTION_NONE) &&
(i < sizeof(touchactions)/sizeof(*touchactions))) (i < imax))
{ {
if (!strncmp(touchactions[i].s, action, strlen(touchactions[i].s))) /* try to match with one of our touchregion screens */
int len = strlen(touchactions[i].s);
if (!strncmp(touchactions[i].s, action, len)
&& *(action+len) == '|')
region->action = touchactions[i].action; region->action = touchactions[i].action;
i++; i++;
} }