[glade] glade-xml-utils: glade_xml_node_is_comment() stop treating text nodes as comments And start using ty



commit dbf7f22564f32ee23f2747bd54803dcc4cefcdf9
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Tue Dec 17 15:49:51 2013 -0300

    glade-xml-utils: glade_xml_node_is_comment() stop treating text nodes as comments
    And start using type member of xmlNode struct to check node type instead of strcmp its name.
    
    Added inline function glade_xml_node_is_comment_or_text() to use in
    glade_xml_node_get_children() and glade_xml_node_next()

 gladeui/glade-xml-utils.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/gladeui/glade-xml-utils.c b/gladeui/glade-xml-utils.c
index 9b9424c..576ab21 100644
--- a/gladeui/glade-xml-utils.c
+++ b/gladeui/glade-xml-utils.c
@@ -800,12 +800,14 @@ gboolean
 glade_xml_node_is_comment (GladeXmlNode * node_in)
 {
   xmlNodePtr node = (xmlNodePtr) node_in;
-  if (node == NULL)
-    return FALSE;
-  if ((xmlStrcmp (node->name, BAD_CAST ("text")) == 0) ||
-      (xmlStrcmp (node->name, BAD_CAST ("comment")) == 0))
-    return TRUE;
-  return FALSE;
+  return (node) ? node->type == XML_COMMENT_NODE : FALSE;
+}
+
+static inline gboolean
+glade_xml_node_is_comment_or_text (GladeXmlNode *node_in)
+{
+  xmlNodePtr node = (xmlNodePtr) node_in;
+  return (node) ? node->type == XML_COMMENT_NODE || node->type == XML_TEXT_NODE : FALSE;
 }
 
 GladeXmlNode *
@@ -815,7 +817,7 @@ glade_xml_node_get_children (GladeXmlNode * node_in)
   xmlNodePtr children;
 
   children = node->children;
-  while (glade_xml_node_is_comment ((GladeXmlNode *) children))
+  while (glade_xml_node_is_comment_or_text ((GladeXmlNode *) children))
     children = children->next;
 
   return (GladeXmlNode *) children;
@@ -844,7 +846,7 @@ glade_xml_node_next (GladeXmlNode * node_in)
   xmlNodePtr node = (xmlNodePtr) node_in;
 
   node = node->next;
-  while (glade_xml_node_is_comment ((GladeXmlNode *) node))
+  while (glade_xml_node_is_comment_or_text ((GladeXmlNode *) node))
     node = node->next;
 
   return (GladeXmlNode *) node;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]