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
This commit is contained in:
Jonathan Gordon 2010-08-03 12:14:50 +00:00
parent d42fd744e6
commit 1e0a01063d
4 changed files with 16 additions and 6 deletions

View file

@ -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();

View file

@ -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;

View file

@ -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);

View file

@ -300,6 +300,8 @@ int main(int argc, char **argv)
}
printf("WPS parsed OK\n\n");
if (wps_verbose_level>2)
skin_debug_tree(wps.tree);
filearg++;
}
return 0;