From 15488a00eae8d10249015b88e4b7bdc47365b854 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Thu, 15 Jul 2010 06:24:11 +0000 Subject: Theme Editor: Committed FS#11477 to add a DECIMAL parameter type in the parser and adapt the Theme Editor to accomodate the change by Johnathan Gordon. Fixed bug in the parser caused by the patch (error was thrown on zero value) and adapted tag rendering for new format git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27426 a1c6a512-1295-4272-9138-f99709370657 --- lib/skin_parser/skin_parser.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'lib/skin_parser/skin_parser.c') diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 2ce41c6d9a..5bc5984fb7 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "skin_buffer.h" #include "skin_parser.h" @@ -534,7 +535,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) /* Storing the type code */ element->params[i].type_code = *tag_args; - /* Checking a nullable argument for null */ + /* Checking a nullable argument for null. */ if(*cursor == DEFAULTSYM && !isdigit(cursor[1])) { if(islower(*tag_args)) @@ -557,8 +558,36 @@ static int skin_parse_tag(struct skin_element* element, char** document) return 0; } - element->params[i].type = NUMERIC; - element->params[i].data.numeric = scan_int(&cursor); + element->params[i].type = INTEGER; + element->params[i].data.number = scan_int(&cursor); + } + else if(tolower(*tag_args) == 'd') + { + int val = 0; + bool have_point = false; + bool have_tenth = false; + while ( isdigit(*cursor) || *cursor == '.' ) + { + if (*cursor != '.') + { + val *= 10; + val += *cursor - '0'; + if (have_point) + { + have_tenth = true; + cursor++; + break; + } + } + else + have_point = true; + cursor++; + } + if (have_tenth == false) + val *= 10; + + element->params[i].type = DECIMAL; + element->params[i].data.number = val; } else if(tolower(*tag_args) == 'n' || tolower(*tag_args) == 's' || tolower(*tag_args) == 'f') -- cgit v1.2.3