From: Gerhard Sittig Date: Sun, 19 Mar 2023 17:06:06 +0000 (+0100) Subject: strutil: add more space in hexdumps after 8 and 16 data bytes X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=a1d7443ba4130ffedfe657b59a77c00bc616662a;p=libsigrok.git strutil: add more space in hexdumps after 8 and 16 data bytes The previous implementation just had one space between bytes. Which quickly becomes hard to read for longer runs. Add more spaces after 8 and 16 bytes each for improved readability. --- diff --git a/src/strutil.c b/src/strutil.c index 9376ff09..c389a524 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -788,10 +788,17 @@ SR_PRIV GString *sr_hexdump_new(const uint8_t *data, const size_t len) GString *s; size_t i; - s = g_string_sized_new(3 * len); + i = 3 * len; + i += len / 8; + i += len / 16; + s = g_string_sized_new(i); for (i = 0; i < len; i++) { if (i) g_string_append_c(s, ' '); + if (i && (i % 8) == 0) + g_string_append_c(s, ' '); + if (i && (i % 16) == 0) + g_string_append_c(s, ' '); g_string_append_printf(s, "%02x", data[i]); }