From 814d402d4c9c011ee7e357e74cca6a64176a33d8 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sat, 21 Apr 2007 19:31:46 +0000 Subject: 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 --- apps/gui/gwps-common.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'apps/gui/gwps-common.c') 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, */ static int find_conditional_end(struct wps_data *data, int index) { - int type = data->tokens[index].type; - - if (type != WPS_TOKEN_CONDITIONAL_START - && type != WPS_TOKEN_CONDITIONAL_OPTION) - { - /* this function should only be used with "index" pointing to a - WPS_TOKEN_CONDITIONAL_START or a WPS_TOKEN_CONDITIONAL_OPTION */ - return index + 1; - } - int ret = index; while (data->tokens[ret].type != WPS_TOKEN_CONDITIONAL_END) ret = data->tokens[ret].value.i; @@ -1304,18 +1294,8 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index) struct wps_data *data = gwps->data; int ret, i; - int num_options = data->tokens[cond_index].value.i; char result[128], *value; - int cond_start = cond_index; - - /* find the index of the conditional start token */ - while (data->tokens[cond_start].type != WPS_TOKEN_CONDITIONAL_START - && cond_start < data->num_tokens) - cond_start++; - - /* if the number of options is 0, the conditional is invalid */ - if (num_options == 0) - return cond_start; + int num_options = data->tokens[cond_index].value.i; /* treat ?xx constructs as if they had 2 options. */ if (num_options < 2) @@ -1334,7 +1314,7 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index) intval = num_options; /* skip to the right enum case */ - int next = cond_start; + int next = cond_index + 2; for (i = 1; i < intval; i++) { next = data->tokens[next].value.i; -- cgit v1.2.3