From 913b91e36ce2b538bce869332afec08d58e50a66 Mon Sep 17 00:00:00 2001 From: kugel Date: Wed, 22 Jul 2009 21:14:47 +0000 Subject: [PATCH] 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 --- apps/gui/wps_parser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 8ae83924c..248269ddc 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -1168,7 +1168,7 @@ static int parse_touchregion(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) { (void)token; - unsigned i; + unsigned i, imax; struct touchregion *region; const char *ptr = wps_bufptr; const char *action; @@ -1218,11 +1218,15 @@ static int parse_touchregion(const char *wps_bufptr, } else region->repeat = false; - + + imax = ARRAYLEN(touchactions); 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; i++; } -- 2.11.4.GIT