Skip to content

Commit

Permalink
Enhanced behavior of options '-L text' and '-K text'.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur-manske committed Apr 13, 2024
1 parent a598293 commit c9dbbe6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion man/xd.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Disables the file offsets column at the generated hexdump table.
Enables the file offsets column at the generated hexdump table (default).
.TP
.B \-L text
Displays the specified text as the separator of the file hexdump to the file contents ASCII representation. Displays a space before the specified text.
Displays the specified text as the separator of the file hexdump to the file contents ASCII representation.
.TP
.B \-K text
Displays the specified text as the separator of the file offsets to the file hexdump.
Expand Down
7 changes: 4 additions & 3 deletions src/xd.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

#define __XD_USAGE__ \
"Usage: %s [-D|-O][-L text][-K text][-R when][-b][-d|-o][-c cols][-g size][-p][-t type][-u] [file...]\n" \
" %s -i [-b][-c columns][-n name][-u] [file...]\n" \
" %s -i [-c columns][-n name][-u] [file...]\n" \
" %s -?\n" \
"Displays a hexdump of the specified file(s) or standard input.\n" \
"This utility is not a part of POSIX® specification.\n" \
"Special options:\n" \
"\t-?: Displays this message and then exits.\n" \
"General options:\n" \
"\t-D: Disables the printing of offsets.\n" \
"\t-L text: Specifies the dump separator. A space is added before it.\n" \
"\t-L text: Specifies the dump separator.\n" \
"\t-K text: Specifies the offset separator.\n" \
"\t-O: Enables the printing of offsets (default).\n" \
"\t-R when: Specifies when to color output. When may be: never, always or auto.\n" \
Expand Down Expand Up @@ -182,7 +182,9 @@ int hexdump(FILE *restrict stream, FILE *restrict source, struct hexdumping *res
}

if (hexfl->hex_flags & HEXDFL_C) return chexdump(stream, source, hexfl);

dumplen = (hexfl->hex_columns * digits) + (hexfl->hex_columns / hexfl->hex_wordsize);
if (hexfl->hex_columns % hexfl->hex_wordsize == 0) dumplen -= 1;

while (fpeek(source) != EOF) {
fpos_t initpos;
Expand Down Expand Up @@ -311,7 +313,6 @@ int main(int argc, char **argv)
case 'p':
hexfl->hex_flags &= ~(HEXDFL_C | HEXDFL_MASK_COLOR);
hexfl->hex_flags |= (HEXDFL_NOCOUNT | HEXDFL_PLAIN | HEXDFL_NOCOLOR);
hexfl->hex_off_separator = "";
break;
case 't':
if (optarg[1]) goto illegal_optarg;
Expand Down

0 comments on commit c9dbbe6

Please sign in to comment.