summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-07-08 17:20:08 +0200
committerLouis Burda <quent.burda@gmail.com>2023-07-08 17:20:08 +0200
commit5b3e5799f9c2782e724a5c6a9d0482d51162708c (patch)
treee1bd14f958dfc7cf77ac1eb3d97a7b5a8eb7143f
parent7041fcde68c2f9cafbece1650611ced0d29aed64 (diff)
downloadhexdiff-5b3e5799f9c2782e724a5c6a9d0482d51162708c.tar.gz
hexdiff-5b3e5799f9c2782e724a5c6a9d0482d51162708c.zip
Only optionally show non-differing 16-byte blocks
-rw-r--r--hexdiff.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hexdiff.c b/hexdiff.c
index da9a9d8..d2a8bbb 100644
--- 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);