summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/skin_parser/skin_debug.c12
-rw-r--r--lib/skin_parser/skin_parser.c35
-rw-r--r--lib/skin_parser/skin_parser.h6
-rw-r--r--lib/skin_parser/tag_table.c10
-rw-r--r--lib/skin_parser/tag_table.h3
5 files changed, 54 insertions, 12 deletions
diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c
index 00d09aea7e..4abe6252f0 100644
--- a/lib/skin_parser/skin_debug.c
+++ b/lib/skin_parser/skin_debug.c
@@ -70,6 +70,9 @@ void skin_error(enum skin_errorcode error)
case INT_EXPECTED:
error_message = "Expected integer";
break;
+ case DECIMAL_EXPECTED:
+ error_message = "Expected decimal";
+ break;
case SEPERATOR_EXPECTED:
error_message = "Expected argument seperator";
break;
@@ -236,8 +239,13 @@ void skin_debug_params(int count, struct skin_tag_parameter params[])
printf("[%s]", params[i].data.text);
break;
- case NUMERIC:
- printf("[%d]", params[i].data.numeric);
+ case INTEGER:
+ printf("[%d]", params[i].data.number);
+ break;
+
+ case DECIMAL:
+ printf("[%d.%d]", params[i].data.number/10,
+ params[i].data.number%10);
break;
case CODE:
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 <stdio.h>
#include <string.h>
#include <ctype.h>
+#include <stdbool.h>
#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')
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h
index 126a014b5a..ad10f90125 100644
--- a/lib/skin_parser/skin_parser.h
+++ b/lib/skin_parser/skin_parser.h
@@ -56,6 +56,7 @@ enum skin_errorcode
UNEXPECTED_NEWLINE,
INSUFFICIENT_ARGS,
INT_EXPECTED,
+ DECIMAL_EXPECTED,
SEPERATOR_EXPECTED,
CLOSE_EXPECTED,
MULTILINE_EXPECTED
@@ -66,7 +67,8 @@ struct skin_tag_parameter
{
enum
{
- NUMERIC,
+ INTEGER,
+ DECIMAL, /* stored in data.number as (whole*10)+part */
STRING,
CODE,
DEFAULT
@@ -74,7 +76,7 @@ struct skin_tag_parameter
union
{
- int numeric;
+ int number;
char* text;
struct skin_element* code;
} data;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index e0247ef745..dd8df63997 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -120,7 +120,7 @@ struct tag_info legal_tags[] =
{ SKIN_TOKEN_REMOTE_HOLD, "mr", "", 0 },
{ SKIN_TOKEN_REPEAT_MODE, "mm", "", 0 },
{ SKIN_TOKEN_PLAYBACK_STATUS, "mp", "", 0 },
- { SKIN_TOKEN_BUTTON_VOLUME, "mv", "|S", 0 },
+ { SKIN_TOKEN_BUTTON_VOLUME, "mv", "|D", 0 },
{ SKIN_TOKEN_PEAKMETER, "pm", "", 0 },
{ SKIN_TOKEN_PLAYER_PROGRESSBAR, "pf", "", 0 },
@@ -131,8 +131,8 @@ struct tag_info legal_tags[] =
{ SKIN_TOKEN_TRACK_TIME_ELAPSED, "pc", "", 0 },
{ SKIN_TOKEN_TRACK_TIME_REMAINING, "pr", "", 0 },
{ SKIN_TOKEN_TRACK_LENGTH, "pt", "", 0 },
- { SKIN_TOKEN_TRACK_STARTING, "pS" , "|S", 0 },
- { SKIN_TOKEN_TRACK_ENDING, "pE" , "|S", 0 },
+ { SKIN_TOKEN_TRACK_STARTING, "pS" , "|D", 0 },
+ { SKIN_TOKEN_TRACK_ENDING, "pE" , "|D", 0 },
{ SKIN_TOKEN_PLAYLIST_POSITION, "pp", "", 0 },
{ SKIN_TOKEN_PLAYLIST_ENTRIES, "pe", "", 0 },
{ SKIN_TOKEN_PLAYLIST_NAME, "pn", "", 0 },
@@ -161,7 +161,7 @@ struct tag_info legal_tags[] =
{ SKIN_TOKEN_RDS_TEXT, "tz", "", 0 },
{ SKIN_TOKEN_SUBLINE_SCROLL, "s", "", 0 },
- { SKIN_TOKEN_SUBLINE_TIMEOUT, "t" , "S", 0 },
+ { SKIN_TOKEN_SUBLINE_TIMEOUT, "t" , "D", 0 },
{ SKIN_TOKEN_ENABLE_THEME, "we", "", NOBREAK },
{ SKIN_TOKEN_DISABLE_THEME, "wd", "", NOBREAK },
@@ -196,7 +196,7 @@ struct tag_info legal_tags[] =
{ SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", 0 },
{ SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", 0 },
- { SKIN_TOKEN_LASTTOUCH, "Tl" , "|S", 0 },
+ { SKIN_TOKEN_LASTTOUCH, "Tl" , "|D", 0 },
{ SKIN_TOKEN_CURRENT_SCREEN, "cs", "", 0 },
{ SKIN_TOKEN_TOUCHREGION, "T" , "IIiiS", NOBREAK },
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h
index 149f148cca..f84d4ac762 100644
--- a/lib/skin_parser/tag_table.h
+++ b/lib/skin_parser/tag_table.h
@@ -246,6 +246,9 @@ enum skin_token_type {
* characters for parameters are:
* I - Required integer
* i - Nullable integer
+ * D - Required decimal
+ * d - Nullable decimal
+ * Decimals are stored as (whole*10)+part
* S - Required string
* s - Nullable string
* F - Required file name