Don't strip leading whitespace from menu labels (Fix bug 4782)
Dana Jansens danakj@orodu.net
3 files changed,
25 insertions(+),
8 deletions(-)
M
obt/xml.c
→
obt/xml.c
@@ -321,14 +321,20 @@ {
obt_xml_tree(i, i->root->children); } -gchar *obt_xml_node_string(xmlNodePtr node) +gchar *obt_xml_node_string_unstripped(xmlNodePtr node) { xmlChar *c = xmlNodeGetContent(node); gchar *s; - if (c) g_strstrip((char*)c); /* strip leading/trailing whitespace */ s = g_strdup(c ? (gchar*)c : ""); xmlFree(c); return s; +} + +gchar *obt_xml_node_string(xmlNodePtr node) +{ + gchar* result = obt_xml_node_string_unstripped(node); + g_strstrip(result); /* strip leading/trailing whitespace */ + return result; } gint obt_xml_node_int(xmlNodePtr node)@@ -413,18 +419,26 @@ xmlFree(c);
return r; } -gboolean obt_xml_attr_string(xmlNodePtr node, const gchar *name, - gchar **value) +gboolean obt_xml_attr_string_unstripped(xmlNodePtr node, const gchar *name, + gchar **value) { xmlChar *c = xmlGetProp(node, (const xmlChar*) name); gboolean r = FALSE; if (c) { - g_strstrip((char*)c); /* strip leading/trailing whitespace */ *value = g_strdup((gchar*)c); r = TRUE; } xmlFree(c); return r; +} + +gboolean obt_xml_attr_string(xmlNodePtr node, const gchar *name, + gchar **value) +{ + gboolean result = obt_xml_attr_string_unstripped(node, name, value); + if (result) + g_strstrip(*value); /* strip leading/trailing whitespace */ + return result; } gboolean obt_xml_attr_contains(xmlNodePtr node, const gchar *name,
M
obt/xml.h
→
obt/xml.h
@@ -72,12 +72,15 @@
xmlNodePtr obt_xml_find_node (xmlNodePtr node, const gchar *name); gboolean obt_xml_node_contains (xmlNodePtr node, const gchar *val); +gchar *obt_xml_node_string_unstripped(xmlNodePtr node); gchar *obt_xml_node_string (xmlNodePtr node); gint obt_xml_node_int (xmlNodePtr node); gboolean obt_xml_node_bool (xmlNodePtr node); gboolean obt_xml_attr_contains (xmlNodePtr node, const gchar *name, const gchar *val); +gboolean obt_xml_attr_string_unstripped(xmlNodePtr node, const gchar *name, + gchar **value); gboolean obt_xml_attr_string (xmlNodePtr node, const gchar *name, gchar **value); gboolean obt_xml_attr_int (xmlNodePtr node, const gchar *name,