summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/skin_parser/skin_debug.c5
-rw-r--r--lib/skin_parser/skin_parser.c12
-rw-r--r--lib/skin_parser/skin_parser.h3
-rw-r--r--tools/checkwps/checkwps.c2
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()
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);
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)
}
printf("WPS parsed OK\n\n");
+ if (wps_verbose_level>2)
+ skin_debug_tree(wps.tree);
filearg++;
}
return 0;