make the parser slightly more usable for rockbox, move the buffer allocation into the lib (maybe not the best spot?)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26880 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-06-17 07:56:51 +00:00
parent 1dc2c5ebcb
commit b2ea95e8d2
2 changed files with 6 additions and 21 deletions

View file

@ -9,7 +9,7 @@
BUILDDIR ?= . BUILDDIR ?= .
SRC = skin_parser.c skin_debug.c skin_scan.c tag_table.c SRC = skin_buffer.c skin_parser.c skin_debug.c skin_scan.c tag_table.c
OBJ := $(patsubst %.c,$(BUILDDIR)/%.o,$(SRC)) OBJ := $(patsubst %.c,$(BUILDDIR)/%.o,$(SRC))
OUT = $(BUILDDIR)/libskin_parser.a OUT = $(BUILDDIR)/libskin_parser.a
CC = gcc CC = gcc

View file

@ -24,19 +24,13 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "skin_buffer.h"
#include "skin_parser.h" #include "skin_parser.h"
#include "skin_debug.h" #include "skin_debug.h"
#include "tag_table.h" #include "tag_table.h"
#include "symbols.h" #include "symbols.h"
#include "skin_scan.h" #include "skin_scan.h"
#ifdef ROCKBOX
/* Declaration of parse tree buffer */
#define SKIN_MAX_MEMORY (30*1024)
static char skin_parse_tree[SKIN_MAX_MEMORY];
static char *skin_buffer;
#endif
/* Global variables for the parser */ /* Global variables for the parser */
int skin_line = 0; int skin_line = 0;
@ -66,11 +60,7 @@ struct skin_element* skin_parse(const char* document)
struct skin_element** to_write = 0; struct skin_element** to_write = 0;
char* cursor = (char*)document; /*Keeps track of location in the document*/ char* cursor = (char*)document; /*Keeps track of location in the document*/
#ifdef ROCKBOX
/* FIXME */
skin_buffer = &skin_parse_tree[0];
#endif
skin_line = 1; skin_line = 1;
skin_clear_errors(); skin_clear_errors();
@ -765,8 +755,9 @@ static int skin_parse_conditional(struct skin_element* element, char** document)
static int skin_parse_comment(struct skin_element* element, char** document) static int skin_parse_comment(struct skin_element* element, char** document)
{ {
char* cursor = *document; char* cursor = *document;
#ifndef ROCKBOX
char* text = NULL; char* text = NULL;
#endif
int length; int length;
/* /*
* Finding the index of the ending newline or null-terminator * Finding the index of the ending newline or null-terminator
@ -847,13 +838,7 @@ static struct skin_element* skin_parse_code_as_arg(char** document)
/* Memory management */ /* Memory management */
char* skin_alloc(size_t size) char* skin_alloc(size_t size)
{ {
#ifdef ROCKBOX return skin_buffer_alloc(size);
char *retval = skin_buffer;
skin_buffer = (void *)(((unsigned long)skin_buffer + 3) & ~3);
return retval;
#else
return malloc(size);
#endif
} }
struct skin_element* skin_alloc_element() struct skin_element* skin_alloc_element()