summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/skin_engine/skin_parser.c9
-rw-r--r--lib/skin_parser/skin_parser.c76
-rw-r--r--lib/skin_parser/tag_table.c2
-rw-r--r--lib/skin_parser/tag_table.h4
4 files changed, 78 insertions, 13 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 39eefc69e0..90c5938e23 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -243,6 +243,7 @@ static int parse_image_display(struct skin_element *element,
243 } 243 }
244 id->label = label; 244 id->label = label;
245 id->offset = 0; 245 id->offset = 0;
246 id->token = NULL;
246 img->using_preloaded_icons = false; 247 img->using_preloaded_icons = false;
247 if (!strcmp(img->bm.data, "__list_icons__")) 248 if (!strcmp(img->bm.data, "__list_icons__"))
248 { 249 {
@@ -253,19 +254,21 @@ static int parse_image_display(struct skin_element *element,
253 254
254 if (element->params_count > 1) 255 if (element->params_count > 1)
255 { 256 {
256 id->token = element->params[1].data.code->data; 257 if (element->params[1].type == CODE)
258 id->token = element->params[1].data.code->data;
259 /* specify a number. 1 being the first subimage (i.e top) NOT 0 */
260 else if (element->params[1].type == INTEGER)
261 id->subimage = element->params[1].data.number - 1;
257 if (element->params_count > 2) 262 if (element->params_count > 2)
258 id->offset = element->params[2].data.number; 263 id->offset = element->params[2].data.number;
259 } 264 }
260 else 265 else
261 { 266 {
262 id->token = NULL;
263 if ((subimage = get_image_id(sublabel)) != -1) 267 if ((subimage = get_image_id(sublabel)) != -1)
264 { 268 {
265 if (subimage >= img->num_subimages) 269 if (subimage >= img->num_subimages)
266 return WPS_ERROR_INVALID_PARAM; 270 return WPS_ERROR_INVALID_PARAM;
267 id->subimage = subimage; 271 id->subimage = subimage;
268 token->value.i = label | (subimage << 8);
269 } else { 272 } else {
270 id->subimage = 0; 273 id->subimage = 0;
271 } 274 }
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c
index fba074f00c..66deaab102 100644
--- a/lib/skin_parser/skin_parser.c
+++ b/lib/skin_parser/skin_parser.c
@@ -579,6 +579,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
579 /* Now we have to actually parse each argument */ 579 /* Now we have to actually parse each argument */
580 for(i = 0; i < num_args; i++) 580 for(i = 0; i < num_args; i++)
581 { 581 {
582 char type_code;
582 /* Making sure we haven't run out of arguments */ 583 /* Making sure we haven't run out of arguments */
583 if(*tag_args == '\0') 584 if(*tag_args == '\0')
584 { 585 {
@@ -600,14 +601,71 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
600 /* Checking for comments */ 601 /* Checking for comments */
601 if(*cursor == COMMENTSYM) 602 if(*cursor == COMMENTSYM)
602 skip_comment(&cursor); 603 skip_comment(&cursor);
603 604
605 if (*tag_args == '[')
606 {
607 /* we need to guess which type of param it is.
608 * guess using this priority:
609 * default > decimal/integer > single tag/code > string
610 */
611 int j=0;
612 bool canbedefault = false;
613 bool haspercent = false, number = true, hasdecimal = false;
614 char temp_params[8];
615 tag_args++;
616 while (*tag_args != ']')
617 {
618 if (*tag_args >= 'a' && *tag_args <= 'z')
619 canbedefault = true;
620 temp_params[j++] = tolower(*tag_args++);
621 }
622 temp_params[j] = '\0';
623 j = 0;
624 while (cursor[j] != ',' && cursor[j] != ')')
625 {
626 haspercent = haspercent || (cursor[j] == '%');
627 hasdecimal = hasdecimal || (cursor[j] == '.');
628 number = number && (isdigit(cursor[j]) || (cursor[j] == '.'));
629 j++;
630 }
631 type_code = '*';
632 if (canbedefault && *cursor == DEFAULTSYM && !isdigit(cursor[1]))
633 {
634 type_code = 'i';
635 }
636 else if (number && hasdecimal && strchr(temp_params, 'd'))
637 {
638 type_code = 'd';
639 }
640 else if (number &&
641 (strchr(temp_params, 'i') || strchr(temp_params, 'd')))
642 {
643 type_code = strchr(temp_params, 'i') ? 'i' : 'd';
644 }
645 else if (haspercent &&
646 (strchr(temp_params, 't') || strchr(temp_params, 'c')))
647 {
648 type_code = strchr(temp_params, 't') ? 't' : 'c';
649 }
650 else if (strchr(temp_params, 's'))
651 {
652 type_code = 's';
653 }
654 if (type_code == '*')
655 {
656 skin_error(INSUFFICIENT_ARGS, cursor);
657 return 0;
658 }
659 }
660 else
661 type_code = *tag_args;
604 /* Storing the type code */ 662 /* Storing the type code */
605 element->params[i].type_code = *tag_args; 663 element->params[i].type_code = type_code;
606 664
607 /* Checking a nullable argument for null. */ 665 /* Checking a nullable argument for null. */
608 if(*cursor == DEFAULTSYM && !isdigit(cursor[1])) 666 if(*cursor == DEFAULTSYM && !isdigit(cursor[1]))
609 { 667 {
610 if(islower(*tag_args)) 668 if(islower(type_code))
611 { 669 {
612 element->params[i].type = DEFAULT; 670 element->params[i].type = DEFAULT;
613 cursor++; 671 cursor++;
@@ -618,7 +676,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
618 return 0; 676 return 0;
619 } 677 }
620 } 678 }
621 else if(tolower(*tag_args) == 'i') 679 else if(tolower(type_code) == 'i')
622 { 680 {
623 /* Scanning an int argument */ 681 /* Scanning an int argument */
624 if(!isdigit(*cursor) && *cursor != '-') 682 if(!isdigit(*cursor) && *cursor != '-')
@@ -630,7 +688,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
630 element->params[i].type = INTEGER; 688 element->params[i].type = INTEGER;
631 element->params[i].data.number = scan_int(&cursor); 689 element->params[i].data.number = scan_int(&cursor);
632 } 690 }
633 else if(tolower(*tag_args) == 'd') 691 else if(tolower(type_code) == 'd')
634 { 692 {
635 int val = 0; 693 int val = 0;
636 bool have_point = false; 694 bool have_point = false;
@@ -657,15 +715,15 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
657 element->params[i].type = DECIMAL; 715 element->params[i].type = DECIMAL;
658 element->params[i].data.number = val; 716 element->params[i].data.number = val;
659 } 717 }
660 else if(tolower(*tag_args) == 'n' || 718 else if(tolower(type_code) == 'n' ||
661 tolower(*tag_args) == 's' || tolower(*tag_args) == 'f') 719 tolower(type_code) == 's' || tolower(type_code) == 'f')
662 { 720 {
663 /* Scanning a string argument */ 721 /* Scanning a string argument */
664 element->params[i].type = STRING; 722 element->params[i].type = STRING;
665 element->params[i].data.text = scan_string(&cursor); 723 element->params[i].data.text = scan_string(&cursor);
666 724
667 } 725 }
668 else if(tolower(*tag_args) == 'c') 726 else if(tolower(type_code) == 'c')
669 { 727 {
670 /* Recursively parsing a code argument */ 728 /* Recursively parsing a code argument */
671 element->params[i].type = CODE; 729 element->params[i].type = CODE;
@@ -673,7 +731,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
673 if(!element->params[i].data.code) 731 if(!element->params[i].data.code)
674 return 0; 732 return 0;
675 } 733 }
676 else if (tolower(*tag_args) == 't') 734 else if (tolower(type_code) == 't')
677 { 735 {
678 struct skin_element* child = skin_alloc_element(); 736 struct skin_element* child = skin_alloc_element();
679 child->type = TAG; 737 child->type = TAG;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index dccb9f8259..4f201ec911 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -167,7 +167,7 @@ static const struct tag_info legal_tags[] =
167 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK }, 167 { SKIN_TOKEN_DRAW_INBUILTBAR, "wi", "", SKIN_REFRESH_STATIC|NOBREAK },
168 168
169 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I", 0|NOBREAK }, 169 { SKIN_TOKEN_IMAGE_PRELOAD, "xl", "SFII|I", 0|NOBREAK },
170 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|TI", 0 }, 170 { SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", "S|[IT]I", 0 },
171 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SFII", 0|NOBREAK }, 171 { SKIN_TOKEN_IMAGE_DISPLAY, "x", "SFII", 0|NOBREAK },
172 172
173 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF", 0|NOBREAK }, 173 { SKIN_TOKEN_LOAD_FONT, "Fl" , "IF", 0|NOBREAK },
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h
index c96feccc65..4b7efaa835 100644
--- a/lib/skin_parser/tag_table.h
+++ b/lib/skin_parser/tag_table.h
@@ -291,6 +291,10 @@ enum skin_token_type {
291 * 2s 291 * 2s
292 * will specify two strings. An asterisk (*) at the beginning of the 292 * will specify two strings. An asterisk (*) at the beginning of the
293 * string will specify that you may choose to omit all arguments 293 * string will specify that you may choose to omit all arguments
294 *
295 * You may also group param types in [] which will tell the parser to
296 * accept any *one* of those types for that param. i.e [IT] will
297 * accept either an integer or tag type. [ITs] will also accept a string or -
294 * 298 *
295 */ 299 */
296struct tag_info 300struct tag_info