diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-25 00:16:04 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-25 00:16:04 +0200 |
commit | 294d0c85adcbcf48da1fc0f48dae3aed59c07436 (patch) | |
tree | 6f0af1f49a3c33e09a4ca7da1f9ec81020cfb978 /util-linux | |
parent | 2dade4f18a86d05642aa6f3ef4c5b5100fd10907 (diff) | |
download | busybox-w32-294d0c85adcbcf48da1fc0f48dae3aed59c07436.tar.gz busybox-w32-294d0c85adcbcf48da1fc0f48dae3aed59c07436.tar.bz2 busybox-w32-294d0c85adcbcf48da1fc0f48dae3aed59c07436.zip |
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.c | 15 |
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) | |||
186 | } else { | 186 | } else { |
187 | if (cols == 0) | 187 | if (cols == 0) |
188 | cols = (opt & OPT_i) ? 12 : 16; | 188 | cols = (opt & OPT_i) ? 12 : 16; |
189 | if (opt & OPT_i) | 189 | if (opt & OPT_i) { |
190 | bytes = 1; /* -i ignores -gN */ | 190 | bytes = 1; // -i ignores -gN |
191 | else | 191 | // output is " 0xXX, 0xXX, 0xXX...", add leading space |
192 | bb_dump_add(dumper, "\" \""); | ||
193 | } else | ||
192 | bb_dump_add(dumper, "\"%08.8_ax: \""); // "address: " | 194 | bb_dump_add(dumper, "\"%08.8_ax: \""); // "address: " |
193 | } | 195 | } |
194 | 196 | ||
@@ -197,14 +199,15 @@ int xxd_main(int argc UNUSED_PARAM, char **argv) | |||
197 | } | 199 | } |
198 | 200 | ||
199 | if (bytes < 1 || bytes >= cols) { | 201 | if (bytes < 1 || bytes >= cols) { |
200 | sprintf(buf, "%u/1 \"%%02x\"", cols); // cols * "xx" | 202 | sprintf(buf, "%u/1 \"%%02x\"", cols); // cols * "XX" |
201 | bb_dump_add(dumper, buf); | 203 | bb_dump_add(dumper, buf); |
202 | } | 204 | } |
203 | else if (bytes == 1) { | 205 | else if (bytes == 1) { |
204 | if (opt & OPT_i) | 206 | if (opt & OPT_i) |
205 | sprintf(buf, "%u/1 \" 0x%%02x,\"", cols); // cols * " 0xxx," | 207 | sprintf(buf, "%u/1 \" 0x%%02x,\"", cols); // cols * " 0xXX," |
208 | //TODO: compat: omit the last comma after the very last byte | ||
206 | else | 209 | else |
207 | sprintf(buf, "%u/1 \"%%02x \"", cols); // cols * "xx " | 210 | sprintf(buf, "%u/1 \"%%02x \"", cols); // cols * "XX " |
208 | bb_dump_add(dumper, buf); | 211 | bb_dump_add(dumper, buf); |
209 | } | 212 | } |
210 | else { | 213 | else { |