summaryrefslogtreecommitdiff
path: root/lib/skin_parser/skin_parser.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-04-21 23:34:42 +1000
committerJonathan Gordon <rockbox@jdgordon.info>2012-04-22 00:24:16 +1000
commit2d3c43dffeb048297313cd9333731d47d66010a0 (patch)
treec5f305939f17cd1014c02991790290be7987a146 /lib/skin_parser/skin_parser.c
parent2315a23c04ec03bbe4496dd079bb68a450658cf7 (diff)
downloadrockbox-2d3c43dffeb048297313cd9333731d47d66010a0.tar.gz
rockbox-2d3c43dffeb048297313cd9333731d47d66010a0.zip
skin_engine: rework the parser to be closer to the langauge grammar.
The parser was unconditionally scanning things which it thought were conditional/enum lists (or tag arg lists) when they couldn't possibly be (i.e < inside a param which should be valid). This change fixes it (i.e %?and(%if(%pv, <, -50), %if(%mp, >i, 1)) is perfectly valid now. This *may* break your exsiting skins if you were using %if with < or > Change-Id: Ia24dbdf0b11fc7d8a735c1111d648c3bebd68ac6
Diffstat (limited to 'lib/skin_parser/skin_parser.c')
-rw-r--r--lib/skin_parser/skin_parser.c65
1 files changed, 5 insertions, 60 deletions
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c
index a81bcded34..44a1c03245 100644
--- a/lib/skin_parser/skin_parser.c
+++ b/lib/skin_parser/skin_parser.c
@@ -182,26 +182,12 @@ static struct skin_element* skin_parse_viewport(const char** document)
182 } 182 }
183 else if(*cursor == TAGSYM) 183 else if(*cursor == TAGSYM)
184 { 184 {
185 /* A ';' directly after a '%' doesn't count */ 185 skip_tag(&cursor);
186 cursor ++;
187
188 if(*cursor == '\0')
189 break;
190
191 cursor++;
192 } 186 }
193 else if(*cursor == COMMENTSYM) 187 else if(*cursor == COMMENTSYM)
194 { 188 {
195 skip_comment(&cursor); 189 skip_comment(&cursor);
196 } 190 }
197 else if(*cursor == ARGLISTOPENSYM)
198 {
199 skip_arglist(&cursor);
200 }
201 else if(*cursor == ENUMLISTOPENSYM)
202 {
203 skip_enumlist(&cursor);
204 }
205 else 191 else
206 { 192 {
207 /* Advancing the cursor as normal */ 193 /* Advancing the cursor as normal */
@@ -445,20 +431,9 @@ static struct skin_element* skin_parse_sublines_optional(const char** document,
445 { 431 {
446 skip_comment(&cursor); 432 skip_comment(&cursor);
447 } 433 }
448 else if(*cursor == ENUMLISTOPENSYM)
449 {
450 skip_enumlist(&cursor);
451 }
452 else if(*cursor == ARGLISTOPENSYM)
453 {
454 skip_arglist(&cursor);
455 }
456 else if(*cursor == TAGSYM) 434 else if(*cursor == TAGSYM)
457 { 435 {
458 cursor++; 436 skip_tag(&cursor);
459 if(*cursor == '\0' || *cursor == '\n')
460 break;
461 cursor++;
462 } 437 }
463 else if(*cursor == MULTILINESYM) 438 else if(*cursor == MULTILINESYM)
464 { 439 {
@@ -595,19 +570,12 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
595 /* Skipping over escaped characters */ 570 /* Skipping over escaped characters */
596 if(*cursor == TAGSYM) 571 if(*cursor == TAGSYM)
597 { 572 {
598 cursor++; 573 skip_tag(&cursor);
599 if(*cursor == '\0')
600 break;
601 cursor++;
602 } 574 }
603 else if(*cursor == COMMENTSYM) 575 else if(*cursor == COMMENTSYM)
604 { 576 {
605 skip_comment(&cursor); 577 skip_comment(&cursor);
606 } 578 }
607 else if(*cursor == ARGLISTOPENSYM)
608 {
609 skip_arglist(&cursor);
610 }
611 else if(*cursor == ARGLISTSEPARATESYM) 579 else if(*cursor == ARGLISTSEPARATESYM)
612 { 580 {
613 num_args++; 581 num_args++;
@@ -974,18 +942,9 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
974 { 942 {
975 skip_comment(&cursor); 943 skip_comment(&cursor);
976 } 944 }
977 else if(*cursor == ENUMLISTOPENSYM)
978 {
979 if (*cursor == '\n')
980 cursor++;
981 skip_enumlist(&cursor);
982 }
983 else if(*cursor == TAGSYM) 945 else if(*cursor == TAGSYM)
984 { 946 {
985 cursor++; 947 skip_tag(&cursor);
986 if(*cursor == '\0' || *cursor == '\n')
987 break;
988 cursor++;
989 } 948 }
990 else if(*cursor == ENUMLISTSEPARATESYM) 949 else if(*cursor == ENUMLISTSEPARATESYM)
991 { 950 {
@@ -1139,21 +1098,7 @@ static struct skin_element* skin_parse_code_as_arg(const char** document)
1139 } 1098 }
1140 else if(*cursor == TAGSYM) 1099 else if(*cursor == TAGSYM)
1141 { 1100 {
1142 /* A ';' directly after a '%' doesn't count */ 1101 skip_tag(&cursor);
1143 cursor ++;
1144
1145 if(*cursor == '\0')
1146 break;
1147
1148 cursor++;
1149 }
1150 else if(*cursor == ARGLISTOPENSYM)
1151 {
1152 skip_arglist(&cursor);
1153 }
1154 else if(*cursor == ENUMLISTOPENSYM)
1155 {
1156 skip_enumlist(&cursor);
1157 } 1102 }
1158 else 1103 else
1159 { 1104 {