diff options
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/skin_parser.c | 112 | ||||
-rw-r--r-- | utils/themeeditor/skin_scan.c | 59 | ||||
-rw-r--r-- | utils/themeeditor/skin_scan.h | 2 |
3 files changed, 111 insertions, 62 deletions
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c index 58acafb56a..8cf23bd11a 100644 --- a/utils/themeeditor/skin_parser.c +++ b/utils/themeeditor/skin_parser.c | |||
@@ -157,6 +157,14 @@ struct skin_element* skin_parse_viewport(char** document) | |||
157 | { | 157 | { |
158 | skip_comment(&cursor); | 158 | skip_comment(&cursor); |
159 | } | 159 | } |
160 | else if(*cursor == ARGLISTOPENSYM) | ||
161 | { | ||
162 | skip_arglist(&cursor); | ||
163 | } | ||
164 | else if(*cursor == ENUMLISTOPENSYM) | ||
165 | { | ||
166 | skip_arglist(&cursor); | ||
167 | } | ||
160 | else | 168 | else |
161 | { | 169 | { |
162 | /* Advancing the cursor as normal */ | 170 | /* Advancing the cursor as normal */ |
@@ -297,7 +305,6 @@ struct skin_element* skin_parse_sublines_optional(char** document, | |||
297 | char* cursor = *document; | 305 | char* cursor = *document; |
298 | int sublines = 1; | 306 | int sublines = 1; |
299 | int i; | 307 | int i; |
300 | int nested = 0; | ||
301 | 308 | ||
302 | retval = skin_alloc_element(); | 309 | retval = skin_alloc_element(); |
303 | retval->type = SUBLINES; | 310 | retval->type = SUBLINES; |
@@ -316,36 +323,31 @@ struct skin_element* skin_parse_sublines_optional(char** document, | |||
316 | if(*cursor == COMMENTSYM) | 323 | if(*cursor == COMMENTSYM) |
317 | { | 324 | { |
318 | skip_comment(&cursor); | 325 | skip_comment(&cursor); |
319 | continue; | ||
320 | } | 326 | } |
321 | 327 | else if(*cursor == ENUMLISTOPENSYM) | |
322 | if(*cursor == ENUMLISTOPENSYM && conditional) | ||
323 | { | 328 | { |
324 | nested++; | 329 | skip_enumlist(&cursor); |
325 | cursor++; | ||
326 | while(nested) | ||
327 | { | ||
328 | if(*cursor == ENUMLISTOPENSYM) | ||
329 | nested++; | ||
330 | if(*cursor == ENUMLISTCLOSESYM) | ||
331 | nested--; | ||
332 | cursor++; | ||
333 | } | ||
334 | } | 330 | } |
335 | /* Accounting for escaped subline symbols */ | 331 | else if(*cursor == ARGLISTOPENSYM) |
336 | if(*cursor == TAGSYM) | 332 | { |
333 | skip_arglist(&cursor); | ||
334 | } | ||
335 | else if(*cursor == TAGSYM) | ||
337 | { | 336 | { |
338 | cursor++; | 337 | cursor++; |
339 | if(*cursor == '\0' || *cursor == '\n') | 338 | if(*cursor == '\0' || *cursor == '\n') |
340 | break; | 339 | break; |
340 | cursor++; | ||
341 | } | 341 | } |
342 | 342 | else if(*cursor == MULTILINESYM) | |
343 | if(*cursor == MULTILINESYM) | ||
344 | { | 343 | { |
345 | sublines++; | 344 | sublines++; |
345 | cursor++; | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | cursor++; | ||
346 | } | 350 | } |
347 | |||
348 | cursor++; | ||
349 | } | 351 | } |
350 | 352 | ||
351 | /* ...and then we parse them */ | 353 | /* ...and then we parse them */ |
@@ -449,8 +451,8 @@ int skin_parse_tag(struct skin_element* element, char** document) | |||
449 | cursor++; | 451 | cursor++; |
450 | } | 452 | } |
451 | 453 | ||
452 | for(bookmark = cursor; *cursor != '\n' && *cursor != '\0' && | 454 | bookmark = cursor; |
453 | *cursor != ARGLISTCLOSESYM; cursor++) | 455 | while(*cursor != '\n' && *cursor != '\0' && *cursor != ARGLISTCLOSESYM) |
454 | { | 456 | { |
455 | /* Skipping over escaped characters */ | 457 | /* Skipping over escaped characters */ |
456 | if(*cursor == TAGSYM) | 458 | if(*cursor == TAGSYM) |
@@ -458,21 +460,27 @@ int skin_parse_tag(struct skin_element* element, char** document) | |||
458 | cursor++; | 460 | cursor++; |
459 | if(*cursor == '\0') | 461 | if(*cursor == '\0') |
460 | break; | 462 | break; |
463 | cursor++; | ||
461 | } | 464 | } |
462 | 465 | else if(*cursor == COMMENTSYM) | |
463 | /* Skipping comments */ | 466 | { |
464 | if(*cursor == COMMENTSYM) | ||
465 | skip_comment(&cursor); | 467 | skip_comment(&cursor); |
466 | 468 | } | |
467 | /* Commas inside of contained lists don't count */ | 469 | else if(*cursor == ARGLISTOPENSYM) |
468 | if(*cursor == ARGLISTOPENSYM) | 470 | { |
469 | while(*cursor != ARGLISTCLOSESYM && *cursor != '\0') | 471 | skip_arglist(&cursor); |
470 | cursor++; | 472 | } |
471 | 473 | else if(*cursor == ARGLISTSEPERATESYM) | |
472 | if(*cursor == ARGLISTSEPERATESYM) | 474 | { |
473 | num_args++; | 475 | num_args++; |
474 | 476 | cursor++; | |
477 | } | ||
478 | else | ||
479 | { | ||
480 | cursor++; | ||
481 | } | ||
475 | } | 482 | } |
483 | |||
476 | cursor = bookmark; /* Restoring the cursor */ | 484 | cursor = bookmark; /* Restoring the cursor */ |
477 | element->params_count = num_args; | 485 | element->params_count = num_args; |
478 | element->params = skin_alloc_params(num_args); | 486 | element->params = skin_alloc_params(num_args); |
@@ -656,7 +664,6 @@ int skin_parse_conditional(struct skin_element* element, char** document) | |||
656 | struct skin_element* tag = skin_alloc_element(); /* The tag to evaluate */ | 664 | struct skin_element* tag = skin_alloc_element(); /* The tag to evaluate */ |
657 | int children = 1; | 665 | int children = 1; |
658 | int i; | 666 | int i; |
659 | int nested = 0; | ||
660 | 667 | ||
661 | element->type = CONDITIONAL; | 668 | element->type = CONDITIONAL; |
662 | element->line = skin_line; | 669 | element->line = skin_line; |
@@ -677,42 +684,27 @@ int skin_parse_conditional(struct skin_element* element, char** document) | |||
677 | if(*cursor == COMMENTSYM) | 684 | if(*cursor == COMMENTSYM) |
678 | { | 685 | { |
679 | skip_comment(&cursor); | 686 | skip_comment(&cursor); |
680 | continue; | ||
681 | } | 687 | } |
682 | 688 | else if(*cursor == ENUMLISTOPENSYM) | |
683 | if(*cursor == ENUMLISTOPENSYM) | ||
684 | { | 689 | { |
685 | nested++; | 690 | skip_enumlist(&cursor); |
686 | cursor++; | ||
687 | while(nested) | ||
688 | { | ||
689 | if(*cursor == ENUMLISTOPENSYM) | ||
690 | { | ||
691 | nested++; | ||
692 | } | ||
693 | else if(*cursor == ENUMLISTCLOSESYM) | ||
694 | { | ||
695 | nested--; | ||
696 | if(nested == 0) | ||
697 | break; | ||
698 | } | ||
699 | cursor++; | ||
700 | } | ||
701 | } | 691 | } |
702 | 692 | else if(*cursor == TAGSYM) | |
703 | if(*cursor == TAGSYM) | ||
704 | { | 693 | { |
705 | cursor++; | 694 | cursor++; |
706 | if(*cursor == '\0' || *cursor == '\n') | 695 | if(*cursor == '\0' || *cursor == '\n') |
707 | break; | 696 | break; |
708 | cursor++; | 697 | cursor++; |
709 | continue; | ||
710 | } | 698 | } |
711 | 699 | else if(*cursor == ENUMLISTSEPERATESYM) | |
712 | if(*cursor == ENUMLISTSEPERATESYM) | 700 | { |
713 | children++; | 701 | children++; |
714 | 702 | cursor++; | |
715 | cursor++; | 703 | } |
704 | else | ||
705 | { | ||
706 | cursor++; | ||
707 | } | ||
716 | } | 708 | } |
717 | cursor = bookmark; | 709 | cursor = bookmark; |
718 | 710 | ||
diff --git a/utils/themeeditor/skin_scan.c b/utils/themeeditor/skin_scan.c index 19e959b5b8..79f7162aab 100644 --- a/utils/themeeditor/skin_scan.c +++ b/utils/themeeditor/skin_scan.c | |||
@@ -34,14 +34,69 @@ | |||
34 | /* Simple function to advance a char* past a comment */ | 34 | /* Simple function to advance a char* past a comment */ |
35 | void skip_comment(char** document) | 35 | void skip_comment(char** document) |
36 | { | 36 | { |
37 | for(/*NO INIT*/;**document != '\n' && **document != '\0'; (*document)++); | 37 | while(**document != '\n' && **document != '\0') |
38 | (*document)++; | ||
38 | if(**document == '\n') | 39 | if(**document == '\n') |
39 | (*document)++; | 40 | (*document)++; |
40 | } | 41 | } |
41 | 42 | ||
42 | void skip_whitespace(char** document) | 43 | void skip_whitespace(char** document) |
43 | { | 44 | { |
44 | for(/*NO INIT*/; **document == ' ' || **document == '\t'; (*document)++); | 45 | while(**document == ' ' || **document == '\t') |
46 | (*document)++; | ||
47 | } | ||
48 | |||
49 | void skip_arglist(char** document) | ||
50 | { | ||
51 | if(**document == ARGLISTOPENSYM) | ||
52 | (*document)++; | ||
53 | while(**document && **document != ARGLISTCLOSESYM) | ||
54 | { | ||
55 | if(**document == TAGSYM) | ||
56 | { | ||
57 | (*document)++; | ||
58 | if(**document == '\0') | ||
59 | break; | ||
60 | (*document)++; | ||
61 | } | ||
62 | else if(**document == ARGLISTOPENSYM) | ||
63 | skip_arglist(document); | ||
64 | else if(**document == ENUMLISTOPENSYM) | ||
65 | skip_enumlist(document); | ||
66 | else if(**document == COMMENTSYM) | ||
67 | skip_comment(document); | ||
68 | else | ||
69 | (*document)++; | ||
70 | } | ||
71 | if(**document == ARGLISTCLOSESYM) | ||
72 | (*document)++; | ||
73 | } | ||
74 | |||
75 | void skip_enumlist(char** document) | ||
76 | { | ||
77 | if(**document == ENUMLISTOPENSYM) | ||
78 | (*document)++; | ||
79 | while(**document && **document != ENUMLISTCLOSESYM) | ||
80 | { | ||
81 | if(**document == TAGSYM) | ||
82 | { | ||
83 | (*document)++; | ||
84 | if(**document == '\0') | ||
85 | break; | ||
86 | (*document)++; | ||
87 | } | ||
88 | else if(**document == ARGLISTOPENSYM) | ||
89 | skip_arglist(document); | ||
90 | else if(**document == ENUMLISTOPENSYM) | ||
91 | skip_enumlist(document); | ||
92 | else if(**document == COMMENTSYM) | ||
93 | skip_comment(document); | ||
94 | else | ||
95 | (*document)++; | ||
96 | } | ||
97 | |||
98 | if(**document == ENUMLISTCLOSESYM) | ||
99 | (*document)++; | ||
45 | } | 100 | } |
46 | 101 | ||
47 | char* scan_string(char** document) | 102 | char* scan_string(char** document) |
diff --git a/utils/themeeditor/skin_scan.h b/utils/themeeditor/skin_scan.h index 6aea92c8a9..b1d04a6e34 100644 --- a/utils/themeeditor/skin_scan.h +++ b/utils/themeeditor/skin_scan.h | |||
@@ -31,6 +31,8 @@ extern "C" | |||
31 | /* Scanning functions */ | 31 | /* Scanning functions */ |
32 | void skip_comment(char** document); | 32 | void skip_comment(char** document); |
33 | void skip_whitespace(char** document); | 33 | void skip_whitespace(char** document); |
34 | void skip_arglist(char** document); | ||
35 | void skip_enumlist(char** document); | ||
34 | char* scan_string(char** document); | 36 | char* scan_string(char** document); |
35 | int scan_int(char** document); | 37 | int scan_int(char** document); |
36 | int check_viewport(char* document); /* Checks for a viewport declaration */ | 38 | int check_viewport(char* document); /* Checks for a viewport declaration */ |