commit 5b3e5799f9c2782e724a5c6a9d0482d51162708c
parent 7041fcde68c2f9cafbece1650611ced0d29aed64
Author: Louis Burda <quent.burda@gmail.com>
Date: Sat, 8 Jul 2023 17:20:08 +0200
Only optionally show non-differing 16-byte blocks
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/hexdiff.c b/hexdiff.c
@@ -35,6 +35,7 @@ static const int diff_gradient[256] = {
static bool use_color = true;
static bool has_color = false;
+static bool show_all = false;
static inline void
color_byte(struct file *cur, struct file *other, size_t i)
@@ -67,6 +68,8 @@ main(int argc, const char **argv)
use_color = true;
} else if (!strcmp(*arg, "-C")) {
use_color = false;
+ } else if (!strcmp(*arg, "-a")) {
+ show_all = true;
} else if (!f1.fname) {
f1.fname = *arg;
} else if (!f2.fname) {
@@ -91,6 +94,9 @@ main(int argc, const char **argv)
while (!feof(f1.file) && !feof(f2.file)) {
f1.buflen = fread(f1.buf, 1, 16, f1.file);
f2.buflen = fread(f2.buf, 1, 16, f2.file);
+ if (!show_all && f1.buflen == f2.buflen
+ && !memcmp(f1.buf, f2.buf, f1.buflen))
+ continue;
if (!f1.buflen && !f2.buflen) break;
printf("%06lx: ", pos);