From: Philippe Proulx Date: Thu, 25 Apr 2019 00:55:47 +0000 (-0400) Subject: cli: put space after comma between array elements X-Git-Tag: v2.0.0-pre5~56 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=58f62bf93c581f9b26209d1f8342fbff748e4a46 cli: put space after comma between array elements This is more readable when looking at the output of `--run-args`. Signed-off-by: Philippe Proulx Change-Id: I75a4622fb2f2c864f4af1599c18044bb696c3307 --- diff --git a/cli/babeltrace-cfg-cli-args.c b/cli/babeltrace-cfg-cli-args.c index 06385a35..dfce55bd 100644 --- a/cli/babeltrace-cfg-cli-args.c +++ b/cli/babeltrace-cfg-cli-args.c @@ -3223,11 +3223,17 @@ int bt_value_to_cli_param_value_append(const bt_value *value, GString *buf) g_string_append_c(buf, '['); uint64_t sz = bt_value_array_get_size(value); for (uint64_t i = 0; i < sz; i++) { + const bt_value *item; + int ret; + if (i > 0) { - g_string_append_c(buf, ','); + g_string_append(buf, ", "); } - const bt_value *item = bt_value_array_borrow_element_by_index_const(value, i); - int ret = bt_value_to_cli_param_value_append(item, buf); + + item = bt_value_array_borrow_element_by_index_const( + value, i); + ret = bt_value_to_cli_param_value_append(item, buf); + if (ret) { goto end; } diff --git a/tests/cli/test_convert_args.in b/tests/cli/test_convert_args.in index 1f471113..a8404b3f 100644 --- a/tests/cli/test_convert_args.in +++ b/tests/cli/test_convert_args.in @@ -74,7 +74,7 @@ comment() { plan_tests 76 test_bt_convert_run_args 'path leftover' "$path_to_trace" "--component source.ctf.fs --name source-ctf-fs --params 'paths=[\"$path_to_trace\"]' --component sink.text.pretty --name pretty --component filter.utils.muxer --name muxer --connect source-ctf-fs:muxer --connect muxer:pretty" -test_bt_convert_run_args 'path leftovers' "$path_to_trace ${path_to_trace}2 ${path_to_trace}3" "--component source.ctf.fs --name source-ctf-fs --params 'paths=[\"$path_to_trace\",\"${path_to_trace}2\",\"${path_to_trace}3\"]' --component sink.text.pretty --name pretty --component filter.utils.muxer --name muxer --connect source-ctf-fs:muxer --connect muxer:pretty" +test_bt_convert_run_args 'path leftovers' "$path_to_trace ${path_to_trace}2 ${path_to_trace}3" "--component source.ctf.fs --name source-ctf-fs --params 'paths=[\"$path_to_trace\", \"${path_to_trace}2\", \"${path_to_trace}3\"]' --component sink.text.pretty --name pretty --component filter.utils.muxer --name muxer --connect source-ctf-fs:muxer --connect muxer:pretty" test_bt_convert_run_args 'path leftover + named user source with --params' "$path_to_trace --component ZZ:source.another.source --params salut=yes" "--component ZZ:source.another.source --params salut=yes --component source.ctf.fs --name source-ctf-fs --params 'paths=[\"$path_to_trace\"]' --component sink.text.pretty --name pretty --component filter.utils.muxer --name muxer --connect ZZ:muxer --connect source-ctf-fs:muxer --connect muxer:pretty" test_bt_convert_run_args 'path leftover + named user source with --name --params' "$path_to_trace --component source.another.source --name HELLO --params salut=yes" "--component source.another.source --name HELLO --params salut=yes --component source.ctf.fs --name source-ctf-fs --params 'paths=[\"$path_to_trace\"]' --component sink.text.pretty --name pretty --component filter.utils.muxer --name muxer --connect HELLO:muxer --connect source-ctf-fs:muxer --connect muxer:pretty" test_bt_convert_run_args 'path leftover + user source with --path --params' "$path_to_trace --component source.another.source --path some-path --params salut=yes" "--component source.another.source --params 'path=\"some-path\"' --params salut=yes --name source.another.source --component source.ctf.fs --name source-ctf-fs --params 'paths=[\"$path_to_trace\"]' --component sink.text.pretty --name pretty --component filter.utils.muxer --name muxer --connect 'source\\.another\\.source:muxer' --connect source-ctf-fs:muxer --connect muxer:pretty"