summaryrefslogtreecommitdiffstats
path: root/text-utils/hexdump-parse.c
diff options
context:
space:
mode:
authorOndrej Oprala2014-02-21 15:34:45 +0100
committerKarel Zak2014-03-04 12:48:59 +0100
commit3bf7ede9971bfafc53b1cba8154fc33dfc9f24b9 (patch)
treec97f39c1219250f806a0f152c5f4040bee593eec /text-utils/hexdump-parse.c
parentlscpu: read_hypervisor_dmi: only fallback to memory scan on x86/x86_64 (diff)
downloadkernel-qcow2-util-linux-3bf7ede9971bfafc53b1cba8154fc33dfc9f24b9.tar.gz
kernel-qcow2-util-linux-3bf7ede9971bfafc53b1cba8154fc33dfc9f24b9.tar.xz
kernel-qcow2-util-linux-3bf7ede9971bfafc53b1cba8154fc33dfc9f24b9.zip
hexdump: color unit may now be longer than the corresponding format unit
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Diffstat (limited to 'text-utils/hexdump-parse.c')
-rw-r--r--text-utils/hexdump-parse.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/text-utils/hexdump-parse.c b/text-utils/hexdump-parse.c
index 660dcce31..22e397c91 100644
--- a/text-utils/hexdump-parse.c
+++ b/text-utils/hexdump-parse.c
@@ -565,8 +565,22 @@ static struct list_head *color_fmt(char *cfmt, int bcnt)
if (errno)
badfmt(fmt);
/* offset range must be between 0 and format byte count */
- if (!(hcnext->range >= 0 && hcnext->range <= bcnt))
+ if (hcnext->range < 0)
badcnt("_L");
+ /* the offset extends over several print units, clone
+ * the condition, link it in and adjust the address/offset */
+ while (hcnext->range > bcnt) {
+ hc = xcalloc(1, sizeof(struct hexdump_clr));
+ memcpy(hc, hcnext, sizeof(struct hexdump_clr));
+
+ hc->range = bcnt;
+
+ INIT_LIST_HEAD(&hc->colorlist);
+ list_add_tail(&hc->colorlist, ret_head);
+
+ hcnext->offt += bcnt;
+ hcnext->range -= bcnt;
+ }
}
/* no specific offset */
} else