summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-05-25 17:22:39 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-05-25 17:22:39 +0000
commit1937b1b1ae0527f2c80834c0461532f1a3cceeaa (patch)
tree7426ffcef783bfff60e73211cd42849c52ef9470 /utils
parent58b4fe10076e053664a598dc252ef107d1da6fa2 (diff)
downloadrockbox-1937b1b1ae0527f2c80834c0461532f1a3cceeaa.tar.gz
rockbox-1937b1b1ae0527f2c80834c0461532f1a3cceeaa.tar.bz2
rockbox-1937b1b1ae0527f2c80834c0461532f1a3cceeaa.zip
Fixed some bugs in the theme editor, added the tags with parameters to the tag table
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26288 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/main.c3
-rw-r--r--utils/themeeditor/skin_parser.c188
-rw-r--r--utils/themeeditor/skin_scan.c1
-rw-r--r--utils/themeeditor/symbols.h2
-rw-r--r--utils/themeeditor/tag_table.c28
-rw-r--r--utils/themeeditor/tag_table.h3
6 files changed, 119 insertions, 106 deletions
diff --git a/utils/themeeditor/main.c b/utils/themeeditor/main.c
index 9f45c90317..269cad7840 100644
--- a/utils/themeeditor/main.c
+++ b/utils/themeeditor/main.c
@@ -6,8 +6,7 @@
int main(int argc, char* argv[])
{
- char* doc = "This is a sample %V(1, 2, 3, 4, 5, six, seven)\n"
- "WPS document, with ; sublines and a %?T(conditional| or| two)";
+ char* doc = "%Vd(U))\n\n%?bl(test,3,5,2,1)<param2|param3>";
struct skin_element* test = skin_parse(doc);
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c
index 89952a615b..bc1f2a5ed2 100644
--- a/utils/themeeditor/skin_parser.c
+++ b/utils/themeeditor/skin_parser.c
@@ -153,8 +153,11 @@ struct skin_element* skin_parse_line_optional(char** document, int conditional)
struct skin_element* current = NULL;
while(*cursor != '\n' && *cursor != '\0' && *cursor != MULTILINESYM
- && !((*cursor == ARGLISTSEPERATESYM || *cursor == ARGLISTCLOSESYM
- || *cursor == ENUMLISTSEPERATESYM) && conditional))
+ && !((*cursor == ARGLISTSEPERATESYM
+ || *cursor == ARGLISTCLOSESYM
+ || *cursor == ENUMLISTSEPERATESYM
+ || *cursor == ENUMLISTCLOSESYM)
+ && conditional))
{
/* Allocating memory if necessary */
if(root)
@@ -233,8 +236,11 @@ struct skin_element* skin_parse_sublines_optional(char** document,
/* First we count the sublines */
while(*cursor != '\0' && *cursor != '\n'
- && !((*cursor == ARGLISTSEPERATESYM || *cursor == ARGLISTCLOSESYM
- || *cursor == ENUMLISTSEPERATESYM) && conditional))
+ && !((*cursor == ARGLISTSEPERATESYM
+ || *cursor == ARGLISTCLOSESYM
+ || *cursor == ENUMLISTSEPERATESYM
+ || *cursor == ENUMLISTCLOSESYM)
+ && conditional))
{
if(*cursor == COMMENTSYM)
skip_comment(&cursor);
@@ -292,7 +298,8 @@ int skin_parse_tag(struct skin_element* element, char** document)
int num_args = 1;
int i;
- int count;
+ int star = 0; /* Flag for the all-or-none option */
+ int req_args; /* To mark when we enter optional arguments */
int optional = 0;
@@ -327,8 +334,16 @@ int skin_parse_tag(struct skin_element* element, char** document)
strcpy(element->name, tag_name);
element->line = skin_line;
+ /* Checking for the * flag */
+ if(tag_args[0] == '*')
+ {
+ star = 1;
+ tag_args++;
+ }
+
/* If this tag has no arguments, we can bail out now */
- if(strlen(tag_args) == 0)
+ if(strlen(tag_args) == 0
+ || (tag_args[0] == '|' && *cursor != ARGLISTOPENSYM))
{
*document = cursor;
return 1;
@@ -374,8 +389,7 @@ int skin_parse_tag(struct skin_element* element, char** document)
element->params = skin_alloc_params(num_args);
/* Now we have to actually parse each argument */
- i = 0;
- while(i < num_args)
+ for(i = 0; i < num_args; i++)
{
/* Making sure we haven't run out of arguments */
if(*tag_args == '\0')
@@ -388,113 +402,88 @@ int skin_parse_tag(struct skin_element* element, char** document)
if(*tag_args == '|')
{
optional = 1;
+ req_args = i - 1;
tag_args++;
}
- /* Checking for a repeated argument */
- if(isdigit(*tag_args))
- {
- count = scan_int(&tag_args);
- }
- else
- {
- count = 1;
- }
-
/* Scanning the arguments */
- while(count > 0)
- {
-
- skip_whitespace(&cursor);
+ skip_whitespace(&cursor);
- /* Checking for a premature end */
- if(num_args - i < count)
- {
- if(optional && (num_args - i == 0))
- {
- break;
- }
- else
- {
- /*
- We error out if there are too few arguments, or if there
- is an optional argument that was supposed to be grouped
- with another
- */
- skin_error(INSUFFICIENT_ARGS);
- return 0;
- }
- }
- /* Checking for comments */
- if(*cursor == COMMENTSYM)
- skip_comment(&cursor);
+ /* Checking for comments */
+ if(*cursor == COMMENTSYM)
+ skip_comment(&cursor);
- /* Checking a nullable argument for null */
- if(*cursor == DEFAULTSYM)
- {
- if(islower(*tag_args))
- {
- element->params[i].type = DEFAULT;
- cursor++;
- }
- else
- {
- skin_error(DEFAULT_NOT_ALLOWED);
- return 0;
- }
- }
- else if(tolower(*tag_args) == 'i')
+ /* Checking a nullable argument for null */
+ if(*cursor == DEFAULTSYM)
+ {
+ if(islower(*tag_args))
{
- /* Scanning an int argument */
- if(!isdigit(*cursor))
- {
- skin_error(INT_EXPECTED);
- return 0;
- }
-
- element->params[i].type = NUMERIC;
- element->params[i].data.numeric = scan_int(&cursor);
+ element->params[i].type = DEFAULT;
+ cursor++;
}
- else if(tolower(*tag_args) == 's' || tolower(*tag_args) == 'f')
+ else
{
- /* Scanning a string argument */
- element->params[i].type = STRING;
- element->params[i].data.text = scan_string(&cursor);
-
+ skin_error(DEFAULT_NOT_ALLOWED);
+ return 0;
}
- else if(tolower(*tag_args) == 'c')
+ }
+ else if(tolower(*tag_args) == 'i')
+ {
+ /* Scanning an int argument */
+ if(!isdigit(*cursor))
{
- element->params[i].type = CODE;
- element->params[i].data.code = skin_parse_code_as_arg(&cursor);
- if(!element->params[i].data.code)
- return 0;
+ skin_error(INT_EXPECTED);
+ return 0;
}
- i++;
- count--;
- skip_whitespace(&cursor);
+ element->params[i].type = NUMERIC;
+ element->params[i].data.numeric = scan_int(&cursor);
+ }
+ else if(tolower(*tag_args) == 's' || tolower(*tag_args) == 'f')
+ {
+ /* Scanning a string argument */
+ element->params[i].type = STRING;
+ element->params[i].data.text = scan_string(&cursor);
- if(*cursor != ARGLISTSEPERATESYM && i < num_args)
- {
- skin_error(SEPERATOR_EXPECTED);
- return 0;
- }
- else if(*cursor != ARGLISTCLOSESYM && i == num_args)
- {
- skin_error(CLOSE_EXPECTED);
+ }
+ else if(tolower(*tag_args) == 'c')
+ {
+ /* Recursively parsing a code argument */
+ element->params[i].type = CODE;
+ element->params[i].data.code = skin_parse_code_as_arg(&cursor);
+ if(!element->params[i].data.code)
return 0;
- }
- else
- {
- cursor++;
- }
+ }
+
+ skip_whitespace(&cursor);
+
+ if(*cursor != ARGLISTSEPERATESYM && i < num_args - 1)
+ {
+ skin_error(SEPERATOR_EXPECTED);
+ return 0;
+ }
+ else if(*cursor != ARGLISTCLOSESYM && i == num_args - 1)
+ {
+ skin_error(CLOSE_EXPECTED);
+ return 0;
+ }
+ else
+ {
+ cursor++;
}
tag_args++;
}
+ /* Checking for a premature end */
+ if(*tag_args != '\0' && !(optional && (!star || num_args == req_args)))
+ {
+ skin_error(INSUFFICIENT_ARGS);
+ return 0;
+ }
+
*document = cursor;
return 1;
@@ -516,8 +505,11 @@ int skin_parse_text(struct skin_element* element, char** document,
/* First figure out how much text we're copying */
while(*cursor != '\0' && *cursor != '\n' && *cursor != MULTILINESYM
&& *cursor != COMMENTSYM
- && !((*cursor == ARGLISTSEPERATESYM || *cursor == ARGLISTCLOSESYM
- || *cursor == ENUMLISTSEPERATESYM) && conditional))
+ && !((*cursor == ARGLISTSEPERATESYM
+ || *cursor == ARGLISTCLOSESYM
+ || *cursor == ENUMLISTSEPERATESYM
+ || *cursor == ENUMLISTCLOSESYM)
+ && conditional))
{
/* Dealing with possibility of escaped characters */
if(*cursor == TAGSYM)
@@ -573,13 +565,13 @@ int skin_parse_conditional(struct skin_element* element, char** document)
return 0;
/* Counting the children */
- if(*(cursor++) != ARGLISTOPENSYM)
+ if(*(cursor++) != ENUMLISTOPENSYM)
{
skin_error(ARGLIST_EXPECTED);
return 0;
}
bookmark = cursor;
- while(*cursor != ARGLISTCLOSESYM && *cursor != '\n' && *cursor != '\0')
+ while(*cursor != ENUMLISTCLOSESYM && *cursor != '\n' && *cursor != '\0')
{
if(*cursor == COMMENTSYM)
{
@@ -618,7 +610,7 @@ int skin_parse_conditional(struct skin_element* element, char** document)
skin_error(SEPERATOR_EXPECTED);
return 0;
}
- else if(i == children && *cursor != ARGLISTCLOSESYM)
+ else if(i == children && *cursor != ENUMLISTCLOSESYM)
{
skin_error(CLOSE_EXPECTED);
return 0;
diff --git a/utils/themeeditor/skin_scan.c b/utils/themeeditor/skin_scan.c
index 92ee521176..dfe5d008e5 100644
--- a/utils/themeeditor/skin_scan.c
+++ b/utils/themeeditor/skin_scan.c
@@ -73,6 +73,7 @@ char* scan_string(char** document)
/* Copying the string */
cursor = *document;
buffer = skin_alloc_string(length);
+ buffer[length] = '\0';
for(i = 0; i < length; i++)
{
if(*cursor == COMMENTSYM)
diff --git a/utils/themeeditor/symbols.h b/utils/themeeditor/symbols.h
index a82bb09393..cc82890a16 100644
--- a/utils/themeeditor/symbols.h
+++ b/utils/themeeditor/symbols.h
@@ -32,6 +32,8 @@
#define ARGLISTCLOSESYM ')'
#define ARGLISTSEPERATESYM ','
#define ENUMLISTSEPERATESYM '|'
+#define ENUMLISTOPENSYM '<'
+#define ENUMLISTCLOSESYM '>'
#define DEFAULTSYM '-'
#endif /* SYMBOLS_H */
diff --git a/utils/themeeditor/tag_table.c b/utils/themeeditor/tag_table.c
index ac0537f4a1..4bfae17a97 100644
--- a/utils/themeeditor/tag_table.c
+++ b/utils/themeeditor/tag_table.c
@@ -26,15 +26,33 @@
/* The tag definition table */
struct tag_info legal_tags[] =
{
- { "V" , "IIiii|2sc" },
- { "Vi" , "SIIiii|2s" },
- { "Vd" , "S" },
- { "T" , "" },
+ { "bl" , "*|fIIII" },
+ { "pb" , "*|fIIII" },
+ { "pv" , "*|fIIII" },
+ { "d" , "I" },
+ { "D" , "I" },
+ { "t" , "I" },
+ { "mv" , "|I"},
+ { "pS" , "|I"},
+ { "pE" , "|I"},
+ { "Tl" , "|I"},
+ { "X" , "F"},
+ { "Fl" , "IF"},
+ { "Cl" , "II|II"},
+ { "V" , "*IIiii|ii"},
+ { "Vl" , "*SIIiii|ii"},
+ { "Vi" , "*sIIiii|ii"},
+ { "Vd" , "S"},
+ { "VI" , "S"},
+ { "Vp" , "ICC"},
+ { "St" , "S"},
+ { "Sx" , "S"},
+ { "T" , "IIiiI"},
{ "" , ""} /* Keep this here to mark the end of the table */
};
/* A table of legal escapable characters */
-char legal_escape_characters[] = "%(|);#,";
+char legal_escape_characters[] = "%(,);#<|>";
/*
* Just does a straight search through the tag table to find one by
diff --git a/utils/themeeditor/tag_table.h b/utils/themeeditor/tag_table.h
index 935380ddd9..807d3e15ac 100644
--- a/utils/themeeditor/tag_table.h
+++ b/utils/themeeditor/tag_table.h
@@ -46,7 +46,8 @@
* To specify multiple instances of the same type, put a
* number before the character. For instance, the string...
* 2s
- * will specify two strings.
+ * will specify two strings. An asterisk (*) at the beginning of the
+ * string will specify that either all or none of the optional
*
*/
struct tag_info