From fa07d641c528cc62dd8581c6aafb31b42f4b9c4e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 9 Jun 2016 13:50:10 +0100 Subject: [PATCH] ECC-233: Stray comma character in BUFR json dump --- tests/bufr_json.sh | 41 ++++++++++++++++++++++++----------------- tools/bufr_dump.c | 5 ++++- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/tests/bufr_json.sh b/tests/bufr_json.sh index 8d58a590e..b9959821b 100755 --- a/tests/bufr_json.sh +++ b/tests/bufr_json.sh @@ -24,29 +24,36 @@ cd ${data_dir}/bufr bufr_files=`cat bufr_data_files.txt` for file in ${bufr_files} do - rm -f ${file}.json | true - - ${tools_dir}bufr_dump -js $file 2> $REDIRECT > ${file}.json - - if test "x$JSON_CHECK" != "x"; then - json_xs < ${file}.json >$REDIRECT 2> $REDIRECT - fi - - rm -f ${file}.json | true - - ${tools_dir}bufr_dump -ja $file 2> $REDIRECT > ${file}.json - - if test "x$JSON_CHECK" != "x"; then - json_xs < ${file}.json >$REDIRECT 2> $REDIRECT - fi - + # JSON dump structure rm -f ${file}.json + ${tools_dir}bufr_dump -js $file 2> $REDIRECT > ${file}.json + if test "x$JSON_CHECK" != "x"; then + json_xs < ${file}.json >$REDIRECT 2> $REDIRECT + fi + # JSON dump all attributes + rm -f ${file}.json + ${tools_dir}bufr_dump -ja $file 2> $REDIRECT > ${file}.json + if test "x$JSON_CHECK" != "x"; then + json_xs < ${file}.json >$REDIRECT 2> $REDIRECT + fi + + # JSON dump flat + rm -f ${file}.json ${tools_dir}bufr_dump -jf $file 2> $REDIRECT > ${file}.json - if test "x$JSON_CHECK" != "x"; then json_xs < ${file}.json >$REDIRECT 2> $REDIRECT fi rm -f ${file}.json done + +# ECC-233: Test JSON dump when selecting messages with '-w' switch +file=tropical_cyclone.bufr +for c in 1 3 1/3; do + ${tools_dir}bufr_dump -w count=$c $file 2> $REDIRECT > ${file}.json + if test "x$JSON_CHECK" != "x"; then + json_xs < ${file}.json >$REDIRECT 2> $REDIRECT + fi +done + diff --git a/tools/bufr_dump.c b/tools/bufr_dump.c index bd727f966..10f0368b0 100644 --- a/tools/bufr_dump.c +++ b/tools/bufr_dump.c @@ -163,7 +163,10 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) grib_set_flag(h,options->print_keys[i].name,GRIB_ACCESSOR_FLAG_DUMP); if (json) { - if (options->handle_count>1) fprintf(stdout,",\n"); + /* ECC-233: print comma as separator between messages */ + if (!first_handle && options->handle_count>1) { + fprintf(stdout,",\n"); + } if (json && first_handle) { fprintf(stdout,"{ \"messages\" : [ \n"); first_handle=0;