[git commit] od: correct -i, enable tests which pass for DESKTOP too

Denys Vlasenko vda.linux at googlemail.com
Thu May 25 17:51:37 UTC 2023


commit: https://git.busybox.net/busybox/commit/?id=ce4cfc33cade63513963f9d5e701f305cbdfe693
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
.rodata                                           105302  105305      +3

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/od.c        |  2 ++
 coreutils/od_bloaty.c |  6 +++--
 testsuite/od.tests    | 62 +++++++++++++++++++++++++++------------------------
 3 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/coreutils/od.c b/coreutils/od.c
index 6d562ea91..bd82487e5 100644
--- a/coreutils/od.c
+++ b/coreutils/od.c
@@ -167,6 +167,8 @@ static const char *const add_strings[] ALIGN_PTR = {
 	"4/4 \"%15.7e \" \"\\n\"",             /* 7: f */
 	"4/4 \"%08x \" \"\\n\"",               /* 8: H, X */
 	"8/2 \"%04x \" \"\\n\"",               /* 9: h, x */
+	/* This probably also depends on word width of the arch (what is "long"?) */
+	/* should be "2/8" or "4/4" depending on sizeof(long)? */
 	"2/8 \"%20lld \" \"\\n\"",             /* 10: I, L, l */
 	"4/4 \"%11d \" \"\\n\"",               /* 11: i */
 	"4/4 \"%011o \" \"\\n\"",              /* 12: O */
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 5b5e56a21..51fff436b 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -1245,9 +1245,11 @@ int od_main(int argc UNUSED_PARAM, char **argv)
 	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_i) decode_format_string("d2");
+	if (opt & OPT_i) decode_format_string("dI");
 	if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes);
-	if (opt & OPT_l) decode_format_string("d4");
+	/* 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");
 	while (lst_t) {
 		decode_format_string(llist_pop(&lst_t));
diff --git a/testsuite/od.tests b/testsuite/od.tests
index 500e0e638..fa6745b78 100755
--- a/testsuite/od.tests
+++ b/testsuite/od.tests
@@ -12,10 +12,10 @@ le=false
 { printf '\0\1' | od -s | grep -q 256; } && le=true
 readonly le
 
-# NB:
+# NB: for !DESKTOP,
 # sed 's/ *$//' truncates trailing spaces.
-# This needs to be fixed properly (not output them).
-# For now, the tests ignore them (does not require a match).
+# This needs to be fixed properly (by not outputting them).
+# For now, the tests ignore them (do not require a match).
 
 optional !DESKTOP
 testing "od -a (!DESKTOP)" \
@@ -26,8 +26,19 @@ testing "od -a (!DESKTOP)" \
 " \
 	"" "$input"
 SKIP=
+# ^^^ a bit incorrect handling of ctrl/high bytes.
+# vvv this output is correct.
+optional DESKTOP
+testing "od -a (DESKTOP)" \
+        "od -a" \
+"\
+0000000 soh stx etx  nl   A   B   C   ~
+0000010
+" \
+	"" "$input"
+SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: B
 testing "od -B (!DESKTOP)" \
         "od -B | sed 's/ *$//'" \
 "\
@@ -37,9 +48,8 @@ testing "od -B (!DESKTOP)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
 $le || SKIP=1
-testing "od -o (!DESKTOP little-endian)" \
+testing "od -o (little-endian)" \
         "od -o | sed 's/ *$//'" \
 "\
 0000000 001001 005003 041101 177103
@@ -48,8 +58,7 @@ testing "od -o (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
-testing "od -b (!DESKTOP)" \
+testing "od -b" \
         "od -b | sed 's/ *$//'" \
 "\
 0000000 001 002 003 012 101 102 103 376
@@ -58,8 +67,7 @@ testing "od -b (!DESKTOP)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
-testing "od -c (!DESKTOP)" \
+testing "od -c" \
         "od -c | sed 's/ *$//'" \
 "\
 0000000 001 002 003  \\\\n   A   B   C 376
@@ -68,9 +76,8 @@ testing "od -c (!DESKTOP)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
 $le || SKIP=1
-testing "od -d (!DESKTOP little-endian)" \
+testing "od -d (little-endian)" \
         "od -d | sed 's/ *$//'" \
 "\
 0000000   513  2563 16961 65091
@@ -79,7 +86,7 @@ testing "od -d (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: D
 $le || SKIP=1
 testing "od -D (!DESKTOP little-endian)" \
         "od -D | sed 's/ *$//'" \
@@ -90,7 +97,7 @@ testing "od -D (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: e
 $le || SKIP=1
 testing "od -e (!DESKTOP little-endian)" \
         "od -e | sed 's/ *$//'" \
@@ -101,7 +108,7 @@ testing "od -e (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: F
 $le || SKIP=1
 testing "od -F (!DESKTOP little-endian)" \
         "od -F | sed 's/ *$//'" \
@@ -111,7 +118,7 @@ testing "od -F (!DESKTOP little-endian)" \
 " \
 	"" "$input"
 
-optional !DESKTOP
+#optional !DESKTOP
 $le || SKIP=1
 testing "od -f (!DESKTOP little-endian)" \
         "od -f | sed 's/ *$//'" \
@@ -122,7 +129,7 @@ testing "od -f (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: H
 $le || SKIP=1
 testing "od -H (!DESKTOP little-endian)" \
         "od -H | sed 's/ *$//'" \
@@ -133,7 +140,7 @@ testing "od -H (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: X
 $le || SKIP=1
 testing "od -X (!DESKTOP little-endian)" \
         "od -X | sed 's/ *$//'" \
@@ -144,9 +151,8 @@ testing "od -X (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
 $le || SKIP=1
-testing "od -h (!DESKTOP little-endian)" \
+testing "od -h (little-endian)" \
         "od -h | sed 's/ *$//'" \
 "\
 0000000 0201 0a03 4241 fe43
@@ -155,9 +161,8 @@ testing "od -h (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
 $le || SKIP=1
-testing "od -x (!DESKTOP little-endian)" \
+testing "od -x (little-endian)" \
         "od -x | sed 's/ *$//'" \
 "\
 0000000 0201 0a03 4241 fe43
@@ -166,7 +171,7 @@ testing "od -x (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: I
 $le || SKIP=1
 testing "od -I (!DESKTOP little-endian)" \
         "od -I | sed 's/ *$//'" \
@@ -177,7 +182,7 @@ testing "od -I (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: L
 $le || SKIP=1
 testing "od -L (!DESKTOP little-endian)" \
         "od -L | sed 's/ *$//'" \
@@ -188,9 +193,8 @@ testing "od -L (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
 $le || SKIP=1
-testing "od -i (!DESKTOP little-endian)" \
+testing "od -i (little-endian)" \
         "od -i | sed 's/ *$//'" \
 "\
 0000000   167969281   -29146559
@@ -199,7 +203,7 @@ testing "od -i (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+optional !DESKTOP  #DESKTOP: unrecognized option: O
 $le || SKIP=1
 testing "od -O (!DESKTOP little-endian)" \
         "od -O | sed 's/ *$//'" \
@@ -210,9 +214,9 @@ testing "od -O (!DESKTOP little-endian)" \
 	"" "$input"
 SKIP=
 
-optional !DESKTOP
+# This probably also depends on word width of the arch (what is "long"?)
 $le || SKIP=1
-testing "od -l (!DESKTOP little-endian)" \
+testing "od -l (little-endian)" \
         "od -l | sed 's/ *$//'" \
 "\
 0000000  -125183517527965183


More information about the busybox-cvs mailing list