diff options
-rw-r--r-- | lib/skin_parser/skin_debug.c | 5 | ||||
-rw-r--r-- | lib/skin_parser/skin_parser.c | 12 | ||||
-rw-r--r-- | lib/skin_parser/skin_parser.h | 3 | ||||
-rw-r--r-- | tools/checkwps/checkwps.c | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c index 803a673f22..3a5a5a7441 100644 --- a/lib/skin_parser/skin_debug.c +++ b/lib/skin_parser/skin_debug.c | |||
@@ -120,7 +120,7 @@ void skin_clear_errors() | |||
120 | error_message = NULL; | 120 | error_message = NULL; |
121 | } | 121 | } |
122 | 122 | ||
123 | #ifndef ROCKBOX | 123 | #if !defined(ROCKBOX) || defined(__PCTOOL__) |
124 | void skin_debug_tree(struct skin_element* root) | 124 | void skin_debug_tree(struct skin_element* root) |
125 | { | 125 | { |
126 | int i; | 126 | int i; |
@@ -227,7 +227,8 @@ void skin_debug_tree(struct skin_element* root) | |||
227 | printf("[ Logical line on line %d\n", current->line); | 227 | printf("[ Logical line on line %d\n", current->line); |
228 | 228 | ||
229 | debug_indent_level++; | 229 | debug_indent_level++; |
230 | skin_debug_tree(current->children[0]); | 230 | if (current->children) |
231 | skin_debug_tree(current->children[0]); | ||
231 | debug_indent_level--; | 232 | debug_indent_level--; |
232 | 233 | ||
233 | skin_debug_indent(); | 234 | skin_debug_indent(); |
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 3554629608..f92a52774d 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c | |||
@@ -38,6 +38,8 @@ int skin_line = 0; | |||
38 | char* skin_start = 0; | 38 | char* skin_start = 0; |
39 | int viewport_line = 0; | 39 | int viewport_line = 0; |
40 | 40 | ||
41 | static int tag_recursion_level = 0; | ||
42 | |||
41 | #ifdef ROCKBOX | 43 | #ifdef ROCKBOX |
42 | static skin_callback callback = NULL; | 44 | static skin_callback callback = NULL; |
43 | static void* callback_data; | 45 | static void* callback_data; |
@@ -121,6 +123,8 @@ static struct skin_element* skin_parse_viewport(const char** document) | |||
121 | struct skin_element* root = NULL; | 123 | struct skin_element* root = NULL; |
122 | struct skin_element* last = NULL; | 124 | struct skin_element* last = NULL; |
123 | struct skin_element* retval = NULL; | 125 | struct skin_element* retval = NULL; |
126 | |||
127 | tag_recursion_level = 0; | ||
124 | 128 | ||
125 | retval = skin_alloc_element(); | 129 | retval = skin_alloc_element(); |
126 | if (!retval) | 130 | if (!retval) |
@@ -467,6 +471,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
467 | int req_args; /* To mark when we enter optional arguments */ | 471 | int req_args; /* To mark when we enter optional arguments */ |
468 | 472 | ||
469 | int optional = 0; | 473 | int optional = 0; |
474 | tag_recursion_level++; | ||
470 | 475 | ||
471 | /* Checking the tag name */ | 476 | /* Checking the tag name */ |
472 | tag_name[0] = cursor[0]; | 477 | tag_name[0] = cursor[0]; |
@@ -567,7 +572,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
567 | 572 | ||
568 | cursor = bookmark; /* Restoring the cursor */ | 573 | cursor = bookmark; /* Restoring the cursor */ |
569 | element->params_count = num_args; | 574 | element->params_count = num_args; |
570 | element->params = skin_alloc_params(num_args); | 575 | element->params = skin_alloc_params(num_args, tag_recursion_level<=1); |
571 | if (!element->params) | 576 | if (!element->params) |
572 | return 0; | 577 | return 0; |
573 | 578 | ||
@@ -712,6 +717,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
712 | } | 717 | } |
713 | #endif | 718 | #endif |
714 | *document = cursor; | 719 | *document = cursor; |
720 | tag_recursion_level--; | ||
715 | 721 | ||
716 | return 1; | 722 | return 1; |
717 | } | 723 | } |
@@ -1014,11 +1020,11 @@ struct skin_element* skin_alloc_element() | |||
1014 | * enough for any tag. params should be used straight away by the callback | 1020 | * enough for any tag. params should be used straight away by the callback |
1015 | * so this is safe. | 1021 | * so this is safe. |
1016 | */ | 1022 | */ |
1017 | struct skin_tag_parameter* skin_alloc_params(int count) | 1023 | struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params) |
1018 | { | 1024 | { |
1019 | #ifdef ROCKBOX | 1025 | #ifdef ROCKBOX |
1020 | static struct skin_tag_parameter params[MAX_TAG_PARAMS]; | 1026 | static struct skin_tag_parameter params[MAX_TAG_PARAMS]; |
1021 | if (count <= MAX_TAG_PARAMS) | 1027 | if (use_shared_params && count <= MAX_TAG_PARAMS) |
1022 | { | 1028 | { |
1023 | memset(params, 0, sizeof(params)); | 1029 | memset(params, 0, sizeof(params)); |
1024 | return params; | 1030 | return params; |
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h index 6ccf31a0e5..7cef0107a3 100644 --- a/lib/skin_parser/skin_parser.h +++ b/lib/skin_parser/skin_parser.h | |||
@@ -27,6 +27,7 @@ extern "C" | |||
27 | { | 27 | { |
28 | #endif | 28 | #endif |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <stdbool.h> | ||
30 | 31 | ||
31 | /******************************************************************** | 32 | /******************************************************************** |
32 | ****** Data Structures ********************************************* | 33 | ****** Data Structures ********************************************* |
@@ -139,7 +140,7 @@ struct skin_element* skin_parse(const char* document); | |||
139 | /* Memory management functions */ | 140 | /* Memory management functions */ |
140 | struct skin_element* skin_alloc_element(void); | 141 | struct skin_element* skin_alloc_element(void); |
141 | struct skin_element** skin_alloc_children(int count); | 142 | struct skin_element** skin_alloc_children(int count); |
142 | struct skin_tag_parameter* skin_alloc_params(int count); | 143 | struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params); |
143 | char* skin_alloc_string(int length); | 144 | char* skin_alloc_string(int length); |
144 | 145 | ||
145 | void skin_free_tree(struct skin_element* root); | 146 | void skin_free_tree(struct skin_element* root); |
diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c index e00fb724bc..7b1aa24764 100644 --- a/tools/checkwps/checkwps.c +++ b/tools/checkwps/checkwps.c | |||
@@ -300,6 +300,8 @@ int main(int argc, char **argv) | |||
300 | } | 300 | } |
301 | 301 | ||
302 | printf("WPS parsed OK\n\n"); | 302 | printf("WPS parsed OK\n\n"); |
303 | if (wps_verbose_level>2) | ||
304 | skin_debug_tree(wps.tree); | ||
303 | filearg++; | 305 | filearg++; |
304 | } | 306 | } |
305 | return 0; | 307 | return 0; |