From b2202a3d7cce23c20192c1b62cf2f934f78f61df Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Tue, 27 Mar 2012 23:42:00 +1100 Subject: [PATCH] skin_engine: Allow negative numbers for the start offset in %ss i.e %ss(-1, -, %ia) will get the last letter in the %ia tag Change-Id: I6b2764d30c072b549e7424fc6e847ec48850b46a --- apps/gui/skin_engine/skin_tokens.c | 5 ++++- manual/appendix/wps_tags.tex | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 29ddad4c5b..1bb5b8e555 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -927,7 +927,10 @@ const char *get_token_value(struct gui_wps *gwps, if (utf8_len < ss->start) return NULL; - start_byte = utf8seek(token_val, ss->start); + if (ss->start < 0) + start_byte = utf8seek(token_val, ss->start + utf8_len); + else + start_byte = utf8seek(token_val, ss->start); if (ss->length < 0 || (ss->start + ss->length) > utf8_len) end_byte = strlen(token_val); diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 4aa9472e74..51f10e9a32 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -766,7 +766,7 @@ a horizontal progressbar which doesn't fill and draws the image \end{tagmap} Use this tag to get a substring from another tag. \begin{description} - \item[start] -- first character to take (0 being the start of the string) + \item[start] -- first character to take (0 being the start of the string, negative means from the end of the string) \item[length] -- length of the substring to return (- for the rest of the string) \item[tag] -- tag to get \item[number] -- OPTIONAL. if this is present it will assume the