NEW CODE:::: static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) { struct skin_element *element=line; struct wps_token *token; int retval = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT; restart: /* we are really using tail recursion so do it with a messy goto to prevent stack overusage */ if (element->type == LINE) { if (element->children_count == 0) return retval; /* empty line, so force redraw */ element = element->children[0]; } while (element) { if (element->type == TAG && element->tag->type == SKIN_TOKEN_SUBLINE_TIMEOUT ) { token = element->data; return token->value.i; } else if (element->type == CONDITIONAL) { struct conditional *conditional = element->data; int val = evaluate_conditional(gwps, 0, conditional, element->children_count); if (val >= 0) { element = element->children[val]; goto restart; } } element = element->next; } return retval; } ============= OLD CODE static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) { struct skin_element *element=line; struct wps_token *token; int retval = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT; if (element->type == LINE) { if (element->children_count == 0) return retval; /* empty line, so force redraw */ element = element->children[0]; } while (element) { if (element->type == TAG && element->tag->type == SKIN_TOKEN_SUBLINE_TIMEOUT ) { token = element->data; return token->value.i; } else if (element->type == CONDITIONAL) { struct conditional *conditional = element->data; int val = evaluate_conditional(gwps, 0, conditional, element->children_count); if (val >= 0) { retval = get_subline_timeout(gwps, element->children[val]); if (retval >= 0) return retval; } } element = element->next; } return retval; } =============== DIFF diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 304ebf1..0c0bf01 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c @@ -483,6 +483,8 @@ static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) struct skin_element *element=line; struct wps_token *token; int retval = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT; +restart: /* we are really using tail recursion so do it with a messy goto + to prevent stack overusage */ if (element->type == LINE) { if (element->children_count == 0) @@ -504,9 +506,8 @@ static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) element->children_count); if (val >= 0) { - retval = get_subline_timeout(gwps, element->children[val]); - if (retval >= 0) - return retval; + element = element->children[val]; + goto restart; } } element = element->next;