X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-xml.c;h=22829d9b47401ab1132cfcf0465fb113267bdce4;hb=48a01768126d75c638babf8b0f9a62106daf67cb;hp=60ad8c9c43f570b67662e0506287dd5d83aa79f2;hpb=7de8808cf86ee8922f261d4cd6ee91aa0fa103b1;p=babeltrace.git
diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c
index 60ad8c9c..22829d9b 100644
--- a/formats/ctf/metadata/ctf-visitor-xml.c
+++ b/formats/ctf/metadata/ctf-visitor-xml.c
@@ -42,24 +42,45 @@ int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *nod
{
int ret = 0;
+ switch (node->u.unary_expression.link) {
+ case UNARY_LINK_UNKNOWN:
+ break;
+ case UNARY_DOTLINK:
+ print_tabs(fd, depth);
+ fprintf(fd, "\n");
+ break;
+ case UNARY_ARROWLINK:
+ print_tabs(fd, depth);
+ fprintf(fd, "\n");
+ break;
+ case UNARY_DOTDOTDOT:
+ print_tabs(fd, depth);
+ fprintf(fd, "\n");
+ break;
+ default:
+ fprintf(stderr, "[error] %s: unknown expression link type %d\n", __func__,
+ (int) node->u.unary_expression.link);
+ return -EINVAL;
+ }
+
switch (node->u.unary_expression.type) {
case UNARY_STRING:
print_tabs(fd, depth);
fprintf(fd, "u.unary_expression.u.string);
- fprintf(fd, "/>\n");
+ fprintf(fd, " />\n");
break;
case UNARY_SIGNED_CONSTANT:
print_tabs(fd, depth);
fprintf(fd, "u.unary_expression.u.signed_constant);
- fprintf(fd, "/>\n");
+ fprintf(fd, " />\n");
break;
case UNARY_UNSIGNED_CONSTANT:
print_tabs(fd, depth);
fprintf(fd, "u.unary_expression.u.signed_constant);
- fprintf(fd, "/>\n");
+ fprintf(fd, " />\n");
break;
case UNARY_SBRAC:
print_tabs(fd, depth);
@@ -71,6 +92,16 @@ int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *nod
print_tabs(fd, depth);
fprintf(fd, "");
break;
+ case UNARY_NESTED:
+ print_tabs(fd, depth);
+ fprintf(fd, "");
+ ret = ctf_visitor_print_unary_expression(fd, depth + 1,
+ node->u.unary_expression.u.nested_exp);
+ if (ret)
+ return ret;
+ print_tabs(fd, depth);
+ fprintf(fd, "");
+ break;
case UNARY_UNKNOWN:
default:
@@ -78,29 +109,13 @@ int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *nod
(int) node->u.unary_expression.type);
return -EINVAL;
}
- switch (node->u.unary_expression.link) {
- case UNARY_LINK_UNKNOWN:
- break;
- case UNARY_DOTLINK:
- print_tabs(fd, depth);
- fprintf(fd, "\n");
- break;
- case UNARY_ARROWLINK:
- print_tabs(fd, depth);
- fprintf(fd, "\n");
- break;
- default:
- fprintf(stderr, "[error] %s: unknown expression link type %d\n", __func__,
- (int) node->u.unary_expression.link);
- return -EINVAL;
- }
return 0;
}
int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
{
print_tabs(fd, depth);
- fprintf(fd, "u.type_specifier.type) {
case TYPESPEC_VOID:
@@ -162,23 +177,25 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
fprintf(fd, "\n");
depth++;
- print_tabs(fd, depth);
- fprintf(fd, "\n");
- cds_list_for_each_entry(iter, &node->u.type_declarator.pointers,
- siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
+ if (!cds_list_empty(&node->u.type_declarator.pointers)) {
+ print_tabs(fd, depth);
+ fprintf(fd, "\n");
+ cds_list_for_each_entry(iter, &node->u.type_declarator.pointers,
+ siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ print_tabs(fd, depth);
+ fprintf(fd, "\n");
}
- print_tabs(fd, depth);
- fprintf(fd, "\n");
switch (node->u.type_declarator.type) {
case TYPEDEC_ID:
print_tabs(fd, depth);
fprintf(fd, "u.type_declarator.u.id);
- fprintf(fd, "<\" />\n");
+ fprintf(fd, "\" />\n");
break;
case TYPEDEC_NESTED:
if (node->u.type_declarator.u.nested.type_declarator) {
@@ -316,17 +333,22 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
depth++;
print_tabs(fd, depth);
fprintf(fd, "\n");
- ret = ctf_visitor_print_xml(fd, depth + 1, node->u.ctf_expression.left);
- if (ret)
- return ret;
+ cds_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+
print_tabs(fd, depth);
fprintf(fd, "\n");
print_tabs(fd, depth);
fprintf(fd, "\n");
- ret = ctf_visitor_print_xml(fd, depth + 1, node->u.ctf_expression.right);
- if (ret)
- return ret;
+ cds_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
print_tabs(fd, depth);
fprintf(fd, "\n");
depth--;
@@ -491,14 +513,13 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
if (node->u.enumerator.id)
fprintf(fd, " id=\"%s\"", node->u.enumerator.id);
fprintf(fd, ">\n");
- if (node->u.enumerator.values) {
- ret = ctf_visitor_print_xml(fd, depth + 1,
- node->u.enumerator.values);
+ cds_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
print_tabs(fd, depth);
- fprintf(fd, "");
+ fprintf(fd, "\n");
break;
case NODE_ENUM:
print_tabs(fd, depth);
@@ -511,23 +532,23 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node)
if (node->u._enum.container_type) {
print_tabs(fd, depth);
- fprintf(fd, "");
+ fprintf(fd, "\n");
ret = ctf_visitor_print_xml(fd, depth + 1, node->u._enum.container_type);
if (ret)
return ret;
print_tabs(fd, depth);
- fprintf(fd, "");
+ fprintf(fd, "\n");
}
print_tabs(fd, depth);
- fprintf(fd, "");
+ fprintf(fd, "\n");
cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
print_tabs(fd, depth);
- fprintf(fd, "");
+ fprintf(fd, "\n");
depth--;
print_tabs(fd, depth);