Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 10th, 2010  |  syntax: None  |  size: 3.56 KB  |  views: 70  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. NEW CODE::::
  2.  
  3. static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line)
  4. {
  5.     struct skin_element *element=line;
  6.     struct wps_token *token;
  7.     int retval = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT;
  8. restart: /* we are really using tail recursion so do it with a messy goto
  9.             to prevent stack overusage */
  10.     if (element->type == LINE)
  11.     {
  12.         if (element->children_count == 0)
  13.             return retval; /* empty line, so force redraw */
  14.         element = element->children[0];
  15.     }
  16.     while (element)
  17.     {
  18.         if (element->type == TAG &&
  19.             element->tag->type == SKIN_TOKEN_SUBLINE_TIMEOUT )
  20.         {
  21.             token = element->data;
  22.             return token->value.i;
  23.         }
  24.         else if (element->type == CONDITIONAL)
  25.         {
  26.             struct conditional *conditional = element->data;
  27.             int val = evaluate_conditional(gwps, 0, conditional,
  28.                                            element->children_count);
  29.             if (val >= 0)
  30.             {
  31.                 element = element->children[val];
  32.                 goto restart;
  33.             }
  34.         }
  35.         element = element->next;
  36.     }
  37.     return retval;
  38. }
  39.  
  40.  
  41. =============
  42. OLD CODE
  43.  
  44.  
  45. static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line)
  46. {
  47.     struct skin_element *element=line;
  48.     struct wps_token *token;
  49.     int retval = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT;
  50.     if (element->type == LINE)
  51.     {
  52.         if (element->children_count == 0)
  53.             return retval; /* empty line, so force redraw */
  54.         element = element->children[0];
  55.     }
  56.     while (element)
  57.     {
  58.         if (element->type == TAG &&
  59.             element->tag->type == SKIN_TOKEN_SUBLINE_TIMEOUT )
  60.         {
  61.             token = element->data;
  62.             return token->value.i;
  63.         }
  64.         else if (element->type == CONDITIONAL)
  65.         {
  66.             struct conditional *conditional = element->data;
  67.             int val = evaluate_conditional(gwps, 0, conditional,
  68.                                            element->children_count);
  69.             if (val >= 0)
  70.             {
  71.                
  72.                 retval = get_subline_timeout(gwps, element->children[val]);
  73.                 if (retval >= 0)
  74.                     return retval;
  75.             }
  76.         }
  77.         element = element->next;
  78.     }
  79.     return retval;
  80. }
  81.  
  82.  
  83. ===============
  84.  
  85. DIFF
  86.  
  87.  
  88. diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
  89. index 304ebf1..0c0bf01 100644
  90. --- a/apps/gui/skin_engine/skin_render.c
  91. +++ b/apps/gui/skin_engine/skin_render.c
  92. @@ -483,6 +483,8 @@ static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line)
  93.      struct skin_element *element=line;
  94.      struct wps_token *token;
  95.      int retval = DEFAULT_SUBLINE_TIME_MULTIPLIER*TIMEOUT_UNIT;
  96. +restart: /* we are really using tail recursion so do it with a messy goto
  97. +            to prevent stack overusage */
  98.      if (element->type == LINE)
  99.      {
  100.          if (element->children_count == 0)
  101. @@ -504,9 +506,8 @@ static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line)
  102.                                             element->children_count);
  103.              if (val >= 0)
  104.              {
  105. -                retval = get_subline_timeout(gwps, element->children[val]);
  106. -                if (retval >= 0)
  107. -                    return retval;
  108. +                element = element->children[val];
  109. +                goto restart;
  110.              }
  111.          }
  112.          element = element->next;