[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Skip identical lines in hexdump
From: |
Christian Franke |
Subject: |
[PATCH] Skip identical lines in hexdump |
Date: |
Fri, 30 Jan 2009 23:44:49 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 |
This skips identical lines in hexdump output, like 'od' or 'xxd -a' also do.
Christian
PS: I would suggest to change hexdump 'buf' parameter from 'char *' to
'const void *' to avoid unnecessary casts.
2009-01-30 Christian Franke <address@hidden>
* lib/hexdump.c (hexdump): Print at most 3 lines if data is identical.
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 9b79f45..7689edf 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -61,6 +61,22 @@ hexdump (unsigned long bse, char *buf, int len)
grub_printf ("%s\n", line);
+ /* Print only first and last line of more than 3 lines are identical. */
+ if (len >= 4 * 16
+ && ! grub_memcmp (buf, buf + 1 * 16, 16)
+ && ! grub_memcmp (buf, buf + 2 * 16, 16)
+ && ! grub_memcmp (buf, buf + 3 * 16, 16))
+ {
+ grub_printf ("*\n");
+ do
+ {
+ bse += 16;
+ buf += 16;
+ len -= 16;
+ }
+ while (len >= 3 * 16 && ! grub_memcmp (buf, buf + 2 * 16, 16));
+ }
+
bse += 16;
buf += 16;
len -= cnt;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Skip identical lines in hexdump,
Christian Franke <=