summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-10-12 12:03:07 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-10-12 12:03:07 +0000
commit69e379a47b6c7830fc17e912eecde6eb5100037f (patch)
treeb6442e9c7ab6939c83b8565dbe20c5ff5fbd131e
parente1c9eb31f79c1c403e03869f19b733fd2b5e7c0e (diff)
downloadrockbox-69e379a47b6c7830fc17e912eecde6eb5100037f.tar.gz
rockbox-69e379a47b6c7830fc17e912eecde6eb5100037f.zip
Skin bar tags fix+cleanup:
Don't crash when not enough params were given (i.e forgetting the filename) Make the parser enforce the first 4 params as compulsary Be more leniant and don't require the image filename if one isnt going to be loaded (no more need for the - as the 5th param) Add an option "image" to specify the filename (otherwise the first option will be used if it isnt a recognised option). e.g: %pv(0,0,100,10) or %pv(0,0,100,10, bar.bmp) or %pv(0,0,100,10, ..., image, bar.bmp) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28247 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/skin_engine/skin_parser.c33
-rw-r--r--lib/skin_parser/tag_table.c2
2 files changed, 26 insertions, 9 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 75b4c4298f..5c169c81de 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -619,7 +619,7 @@ static int parse_progressbar_tag(struct skin_element* element,
619 return -1; 619 return -1;
620 add_to_ll_chain(&wps_data->progressbars, item); 620 add_to_ll_chain(&wps_data->progressbars, item);
621 621
622 /* (x,y,width,height,filename) */ 622 /* (x, y, width, height, ...) */
623 if (!isdefault(param)) 623 if (!isdefault(param))
624 pb->x = param->data.number; 624 pb->x = param->data.number;
625 else 625 else
@@ -659,11 +659,15 @@ static int parse_progressbar_tag(struct skin_element* element,
659#endif 659#endif
660 } 660 }
661 } 661 }
662 param++; 662 /* optional params, first is the image filename if it isnt recognised as a keyword */
663 if (!isdefault(param)) 663
664 pb->bm.data = param->data.text; 664 curr_param = 4;
665 665 if (isdefault(&element->params[curr_param]))
666 curr_param = 5; 666 {
667 param++;
668 curr_param++;
669 }
670
667 pb->horizontal = pb->width > pb->height; 671 pb->horizontal = pb->width > pb->height;
668 while (curr_param < element->params_count) 672 while (curr_param < element->params_count)
669 { 673 {
@@ -679,9 +683,20 @@ static int parse_progressbar_tag(struct skin_element* element,
679 curr_param++; 683 curr_param++;
680 param++; 684 param++;
681 pb->slider = find_image(param->data.text, wps_data); 685 pb->slider = find_image(param->data.text, wps_data);
682 if (!pb->slider)
683 return -1;
684 } 686 }
687 else /* option needs the next param */
688 return -1;
689 }
690 else if (!strcmp(param->data.text, "image"))
691 {
692 if (curr_param+1 < element->params_count)
693 {
694 curr_param++;
695 param++;
696 pb->bm.data = param->data.text;
697 }
698 else /* option needs the next param */
699 return -1;
685 } 700 }
686 else if (!strcmp(param->data.text, "vertical")) 701 else if (!strcmp(param->data.text, "vertical"))
687 { 702 {
@@ -691,6 +706,8 @@ static int parse_progressbar_tag(struct skin_element* element,
691 } 706 }
692 else if (!strcmp(param->data.text, "horizontal")) 707 else if (!strcmp(param->data.text, "horizontal"))
693 pb->horizontal = true; 708 pb->horizontal = true;
709 else if (curr_param == 4)
710 pb->bm.data = param->data.text;
694 711
695 curr_param++; 712 curr_param++;
696 } 713 }
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index 08246b3a89..8b31adab2c 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -22,7 +22,7 @@
22#include "tag_table.h" 22#include "tag_table.h"
23 23
24#include <string.h> 24#include <string.h>
25#define BAR_PARAMS "*|iiiisN" 25#define BAR_PARAMS "*iiii|sN"
26/* The tag definition table */ 26/* The tag definition table */
27static const struct tag_info legal_tags[] = 27static const struct tag_info legal_tags[] =
28{ 28{