From 251ab2686e34ab5d8eadd01311004954b3292cac Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Fri, 9 Mar 2018 22:23:19 +0100 Subject: [PATCH] enhance dumps --- lib/ecoli_completed.c | 2 +- lib/ecoli_node.c | 19 +++++-------------- lib/ecoli_parsed.c | 20 ++++++-------------- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/lib/ecoli_completed.c b/lib/ecoli_completed.c index 4113ef3..bdada2a 100644 --- a/lib/ecoli_completed.c +++ b/lib/ecoli_completed.c @@ -524,7 +524,7 @@ void ec_completed_dump(FILE *out, const struct ec_completed *completed) return; } - fprintf(out, "completion: count=%u full=%u full=%u unknown=%u\n", + fprintf(out, "completion: count=%u full=%u partial=%u unknown=%u\n", completed->count, completed->count_full, completed->count_partial, completed->count_unknown); diff --git a/lib/ecoli_node.c b/lib/ecoli_node.c index dc4cc17..abc3e76 100644 --- a/lib/ecoli_node.c +++ b/lib/ecoli_node.c @@ -259,34 +259,25 @@ const char *ec_node_id(const struct ec_node *node) static void __ec_node_dump(FILE *out, const struct ec_node *node, size_t indent) { - const char *id, *typename, *desc; + const char *id, *typename; struct ec_node *child; size_t i, n; id = ec_node_id(node); typename = node->type->name; - desc = ec_node_desc(node); - - /* XXX enhance */ - for (i = 0; i < indent; i++) { - if (i % 2) - fprintf(out, " "); - else - fprintf(out, "|"); - } - fprintf(out, "node %p type=%s id=%s desc=%s\n", - node, typename, id, desc); + fprintf(out, "%*s" "type=%s id=%s %p\n", + (int)indent * 4, "", typename, id, node); n = node->n_children; for (i = 0; i < n; i++) { child = node->children[i]; - __ec_node_dump(out, child, indent + 2); + __ec_node_dump(out, child, indent + 1); } } void ec_node_dump(FILE *out, const struct ec_node *node) { - fprintf(out, "------------------- node dump:\n"); //XXX + fprintf(out, "------------------- node dump:\n"); if (node == NULL) { fprintf(out, "node is NULL\n"); diff --git a/lib/ecoli_parsed.c b/lib/ecoli_parsed.c index 5588dc6..a70f066 100644 --- a/lib/ecoli_parsed.c +++ b/lib/ecoli_parsed.c @@ -260,24 +260,16 @@ static void __ec_parsed_dump(FILE *out, { struct ec_parsed *child; const struct ec_strvec *vec; - size_t i; - const char *id = "none", *typename = "none"; + const char *id, *typename = "none"; + /* node can be null when parsing is incomplete */ if (parsed->node != NULL) { - if (parsed->node->id != NULL) - id = parsed->node->id; + id = parsed->node->id; typename = parsed->node->type->name; } - /* XXX enhance */ - for (i = 0; i < indent; i++) { - if (i % 2) - fprintf(out, " "); - else - fprintf(out, "|"); - } - - fprintf(out, "node_type=%s id=%s vec=", typename, id); + fprintf(out, "%*s" "type=%s id=%s vec=", + (int)indent * 4, "", typename, id); vec = ec_parsed_strvec(parsed); ec_strvec_dump(out, vec); @@ -287,7 +279,7 @@ static void __ec_parsed_dump(FILE *out, void ec_parsed_dump(FILE *out, const struct ec_parsed *parsed) { - fprintf(out, "------------------- parsed dump:\n"); //XXX + fprintf(out, "------------------- parsed dump:\n"); if (parsed == NULL) { fprintf(out, "parsed is NULL, error in parse\n"); -- 2.20.1