diff options
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 { |