From 4198e0a81912bbe1a248e755aea74ca91e0b1645 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 14 Dec 2023 20:20:39 -0500 Subject: [PATCH] fix printing arrays --- src/tag_print.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/tag_print.c b/src/tag_print.c index 9612698..b6a8e1a 100644 --- a/src/tag_print.c +++ b/src/tag_print.c @@ -35,9 +35,11 @@ static void tag_print_data(const tag_t *tag, int depth) { break; case TAG_BYTE_ARRAY: printf("["); - for (int32_t i = 0; i < tag->data.b_arr.size; i++) - printf("%hhd,", tag->data.b_arr.data[i]); - printf("\b]"); + for (int32_t i = 0; i < tag->data.b_arr.size; i++) { + if (i != 0) printf(","); + printf("%hhd", tag->data.b_arr.data[i]); + } + printf("]"); break; case TAG_STRING: if (tag->data.string.size > 1) @@ -65,15 +67,19 @@ static void tag_print_data(const tag_t *tag, int depth) { break; case TAG_INT_ARRAY: printi(depth, "["); - for (int32_t i = 0; i < tag->data.i_arr.size; i++) - printf("%d,", tag->data.i_arr.data[i]); - printf("\b]"); + for (int32_t i = 0; i < tag->data.i_arr.size; i++) { + if (i != 0) printf(","); + printf("%d", tag->data.i_arr.data[i]); + } + printf("]"); break; case TAG_LONG_ARRAY: printf("["); - for (int32_t i = 0; i < tag->data.l_arr.size; i++) - printf("%ld,", tag->data.l_arr.data[i]); - printf("\b]"); + for (int32_t i = 0; i < tag->data.l_arr.size; i++) { + if (i != 0) printf(","); + printf("%ld", tag->data.l_arr.data[i]); + } + printf("]"); break; case TAG_END: break;