From 37d69b8dcc05d676d2e82d4162933e984bb23bcf Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 22 Jun 2008 16:58:56 +0200 Subject: [PATCH] markup substitutions enhancements. Do not preemptively allocate a g_markup_escape_text for substitutions, just remember what we want to substitute markup with, and substitute it in the final buffer efficiently. Signed-off-by: Pierre Habouzit --- client.c | 4 +--- common/markup.c | 2 +- widgets/taglist.c | 6 +----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/client.c b/client.c index bbe321b4..6f1e0e70 100644 --- a/client.c +++ b/client.c @@ -769,8 +769,7 @@ char * client_markup_parse(client_t *c, const char *str, ssize_t len) { const char *elements[] = { "title", NULL }; - char *title_esc = g_markup_escape_text(c->name, -1); - const char *elements_sub[] = { title_esc , NULL }; + const char *elements_sub[] = { c->name , NULL }; markup_parser_data_t p; char *ret; @@ -784,7 +783,6 @@ client_markup_parse(client_t *c, const char *str, ssize_t len) ret = a_strdup(str); markup_parser_data_wipe(&p); - p_delete(&title_esc); return ret; } diff --git a/common/markup.c b/common/markup.c index ecbf3254..070ab3b6 100644 --- a/common/markup.c +++ b/common/markup.c @@ -64,7 +64,7 @@ markup_parse_start_element(GMarkupParseContext *context __attribute__ ((unused)) if(p->elements_sub && p->elements_sub[i]) { - buffer_adds(&p->text, p->elements_sub[i]); + buffer_add_xmlescaped(&p->text, p->elements_sub[i]); } return; diff --git a/widgets/taglist.c b/widgets/taglist.c index 1e28c25e..75af0e75 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -58,22 +58,18 @@ static char * tag_markup_parse(tag_t *t, const char *str, ssize_t len) { const char *elements[] = { "title", NULL }; - char *title_esc = g_markup_escape_text(t->name, -1); - const char *elements_sub[] = { title_esc , NULL }; + const char *elements_sub[] = { t->name , NULL }; markup_parser_data_t p; char *ret; markup_parser_data_init(&p, elements, elements_sub, countof(elements)); if(markup_parse(&p, str, len)) - { ret = buffer_detach(&p.text); - } else ret = a_strdup(str); markup_parser_data_wipe(&p); - p_delete(&title_esc); return ret; }