diff --git a/include/common/xml.h b/include/common/xml.h index a22699f7..7bc8eb26 100644 --- a/include/common/xml.h +++ b/include/common/xml.h @@ -5,7 +5,7 @@ #include /* - * Converts dotted properties into nested nodes. + * Converts dotted attributes into nested nodes. * For example, the following node: * * * */ -void lab_xml_expand_dotted_props(xmlNode *root); +void lab_xml_expand_dotted_attributes(xmlNode *root); #endif /* LABWC_XML_H */ diff --git a/src/common/xml.c b/src/common/xml.c index 203e56ba..7833bee5 100644 --- a/src/common/xml.c +++ b/src/common/xml.c @@ -5,16 +5,16 @@ #include "common/xml.h" /* - * Converts a property A.B.C="X" into X + * Converts an attribute A.B.C="X" into X */ static xmlNode* -create_prop_tree(const xmlAttr *prop) +create_attribute_tree(const xmlAttr *attr) { - if (!strchr((char *)prop->name, '.')) { + if (!strchr((char *)attr->name, '.')) { return NULL; } - gchar **parts = g_strsplit((char *)prop->name, ".", -1); + gchar **parts = g_strsplit((char *)attr->name, ".", -1); int length = g_strv_length(parts); xmlNode *root_node = NULL; xmlNode *parent_node = NULL; @@ -35,7 +35,7 @@ create_prop_tree(const xmlAttr *prop) parent_node = current_node; } - xmlChar *content = xmlNodeGetContent(prop->children); + xmlChar *content = xmlNodeGetContent(attr->children); xmlNodeSetContent(current_node, content); xmlFree(content); @@ -45,7 +45,7 @@ create_prop_tree(const xmlAttr *prop) /* * Consider . - * These three properties are represented by following trees. + * These three attributes are represented by following trees. * action(dst)---name * action(src)---position---x * action--------position---y @@ -86,7 +86,7 @@ merge_two_trees(xmlNode *dst, xmlNode *src) } void -lab_xml_expand_dotted_props(xmlNode *parent) +lab_xml_expand_dotted_attributes(xmlNode *parent) { xmlNode *old_first_child = parent->children; xmlNode *prev_tree = NULL; @@ -95,13 +95,13 @@ lab_xml_expand_dotted_props(xmlNode *parent) return; } - for (xmlAttr *prop = parent->properties; prop;) { - /* Convert the property with dots into an xml tree */ - xmlNode *tree = create_prop_tree(prop); + for (xmlAttr *attr = parent->properties; attr;) { + /* Convert the attribute with dots into an xml tree */ + xmlNode *tree = create_attribute_tree(attr); if (!tree) { - /* The property doesn't contain dots */ + /* The attribute doesn't contain dots */ prev_tree = NULL; - prop = prop->next; + attr = attr->next; continue; } @@ -116,12 +116,12 @@ lab_xml_expand_dotted_props(xmlNode *parent) prev_tree = tree; } - xmlAttr *next_prop = prop->next; - xmlRemoveProp(prop); - prop = next_prop; + xmlAttr *next_attr = attr->next; + xmlRemoveProp(attr); + attr = next_attr; } for (xmlNode *node = parent->children; node; node = node->next) { - lab_xml_expand_dotted_props(node); + lab_xml_expand_dotted_attributes(node); } } diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 1a01739b..20be4c5a 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1416,7 +1416,7 @@ rcxml_parse_xml(struct buf *b) } struct parser_state init_state = {0}; xmlNode *root = xmlDocGetRootElement(d); - lab_xml_expand_dotted_props(root); + lab_xml_expand_dotted_attributes(root); xml_tree_walk(root, &init_state); xmlFreeDoc(d); xmlCleanupParser(); diff --git a/t/xml.c b/t/xml.c index be71581d..bb8f8a6d 100644 --- a/t/xml.c +++ b/t/xml.c @@ -90,7 +90,7 @@ struct test_case { }}; static void -test_lab_xml_expand_dotted_props(void **state) +test_lab_xml_expand_dotted_attributes(void **state) { (void)state; @@ -99,7 +99,7 @@ test_lab_xml_expand_dotted_props(void **state) NULL, NULL, 0); xmlNode *root = xmlDocGetRootElement(doc); - lab_xml_expand_dotted_props(root); + lab_xml_expand_dotted_attributes(root); xmlBuffer *buf = xmlBufferCreate(); xmlNodeDump(buf, root->doc, root, 0, 0); @@ -113,7 +113,7 @@ test_lab_xml_expand_dotted_props(void **state) int main(int argc, char **argv) { const struct CMUnitTest tests[] = { - cmocka_unit_test(test_lab_xml_expand_dotted_props), + cmocka_unit_test(test_lab_xml_expand_dotted_attributes), }; return cmocka_run_group_tests(tests, NULL, NULL);