From: tasn Date: Thu, 28 Jul 2011 09:18:55 +0000 (+0000) Subject: Evas textblock: Format tags now support quoting values. X-Git-Tag: 2.0_alpha~240^2~198 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee6cb451c4f3fc1f23e221936462163feb1ab4c8;p=framework%2Fuifw%2Fevas.git Evas textblock: Format tags now support quoting values. For example: "bla". git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@61843 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 17760a1..652381d 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -1561,32 +1561,46 @@ _format_is_param(const char *item) static void _format_param_parse(const char *item, const char **key, const char **val) { - const char *equal, *end; + const char *start, *end, *quote; + + start = strchr(item, '='); + *key = eina_stringshare_add_length(item, start - item); + start++; /* Advance after the '=' */ + /* If we can find a quote, our new delimiter is a quote, not a space. */ + if ((quote = strchr(start, '\''))) + { + start = quote + 1; + end = strchr(start, '\''); + } + else + { + end = strchr(start, ' '); + } - equal = strchr(item, '='); - *key = eina_stringshare_add_length(item, equal - item); - equal++; /* Advance after the '=' */ /* Null terminate before the spaces */ - end = strchr(equal, ' '); if (end) { - *val = eina_stringshare_add_length(equal, end - equal); + *val = eina_stringshare_add_length(start, end - start); } else { - *val = eina_stringshare_add(equal); + *val = eina_stringshare_add(start); } } /** * @internal - * FIXME: comment. + * This function parses the format passed in *s and advances s to point to the + * next format item, while returning the current one as the return value. + * @param s The current and returned position in the format string. + * @return the current item parsed from the string. */ static const char * _format_parse(const char **s) { - const char *p, *item; + const char *p; const char *s1 = NULL, *s2 = NULL; + Eina_Bool quote = EINA_FALSE;; p = *s; if (*p == 0) return NULL; @@ -1599,7 +1613,12 @@ _format_parse(const char **s) } else if (!s2) { - if ((p > *s) && (p[-1] != '\\')) + if (*p == '\'') + { + quote = !quote; + } + + if ((p > *s) && (p[-1] != '\\') && (!quote)) { if (*p == ' ') s2 = p; } @@ -1608,10 +1627,8 @@ _format_parse(const char **s) p++; if (s1 && s2) { - item = s1; - *s = s2; - return item; + return s1; } } *s = p;