From 0d94ea65a54665179614efed0b7912ef54cee4de Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Wed, 24 Feb 2016 07:53:31 +0100 Subject: [PATCH] fix CSV, XML output --- storage.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/storage.c b/storage.c index 3c1109e..9986d48 100644 --- a/storage.c +++ b/storage.c @@ -1261,10 +1261,10 @@ static void emit_one(JsonNode *j, JsonNode *inttypes, void (func)(char *line, vo func(UB(line), param); } -void xml_output(JsonNode *json, output_type otype, JsonNode *fields, void (*func)(char *s, void *param), void *param) +void xml_output(JsonNode *array, output_type otype, JsonNode *fields, void (*func)(char *s, void *param), void *param) { JsonNode *node, *inttypes; - JsonNode *arr, *one, *j; + JsonNode *one, *j; /* Prime the inttypes object with types we consider "integer" */ inttypes = json_mkobject(); @@ -1280,8 +1280,7 @@ void xml_output(JsonNode *json, output_type otype, JsonNode *fields, void (*func ", param); func("", param); - arr = json_find_member(json, "locations"); - json_foreach(one, arr) { + json_foreach(one, array) { func(" ", param); if (fields) { json_foreach(node, fields) { @@ -1353,10 +1352,10 @@ static void csv_title(UT_string *line, JsonNode *node, char *column) * default ALL. */ -void csv_output(JsonNode *json, output_type otype, JsonNode *fields, void (*func)(char *s, void *param), void *param) +void csv_output(JsonNode *array, output_type otype, JsonNode *fields, void (*func)(char *s, void *param), void *param) { JsonNode *node, *inttypes; - JsonNode *arr, *one, *j; + JsonNode *one, *j; short virgin = 1; static UT_string *line = NULL; @@ -1372,8 +1371,7 @@ void csv_output(JsonNode *json, output_type otype, JsonNode *fields, void (*func json_append_member(inttypes, "dist", json_mkbool(1)); json_append_member(inttypes, "trip", json_mkbool(1)); - arr = json_find_member(json, "locations"); - json_foreach(one, arr) { + json_foreach(one, array) { /* Headings */ if (virgin) {