From 10280a648f9caa1836f9b461301467194d091787 Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 6 Sep 2018 13:08:36 +0000 Subject: Small change to hex so that divisible by 16 file length doesn't cause a blank line. --- hex.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'hex.c') diff --git a/hex.c b/hex.c index 39076be..1f9ba08 100644 --- a/hex.c +++ b/hex.c @@ -20,13 +20,16 @@ static void Dump(char *fn,FILE *fp) { strcpy(s," "); - printf("%6.6x: ",p); - p+=16; - for(f=0;f<16;f++) { if((b!=EOF)&&((b=getc(fp))!=EOF)) { + if (f == 0) + { + printf("%6.6x: ",p); + p+=16; + } + printf("%2.2x ",(unsigned char)b); if (isprint(b)) @@ -40,6 +43,11 @@ static void Dump(char *fn,FILE *fp) } else { + if (f == 0) + { + return; + } + printf("** "); } } -- cgit v1.2.3