From: Christian Franke <Christian.Franke@t-online.de>
To: grub-devel@gnu.org
Subject: [PATCH] Skip identical lines in hexdump
Date: Fri, 30 Jan 2009 23:44:49 +0100 [thread overview]
Message-ID: <498382E1.8020107@t-online.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
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 <franke@computer.org>
* lib/hexdump.c (hexdump): Print at most 3 lines if data is identical.
[-- Attachment #2: grub2-hexdump-skip.patch --]
[-- Type: text/x-diff, Size: 699 bytes --]
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;
next reply other threads:[~2009-01-30 22:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-30 22:44 Christian Franke [this message]
2009-02-02 19:44 ` [PATCH] Skip identical lines in hexdump Christian Franke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=498382E1.8020107@t-online.de \
--to=christian.franke@t-online.de \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.