From 3954a51311f872abcce9b96ebe436b869939767a Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Fri, 6 Apr 2007 14:18:07 +0000 Subject: Better handling of subline timeout values : All values are set to the default before another value is found by the parser. No more resetting to the default value at displaying time (this caused problems especially noticeable on the DancePuffDuo WPS). Changing the values with conditionals is still possible but only strictly positive tiemout values are accepted now. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13045 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 5 ----- apps/gui/wps_debug.c | 11 +++++++++++ apps/gui/wps_parser.c | 12 ++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 4384284901..86003fa9ef 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -1763,14 +1763,9 @@ bool gui_wps_refresh(struct gui_wps *gwps, /* reset to first subline if refresh all flag is set */ if (refresh_mode == WPS_REFRESH_ALL) { - int j; for (i = 0; i < data->num_lines; i++) { data->curr_subline[i] = SUBLINE_RESET; - for (j = 0; j < data->num_sublines[i]; j++) - { - data->time_mult[i][j] = DEFAULT_SUBLINE_TIME_MULTIPLIER; - } } } diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index bcb05e0902..48aadc627d 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c @@ -362,6 +362,17 @@ void print_line_info(struct wps_data *data) DEBUGF("\n"); } + DEBUGF("subline time multipliers :\n"); + for (line = 0; line < data->num_lines; line++) + { + DEBUGF("%2d. ", line); + for (subline = 0; subline < data->num_sublines[line]; subline++) + { + DEBUGF("%3d ", data->time_mult[line][subline]); + } + DEBUGF("\n"); + } + DEBUGF("\n"); } diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index b51a76a594..8a226e1963 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -490,7 +490,15 @@ static int parse_subline_timeout(const char *wps_bufptr, struct wps_data *wps_da if (have_tenth == false) val *= 10; + /* We only want to allow strictly positive timeout values */ + if (val <= 0) + val = DEFAULT_SUBLINE_TIME_MULTIPLIER; + + int line = wps_data->num_lines; + int subline = wps_data->num_sublines[line]; + wps_data->time_mult[line][subline] = val; wps_data->tokens[wps_data->num_tokens].value.i = val; + return skip; } @@ -616,6 +624,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) data->num_tokens = 0; char *current_string = data->string_buffer; + data->time_mult[0][0] = DEFAULT_SUBLINE_TIME_MULTIPLIER; + while(wps_bufptr && *wps_bufptr && data->num_tokens < WPS_MAX_TOKENS && data->num_lines < WPS_MAX_LINES) { @@ -634,6 +644,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) data->tokens[data->num_tokens++].type = WPS_TOKEN_SUBLINE_SEPARATOR; subline = ++(data->num_sublines[data->num_lines]); data->format_lines[data->num_lines][subline] = data->num_tokens; + data->time_mult[data->num_lines][subline] = DEFAULT_SUBLINE_TIME_MULTIPLIER; } else wps_bufptr += skip_end_of_line(wps_bufptr); @@ -700,6 +711,7 @@ condlistend: /* close a conditional. sometimes we want to close them even when if (data->num_lines < WPS_MAX_LINES) { data->format_lines[data->num_lines][0] = data->num_tokens; + data->time_mult[data->num_lines][0] = DEFAULT_SUBLINE_TIME_MULTIPLIER; } break; -- cgit v1.2.3