summaryrefslogtreecommitdiff
path: root/apps/gui/gwps-common.c
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-04-21 19:31:46 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-04-21 19:31:46 +0000
commit814d402d4c9c011ee7e357e74cca6a64176a33d8 (patch)
tree69f55addc2e6e88441cd9a906ae3b207e461c29a /apps/gui/gwps-common.c
parenteb85f14f9549b328cdd76c93ecdf6862a5d0b341 (diff)
downloadrockbox-814d402d4c9c011ee7e357e74cca6a64176a33d8.tar.gz
rockbox-814d402d4c9c011ee7e357e74cca6a64176a33d8.zip
More strict WPS parsing and displaying code. If there are errors, WPS loading will fail and the default WPS will be displayed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13236 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/gwps-common.c')
-rw-r--r--apps/gui/gwps-common.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index d6576a2b3c..8022209189 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -1275,16 +1275,6 @@ static char *get_token_value(struct gui_wps *gwps,
1275*/ 1275*/
1276static int find_conditional_end(struct wps_data *data, int index) 1276static int find_conditional_end(struct wps_data *data, int index)
1277{ 1277{
1278 int type = data->tokens[index].type;
1279
1280 if (type != WPS_TOKEN_CONDITIONAL_START
1281 && type != WPS_TOKEN_CONDITIONAL_OPTION)
1282 {
1283 /* this function should only be used with "index" pointing to a
1284 WPS_TOKEN_CONDITIONAL_START or a WPS_TOKEN_CONDITIONAL_OPTION */
1285 return index + 1;
1286 }
1287
1288 int ret = index; 1278 int ret = index;
1289 while (data->tokens[ret].type != WPS_TOKEN_CONDITIONAL_END) 1279 while (data->tokens[ret].type != WPS_TOKEN_CONDITIONAL_END)
1290 ret = data->tokens[ret].value.i; 1280 ret = data->tokens[ret].value.i;
@@ -1304,18 +1294,8 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index)
1304 struct wps_data *data = gwps->data; 1294 struct wps_data *data = gwps->data;
1305 1295
1306 int ret, i; 1296 int ret, i;
1307 int num_options = data->tokens[cond_index].value.i;
1308 char result[128], *value; 1297 char result[128], *value;
1309 int cond_start = cond_index; 1298 int num_options = data->tokens[cond_index].value.i;
1310
1311 /* find the index of the conditional start token */
1312 while (data->tokens[cond_start].type != WPS_TOKEN_CONDITIONAL_START
1313 && cond_start < data->num_tokens)
1314 cond_start++;
1315
1316 /* if the number of options is 0, the conditional is invalid */
1317 if (num_options == 0)
1318 return cond_start;
1319 1299
1320 /* treat ?xx<true> constructs as if they had 2 options. */ 1300 /* treat ?xx<true> constructs as if they had 2 options. */
1321 if (num_options < 2) 1301 if (num_options < 2)
@@ -1334,7 +1314,7 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index)
1334 intval = num_options; 1314 intval = num_options;
1335 1315
1336 /* skip to the right enum case */ 1316 /* skip to the right enum case */
1337 int next = cond_start; 1317 int next = cond_index + 2;
1338 for (i = 1; i < intval; i++) 1318 for (i = 1; i < intval; i++)
1339 { 1319 {
1340 next = data->tokens[next].value.i; 1320 next = data->tokens[next].value.i;