diff --git a/man/xd.1 b/man/xd.1 index 5d351ba..0d80079 100644 --- a/man/xd.1 +++ b/man/xd.1 @@ -4,7 +4,7 @@ xd \- Display a hexdump table of files .SH SYNOPSIS -xd [\fI-D\fR|\fI-O\fR][\fI-L text\fR][\fI-K text\fR][\fI-R when\fR][\fI-b|-o\fR][\fI-d\fR][\fI-c cols\fR][\fI-g size\fR][\fI-p\fR][\fI-t type\fR][\fIu\fR] [\fIfile...\fR] +xd [\fI-D\fR|\fI-O\fR][\fI-L text\fR][\fI-K text\fR][\fI-R when\fR][\fI-bd\fR][\fI-c cols\fR][\fI-g size\fR][\fI-pu\fR] [\fIfile...\fR] .br xd \fI-i\fR [\fI-c cols\fR][\fI-n name\fR][\fI-u\fR] [\fIfile...\fR] .br @@ -52,15 +52,9 @@ Outputs C headers (changes the default columns size to twelve and ignores group .B \-n name Specify a variable name to be used with \fI-i\fR option. .TP -.B \-o -Use octal count. -.TP .B \-p Displays in plain dump format (change the default columns to thirty, changes the default group size to zero, disables file offsets, disables the colorizing and disables the exibition of the file contents ASCII representation). .TP -.B \-t type -Dumps in the specified base. Type may be: h or x (hexadecimal), o (octal), d (decimal) and b (binary). -.TP .B \-u Use upper case hexadecimal letters. diff --git a/src/xd.c b/src/xd.c index 594e330..091afa3 100644 --- a/src/xd.c +++ b/src/xd.c @@ -12,7 +12,7 @@ #include #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" \ + "Usage: %s [-D|-O][-L text][-K text][-R when][-bd][-c cols][-g size][-pu] [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" \ @@ -31,9 +31,7 @@ "\t-g size: Specifies a group size for the dumped bytes (defaults to 2).\n" \ "\t-i: Outputs C headers (implies -c12).\n" \ "\t-n name: Specifies a name for the variable with the option -i.\n" \ - "\t-o: Counts the offset in octal, not in hexadecimal.\n" \ "\t-p: Displays in plain dump format (implies -D, -c30 and -g0).\n" \ - "\t-t type: Performs a dump of specified type: b(binary), x or h (hexadecimal), d(decimal) or o(octal).\n" \ "\t-u: Use upper case hex letters.\n" \ "Manual entry shall be avaliable with: `man 1 xd`.\n" \ "Copyright (©) @Arthur de Souza Manske, 2024. All rights reserved.\n" @@ -52,10 +50,6 @@ #define HEXDFL_MASK_COLOR (HEXDFL_COLORED | HEXDFL_NOCOLOR) #define HEXPFL_BYTE (0x800) -#define HEXDFL_OCTAL_COUNT (0x1000) -#define HEXDFL_OCTAL_DUMP (0x2000) -#define HEXDFL_DECIMAL_DUMP (0x4000) - struct hexdumping { uint16_t hex_flags; int hex_columns, hex_wordsize; @@ -93,8 +87,6 @@ int hexprint(FILE *stream, unsigned char ch, uint16_t flags) } if (flags & HEXDFL_UPPER) format = "%02hhX"; - if (flags & HEXDFL_DECIMAL_DUMP) format = "%03hhu"; - if (flags & HEXDFL_OCTAL_DUMP) format = "%03hho"; if (!(flags & HEXPFL_BYTE)) { if (ch < 32 || ch > 127) ch = '.'; @@ -157,7 +149,6 @@ int hexdump(FILE *restrict stream, FILE *restrict source, struct hexdumping *res int dumplen = 0, digits = 2; if (hexfl->hex_flags & HEXDFL_BINARY_DUMP) digits = 8; - if (hexfl->hex_flags & HEXDFL_DECIMAL_DUMP || hexfl->hex_flags & HEXDFL_OCTAL_DUMP) digits = 3; if (!(hexfl->hex_flags & HEXDFL_FORCE_COLUMNS)) { if (hexfl->hex_flags & HEXDFL_C) { @@ -194,7 +185,6 @@ int hexdump(FILE *restrict stream, FILE *restrict source, struct hexdumping *res if (!(hexfl->hex_flags & HEXDFL_NOCOUNT)) { char *format = "%010jx%s"; - if (hexfl->hex_flags & HEXDFL_OCTAL_COUNT) format = "%010jo%s"; if (hexfl->hex_flags & HEXDFL_DECIMAL_COUNT) format = "%010ju%s"; fprintf(stream, format, totalbytes, hexfl->hex_off_separator); @@ -241,7 +231,7 @@ int main(int argc, char **argv) struct hexdumping *hexfl = & (struct hexdumping) {.hex_dump_separator = " ", .hex_off_separator = ": "}; opterr = 0; - while ((ch = getopt(argc, argv, ":DK:L:OR:bc:dig:n:oprt:u")) != -1) { + while ((ch = getopt(argc, argv, ":DK:L:OR:bc:dig:n:pru")) != -1) { switch (ch) { case '?': if (optopt == '?') { @@ -306,25 +296,9 @@ int main(int argc, char **argv) hexfl->hex_flags |= HEXDFL_AUTONAME; break; - case 'o': - hexfl->hex_flags &= ~(HEXDFL_DECIMAL_COUNT); - hexfl->hex_flags |= HEXDFL_OCTAL_COUNT; - break; case 'p': hexfl->hex_flags &= ~(HEXDFL_C | HEXDFL_MASK_COLOR); hexfl->hex_flags |= (HEXDFL_NOCOUNT | HEXDFL_PLAIN | HEXDFL_NOCOLOR); - break; - case 't': - if (optarg[1]) goto illegal_optarg; - - switch (optarg[0]) { - case 'h': case 'x': hexfl->hex_flags &= ~(HEXDFL_DECIMAL_DUMP | HEXDFL_OCTAL_DUMP | HEXDFL_BINARY_DUMP); break; - case 'b': hexfl->hex_flags &= ~(HEXDFL_DECIMAL_DUMP | HEXDFL_OCTAL_DUMP); hexfl->hex_flags |= HEXDFL_BINARY_DUMP; break; - case 'o': hexfl->hex_flags &= ~(HEXDFL_BINARY_DUMP | HEXDFL_DECIMAL_DUMP); hexfl->hex_flags |= HEXDFL_OCTAL_DUMP; break; - case 'd': hexfl->hex_flags &= ~(HEXDFL_BINARY_DUMP | HEXDFL_OCTAL_DUMP); hexfl->hex_flags |= HEXDFL_DECIMAL_DUMP; break; - default: goto illegal_optarg; - } - break; case 'u': hexfl->hex_flags |= HEXDFL_UPPER; break; }