[git commit] od: implement -B
Denys Vlasenko
vda.linux at googlemail.com
Thu May 25 20:17:18 UTC 2023
commit: https://git.busybox.net/busybox/commit/?id=6882a933cf078be35f4eb93963365549d43cb497
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
.rodata 105305 105306 +1
od_main 1880 1866 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-14) Total: -13 bytes
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
coreutils/od_bloaty.c | 23 ++++++++++++-----------
testsuite/od.tests | 7 +++----
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 51fff436b..57a4fe163 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -49,20 +49,21 @@ enum {
OPT_j = 1 << 9,
OPT_l = 1 << 10,
OPT_o = 1 << 11,
- OPT_t = 1 << 12,
+ OPT_B = 1 << 12, /* undocumented synonym to -o */
+ OPT_t = 1 << 13,
/* When zero and two or more consecutive blocks are equal, format
only the first block and output an asterisk alone on the following
line to indicate that identical blocks have been elided: */
- OPT_v = 1 << 13,
- OPT_x = 1 << 14,
- OPT_s = 1 << 15,
- OPT_S = 1 << 16,
- OPT_w = 1 << 17,
- OPT_traditional = (1 << 18) * ENABLE_LONG_OPTS,
+ OPT_v = 1 << 14,
+ OPT_x = 1 << 15,
+ OPT_s = 1 << 16,
+ OPT_S = 1 << 17,
+ OPT_w = 1 << 18,
+ OPT_traditional = (1 << 19) * ENABLE_LONG_OPTS,
};
#define OD_GETOPT32() getopt32long(argv, \
- "A:N:abcdfhij:lot:*vxsS:w:+:", od_longopts, \
+ "A:N:abcdfhij:loBt:*vxsS:w:+:", od_longopts, \
/* -w with optional param */ \
/* -S was -s and also had optional parameter */ \
/* but in coreutils 6.3 it was renamed and now has */ \
@@ -1239,22 +1240,22 @@ int od_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_N) {
max_bytes_to_format = xstrtooff_sfx(str_N, 0, bkm_suffixes);
}
+
if (opt & OPT_a) decode_format_string("a");
if (opt & OPT_b) decode_format_string("oC");
if (opt & OPT_c) decode_format_string("c");
if (opt & OPT_d) decode_format_string("u2");
if (opt & OPT_f) decode_format_string("fF");
- if (opt & OPT_h) decode_format_string("x2");
+ if (opt & (OPT_h|OPT_x)) decode_format_string("x2");
if (opt & OPT_i) decode_format_string("dI");
if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes);
/* This probably also depends on word width of the arch (what is "long"?) */
/* should be "d4" or "d8" depending on sizeof(long)? */
if (opt & OPT_l) decode_format_string("d8");
- if (opt & OPT_o) decode_format_string("o2");
+ if (opt & (OPT_o|OPT_B)) decode_format_string("o2");
while (lst_t) {
decode_format_string(llist_pop(&lst_t));
}
- if (opt & OPT_x) decode_format_string("x2");
if (opt & OPT_s) decode_format_string("d2");
if (opt & OPT_S) {
G.string_min = xstrtou_sfx(str_S, 0, bkm_suffixes);
diff --git a/testsuite/od.tests b/testsuite/od.tests
index fa6745b78..29ca829d5 100755
--- a/testsuite/od.tests
+++ b/testsuite/od.tests
@@ -38,8 +38,7 @@ testing "od -a (DESKTOP)" \
"" "$input"
SKIP=
-optional !DESKTOP #DESKTOP: unrecognized option: B
-testing "od -B (!DESKTOP)" \
+testing "od -B" \
"od -B | sed 's/ *$//'" \
"\
0000000 001001 005003 041101 177103
@@ -117,10 +116,10 @@ testing "od -F (!DESKTOP little-endian)" \
0000010
" \
"" "$input"
+SKIP=
-#optional !DESKTOP
$le || SKIP=1
-testing "od -f (!DESKTOP little-endian)" \
+testing "od -f (little-endian)" \
"od -f | sed 's/ *$//'" \
"\
0000000 6.3077975e-33 -6.4885867e+37
More information about the busybox-cvs
mailing list