summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-09-06 13:08:36 +0000
committerIan C <ianc@noddybox.co.uk>2018-09-06 13:08:36 +0000
commit10280a648f9caa1836f9b461301467194d091787 (patch)
tree07b50c0c8937d28c31f736034c467fafcd3e40ae
parent188f93cc71ffcf3bcef8f9ebc723edfc236d938d (diff)
Small change to hex so that divisible by 16 file length doesn't cause a blank
line.
-rw-r--r--hex.c14
1 files changed, 11 insertions, 3 deletions
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("** ");
}
}