diff options
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/hexdump-parse.c | 16 | ||||
-rw-r--r-- | text-utils/hexdump.1 | 3 |
2 files changed, 16 insertions, 3 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 diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1 index edf5d6f9c..89b0d9168 100644 --- a/text-utils/hexdump.1 +++ b/text-utils/hexdump.1 @@ -264,8 +264,7 @@ interpreted by hexdump inside the color_units. .TP .B OFFSET An offset or an offset range at which to check for a match. Please note -that lone OFFSET_START uses the same value as END offset. Also, the -range may not be larger than the respective format byte count. +that lone OFFSET_START uses the same value as END offset. .SS Counters The default and supported byte counts for the conversion characters are as follows: |