From 3bf7ede9971bfafc53b1cba8154fc33dfc9f24b9 Mon Sep 17 00:00:00 2001 From: Ondrej Oprala Date: Fri, 21 Feb 2014 15:34:45 +0100 Subject: hexdump: color unit may now be longer than the corresponding format unit Signed-off-by: Ondrej Oprala --- text-utils/hexdump-parse.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'text-utils/hexdump-parse.c') 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 -- cgit v1.2.3-55-g7522