diff options
author | Denys Vlasenko | 2017-01-25 01:58:00 +0100 |
---|---|---|
committer | Denys Vlasenko | 2017-01-25 01:58:00 +0100 |
commit | 0f4364775fbc0b716024d5211325045c40b431c9 (patch) | |
tree | 9f1bbe20c313154a2f9678816e55eb1944e6a622 /util-linux/hexdump.c | |
parent | 2181fb4af8680730e0157310ffeeb3a35768beb0 (diff) | |
download | busybox-0f4364775fbc0b716024d5211325045c40b431c9.zip busybox-0f4364775fbc0b716024d5211325045c40b431c9.tar.gz |
xxd: new applet
Yet Another Hexdumper
function old new delta
xxd_main - 364 +364
packed_usage 31046 31116 +70
applet_names 2560 2564 +4
applet_main 1476 1480 +4
rewrite 1022 1013 -9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 442/-9) Total: 433 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/hexdump.c')
-rw-r--r-- | util-linux/hexdump.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index 4a7f641..4b536e1 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c @@ -47,6 +47,7 @@ //usage: "\n -d Two-byte decimal display" //usage: "\n -e FORMAT_STRING" //usage: "\n -f FORMAT_FILE" +// exactly the same help text lines in hexdump and xxd: //usage: "\n -n LENGTH Interpret only LENGTH bytes of input" //usage: "\n -o Two-byte octal display" //usage: "\n -s OFFSET Skip OFFSET bytes" @@ -83,11 +84,11 @@ static void bb_dump_addfile(dumper_t *dumper, char *name) } static const char *const add_strings[] = { - "\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"", /* b */ - "\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"", /* c */ - "\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"", /* d */ - "\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"", /* o */ - "\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", /* x */ + "\"%07.7_ax \"16/1 \"%03o \"\"\n\"", /* b */ + "\"%07.7_ax \"16/1 \"%3_c \"\"\n\"", /* c */ + "\"%07.7_ax \"8/2 \" %05u \"\"\n\"", /* d */ + "\"%07.7_ax \"8/2 \" %06o \"\"\n\"", /* o */ + "\"%07.7_ax \"8/2 \" %04x \"\"\n\"", /* x */ }; static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\""; @@ -125,9 +126,11 @@ int hexdump_main(int argc, char **argv) /* Save a little bit of space below by omitting the 'else's. */ if (ch == 'C') { hd_applet: - bb_dump_add(dumper, "\"%08.8_Ax\n\""); - bb_dump_add(dumper, "\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" "); - bb_dump_add(dumper, "\" |\" 16/1 \"%_p\" \"|\\n\""); + bb_dump_add(dumper, "\"%08.8_Ax\n\""); // final address line after dump + //------------------- "address " 8 * "xx " " " 8 * "xx " + bb_dump_add(dumper, "\"%08.8_ax \"8/1 \"%02x \" \" \"8/1 \"%02x \""); + //------------------- " |ASCII...........|\n" + bb_dump_add(dumper, "\" |\"16/1 \"%_p\"\"|\n\""); } if (ch == 'e') { bb_dump_add(dumper, optarg); @@ -158,7 +161,7 @@ int hexdump_main(int argc, char **argv) if (!dumper->fshead) { bb_dump_add(dumper, add_first); - bb_dump_add(dumper, "\"%07.7_ax \" 8/2 \"%04x \" \"\\n\""); + bb_dump_add(dumper, "\"%07.7_ax \"8/2 \"%04x \"\"\n\""); } argv += optind; |