summaryrefslogtreecommitdiff
path: root/obt/parse.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2009-11-24 19:51:00 -0500
committerDana Jansens <danakj@orodu.net>2009-11-24 19:56:00 -0500
commit84843c3f9842046e34366202f1a8f80ce8565f91 (patch)
tree942660a4581752c29e2a66cdc048c2f1cdc1b9d6 /obt/parse.c
parent4bf6b1b551be744be4fbe4d1faab5be12d051378 (diff)
strip leading/trailing whitespace off stuff when reading it from the configs
Diffstat (limited to 'obt/parse.c')
-rw-r--r--obt/parse.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/obt/parse.c b/obt/parse.c
index a792188f..b7c34ab1 100644
--- a/obt/parse.c
+++ b/obt/parse.c
@@ -307,7 +307,9 @@ void obt_parse_tree_from_root(ObtParseInst *i)
gchar *obt_parse_node_string(xmlNodePtr node)
{
xmlChar *c = xmlNodeGetContent(node);
- gchar *s = g_strdup(c ? (gchar*)c : "");
+ gchar *s;
+ if (c) g_strstrip((char*)c); /* strip leading/trailing whitespace */
+ s = g_strdup(c ? (gchar*)c : "");
xmlFree(c);
return s;
}
@@ -315,7 +317,9 @@ gchar *obt_parse_node_string(xmlNodePtr node)
gint obt_parse_node_int(xmlNodePtr node)
{
xmlChar *c = xmlNodeGetContent(node);
- gint i = c ? atoi((gchar*)c) : 0;
+ gint i;
+ if (c) g_strstrip((char*)c); /* strip leading/trailing whitespace */
+ i = c ? atoi((gchar*)c) : 0;
xmlFree(c);
return i;
}
@@ -324,6 +328,7 @@ gboolean obt_parse_node_bool(xmlNodePtr node)
{
xmlChar *c = xmlNodeGetContent(node);
gboolean b = FALSE;
+ if (c) g_strstrip((char*)c); /* strip leading/trailing whitespace */
if (c && !xmlStrcasecmp(c, (const xmlChar*) "true"))
b = TRUE;
else if (c && !xmlStrcasecmp(c, (const xmlChar*) "yes"))
@@ -338,6 +343,7 @@ gboolean obt_parse_node_contains(xmlNodePtr node, const gchar *val)
{
xmlChar *c = xmlNodeGetContent(node);
gboolean r;
+ if (c) g_strstrip((char*)c); /* strip leading/trailing whitespace */
r = !xmlStrcasecmp(c, (const xmlChar*) val);
xmlFree(c);
return r;
@@ -359,6 +365,7 @@ gboolean obt_parse_attr_bool(xmlNodePtr node, const gchar *name,
xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
gboolean r = FALSE;
if (c) {
+ g_strstrip((char*)c); /* strip leading/trailing whitespace */
if (!xmlStrcasecmp(c, (const xmlChar*) "true"))
*value = TRUE, r = TRUE;
else if (!xmlStrcasecmp(c, (const xmlChar*) "yes"))
@@ -381,6 +388,7 @@ gboolean obt_parse_attr_int(xmlNodePtr node, const gchar *name, gint *value)
xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
gboolean r = FALSE;
if (c) {
+ g_strstrip((char*)c); /* strip leading/trailing whitespace */
*value = atoi((gchar*)c);
r = TRUE;
}
@@ -394,6 +402,7 @@ gboolean obt_parse_attr_string(xmlNodePtr node, const gchar *name,
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;
}
@@ -406,8 +415,10 @@ gboolean obt_parse_attr_contains(xmlNodePtr node, const gchar *name,
{
xmlChar *c = xmlGetProp(node, (const xmlChar*) name);
gboolean r = FALSE;
- if (c)
+ if (c) {
+ g_strstrip((char*)c); /* strip leading/trailing whitespace */
r = !xmlStrcasecmp(c, (const xmlChar*) val);
+ }
xmlFree(c);
return r;
}