From bb14becb75ed0a5c1ac7b518e953eb76138e9608 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Wed, 15 Dec 2021 18:12:44 +0100 Subject: [PATCH] Fix hexdump for non-printable characters --- sort.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sort.c b/sort.c index 76cde8b..b2d9aaa 100644 --- a/sort.c +++ b/sort.c @@ -153,10 +153,17 @@ hexdump(uint8_t *buf, size_t size) for(j=0; j<16; j++) { - if(i+j < size && isprint(buf[i+j])) - fprintf(stderr, "%c", buf[i+j]); + if(i+j < size) + { + if(isprint(buf[i+j])) + fprintf(stderr, "%c", buf[i+j]); + else + fprintf(stderr, "."); + } else + { fprintf(stderr, " "); + } } fprintf(stderr, "\n"); }