summaryrefslogtreecommitdiffhomepage
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-25 00:16:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-25 00:16:04 +0200
commit294d0c85adcbcf48da1fc0f48dae3aed59c07436 (patch)
tree6f0af1f49a3c33e09a4ca7da1f9ec81020cfb978 /util-linux
parent2dade4f18a86d05642aa6f3ef4c5b5100fd10907 (diff)
xxd: compat tweak for -i
function old new delta xxd_main 888 893 +5 .rodata 103669 103674 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 10/0) Total: 10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/hexdump_xxd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c
index aa215569f..fe78f6242 100644
--- a/util-linux/hexdump_xxd.c
+++ b/util-linux/hexdump_xxd.c
@@ -186,9 +186,11 @@ int xxd_main(int argc UNUSED_PARAM, char **argv)
} else {
if (cols == 0)
cols = (opt & OPT_i) ? 12 : 16;
- if (opt & OPT_i)
- bytes = 1; /* -i ignores -gN */
- else
+ if (opt & OPT_i) {
+ bytes = 1; // -i ignores -gN
+ // output is " 0xXX, 0xXX, 0xXX...", add leading space
+ bb_dump_add(dumper, "\" \"");
+ } else
bb_dump_add(dumper, "\"%08.8_ax: \""); // "address: "
}
@@ -197,14 +199,15 @@ int xxd_main(int argc UNUSED_PARAM, char **argv)
}
if (bytes < 1 || bytes >= cols) {
- sprintf(buf, "%u/1 \"%%02x\"", cols); // cols * "xx"
+ sprintf(buf, "%u/1 \"%%02x\"", cols); // cols * "XX"
bb_dump_add(dumper, buf);
}
else if (bytes == 1) {
if (opt & OPT_i)
- sprintf(buf, "%u/1 \" 0x%%02x,\"", cols); // cols * " 0xxx,"
+ sprintf(buf, "%u/1 \" 0x%%02x,\"", cols); // cols * " 0xXX,"
+//TODO: compat: omit the last comma after the very last byte
else
- sprintf(buf, "%u/1 \"%%02x \"", cols); // cols * "xx "
+ sprintf(buf, "%u/1 \"%%02x \"", cols); // cols * "XX "
bb_dump_add(dumper, buf);
}
else {