diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-08-03 12:14:50 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-08-03 12:14:50 +0000 |
commit | 1e0a01063d1088d83639f9e0dbf113efe67e5e73 (patch) | |
tree | 4d375fd2b49f75854c33588361e46a13d8985357 /lib/skin_parser | |
parent | d42fd744e68a84c5a11803e36f2274a06c6927b6 (diff) | |
download | rockbox-1e0a01063d1088d83639f9e0dbf113efe67e5e73.tar.gz rockbox-1e0a01063d1088d83639f9e0dbf113efe67e5e73.zip |
make -vvv display the parse tree in checkwps. Fix a potential bug in the parser where recursive tags (the playlist viewier) would share params with its parant which meant bad things
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27677 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib/skin_parser')
-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 |
3 files changed, 14 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() error_message = NULL; } -#ifndef ROCKBOX +#if !defined(ROCKBOX) || defined(__PCTOOL__) void skin_debug_tree(struct skin_element* root) { int i; @@ -227,7 +227,8 @@ void skin_debug_tree(struct skin_element* root) printf("[ Logical line on line %d\n", current->line); debug_indent_level++; - skin_debug_tree(current->children[0]); + if (current->children) + skin_debug_tree(current->children[0]); debug_indent_level--; 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; char* skin_start = 0; int viewport_line = 0; +static int tag_recursion_level = 0; + #ifdef ROCKBOX static skin_callback callback = NULL; static void* callback_data; @@ -121,6 +123,8 @@ static struct skin_element* skin_parse_viewport(const char** document) struct skin_element* root = NULL; struct skin_element* last = NULL; struct skin_element* retval = NULL; + + tag_recursion_level = 0; retval = skin_alloc_element(); if (!retval) @@ -467,6 +471,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) int req_args; /* To mark when we enter optional arguments */ int optional = 0; + tag_recursion_level++; /* Checking the tag name */ tag_name[0] = cursor[0]; @@ -567,7 +572,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) cursor = bookmark; /* Restoring the cursor */ element->params_count = num_args; - element->params = skin_alloc_params(num_args); + element->params = skin_alloc_params(num_args, tag_recursion_level<=1); if (!element->params) return 0; @@ -712,6 +717,7 @@ static int skin_parse_tag(struct skin_element* element, const char** document) } #endif *document = cursor; + tag_recursion_level--; return 1; } @@ -1014,11 +1020,11 @@ struct skin_element* skin_alloc_element() * enough for any tag. params should be used straight away by the callback * so this is safe. */ -struct skin_tag_parameter* skin_alloc_params(int count) +struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params) { #ifdef ROCKBOX static struct skin_tag_parameter params[MAX_TAG_PARAMS]; - if (count <= MAX_TAG_PARAMS) + if (use_shared_params && count <= MAX_TAG_PARAMS) { memset(params, 0, sizeof(params)); 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" { #endif #include <stdlib.h> +#include <stdbool.h> /******************************************************************** ****** Data Structures ********************************************* @@ -139,7 +140,7 @@ struct skin_element* skin_parse(const char* document); /* Memory management functions */ struct skin_element* skin_alloc_element(void); struct skin_element** skin_alloc_children(int count); -struct skin_tag_parameter* skin_alloc_params(int count); +struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params); char* skin_alloc_string(int length); void skin_free_tree(struct skin_element* root); |