aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 12:56:17 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 12:56:17 +0200
commit60d4d55b870757089cdae96920cf6c416ba2de37 (patch)
treeca1883766cb079e79b41a537580fa3d171cda65a
parent3c6f6382eef14b880550cbf28ac5a517d0a075fc (diff)
downloadbusybox-w32-60d4d55b870757089cdae96920cf6c416ba2de37.tar.gz
busybox-w32-60d4d55b870757089cdae96920cf6c416ba2de37.tar.bz2
busybox-w32-60d4d55b870757089cdae96920cf6c416ba2de37.zip
od: support -DOHXIL
function old new delta od_main 1866 1917 +51 .rodata 105306 105321 +15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 66/0) Total: 66 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/od.c4
-rw-r--r--coreutils/od_bloaty.c43
-rwxr-xr-xtestsuite/od.tests44
3 files changed, 46 insertions, 45 deletions
diff --git a/coreutils/od.c b/coreutils/od.c
index 46aba5a7c..98ae06ba7 100644
--- a/coreutils/od.c
+++ b/coreutils/od.c
@@ -22,7 +22,9 @@
22 22
23//usage:#if !ENABLE_DESKTOP 23//usage:#if !ENABLE_DESKTOP
24//usage:#define od_trivial_usage 24//usage:#define od_trivial_usage
25//usage: "[-aBbcDdeFfHhIiLlOoXxsv] [FILE]" 25//usage: "[-abcdeFfhIiLloxsv] [FILE]"
26// We also support -BDOHXIL, but they are not documented in coreutils 9.1
27// manpage/help, so don't show them either.
26//usage:#define od_full_usage "\n\n" 28//usage:#define od_full_usage "\n\n"
27//usage: "Print FILE (or stdin) unambiguously, as octal bytes by default" 29//usage: "Print FILE (or stdin) unambiguously, as octal bytes by default"
28//usage:#endif 30//usage:#endif
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 57a4fe163..2782adbf6 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -27,6 +27,8 @@
27//usage:#if ENABLE_DESKTOP 27//usage:#if ENABLE_DESKTOP
28//usage:#define od_trivial_usage 28//usage:#define od_trivial_usage
29//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE]..." 29//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE]..."
30// We also support -BDOHXIL, but they are not documented in coreutils 9.1
31// manpage/help, so don't show them either.
30// We don't support: 32// We don't support:
31// ... [FILE] [[+]OFFSET[.][b]] 33// ... [FILE] [[+]OFFSET[.][b]]
32// Support is buggy for: 34// Support is buggy for:
@@ -43,27 +45,33 @@ enum {
43 OPT_b = 1 << 3, 45 OPT_b = 1 << 3,
44 OPT_c = 1 << 4, 46 OPT_c = 1 << 4,
45 OPT_d = 1 << 5, 47 OPT_d = 1 << 5,
46 OPT_f = 1 << 6, 48 OPT_D = 1 << 6, /* undocumented in coreutils 9.1 */
47 OPT_h = 1 << 7, 49 OPT_f = 1 << 7,
48 OPT_i = 1 << 8, 50 OPT_h = 1 << 8,
49 OPT_j = 1 << 9, 51 OPT_H = 1 << 9, /* undocumented in coreutils 9.1 */
50 OPT_l = 1 << 10, 52 OPT_i = 1 << 10,
51 OPT_o = 1 << 11, 53 OPT_I = 1 << 11, /* undocumented in coreutils 9.1 */
52 OPT_B = 1 << 12, /* undocumented synonym to -o */ 54 OPT_j = 1 << 12,
53 OPT_t = 1 << 13, 55 OPT_l = 1 << 13,
56 OPT_L = 1 << 14, /* undocumented in coreutils 9.1 */
57 OPT_o = 1 << 15,
58 OPT_O = 1 << 16, /* undocumented in coreutils 9.1 */
59 OPT_B = 1 << 17, /* undocumented synonym to -o */
60 OPT_t = 1 << 18,
54 /* When zero and two or more consecutive blocks are equal, format 61 /* When zero and two or more consecutive blocks are equal, format
55 only the first block and output an asterisk alone on the following 62 only the first block and output an asterisk alone on the following
56 line to indicate that identical blocks have been elided: */ 63 line to indicate that identical blocks have been elided: */
57 OPT_v = 1 << 14, 64 OPT_v = 1 << 19,
58 OPT_x = 1 << 15, 65 OPT_x = 1 << 20,
59 OPT_s = 1 << 16, 66 OPT_X = 1 << 21, /* undocumented in coreutils 9.1 */
60 OPT_S = 1 << 17, 67 OPT_s = 1 << 22,
61 OPT_w = 1 << 18, 68 OPT_S = 1 << 23,
62 OPT_traditional = (1 << 19) * ENABLE_LONG_OPTS, 69 OPT_w = 1 << 24,
70 OPT_traditional = (1 << 25) * ENABLE_LONG_OPTS,
63}; 71};
64 72
65#define OD_GETOPT32() getopt32long(argv, \ 73#define OD_GETOPT32() getopt32long(argv, \
66 "A:N:abcdfhij:loBt:*vxsS:w:+:", od_longopts, \ 74 "A:N:abcdDfhHiIj:lLoOBt:*vxXsS:w:+:", od_longopts, \
67 /* -w with optional param */ \ 75 /* -w with optional param */ \
68 /* -S was -s and also had optional parameter */ \ 76 /* -S was -s and also had optional parameter */ \
69 /* but in coreutils 6.3 it was renamed and now has */ \ 77 /* but in coreutils 6.3 it was renamed and now has */ \
@@ -1245,14 +1253,17 @@ int od_main(int argc UNUSED_PARAM, char **argv)
1245 if (opt & OPT_b) decode_format_string("oC"); 1253 if (opt & OPT_b) decode_format_string("oC");
1246 if (opt & OPT_c) decode_format_string("c"); 1254 if (opt & OPT_c) decode_format_string("c");
1247 if (opt & OPT_d) decode_format_string("u2"); 1255 if (opt & OPT_d) decode_format_string("u2");
1256 if (opt & OPT_D) decode_format_string("uI");
1248 if (opt & OPT_f) decode_format_string("fF"); 1257 if (opt & OPT_f) decode_format_string("fF");
1249 if (opt & (OPT_h|OPT_x)) decode_format_string("x2"); 1258 if (opt & (OPT_h|OPT_x)) decode_format_string("x2");
1259 if (opt & (OPT_H|OPT_X)) decode_format_string("xI");
1250 if (opt & OPT_i) decode_format_string("dI"); 1260 if (opt & OPT_i) decode_format_string("dI");
1251 if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes); 1261 if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes);
1252 /* This probably also depends on word width of the arch (what is "long"?) */ 1262 /* This probably also depends on word width of the arch (what is "long"?) */
1253 /* should be "d4" or "d8" depending on sizeof(long)? */ 1263 /* should be "d4" or "d8" depending on sizeof(long)? */
1254 if (opt & OPT_l) decode_format_string("d8"); 1264 if (opt & (OPT_I|OPT_l|OPT_L)) decode_format_string("d8");
1255 if (opt & (OPT_o|OPT_B)) decode_format_string("o2"); 1265 if (opt & (OPT_o|OPT_B)) decode_format_string("o2");
1266 if (opt & OPT_O) decode_format_string("oI");
1256 while (lst_t) { 1267 while (lst_t) {
1257 decode_format_string(llist_pop(&lst_t)); 1268 decode_format_string(llist_pop(&lst_t));
1258 } 1269 }
diff --git a/testsuite/od.tests b/testsuite/od.tests
index d6f50a206..677968967 100755
--- a/testsuite/od.tests
+++ b/testsuite/od.tests
@@ -90,9 +90,8 @@ testing "od -d (little-endian)" \
90 "" "$input" 90 "" "$input"
91SKIP= 91SKIP=
92 92
93optional !DESKTOP #DESKTOP: unrecognized option: D
94$le || SKIP=1 93$le || SKIP=1
95testing "od -D (!DESKTOP little-endian)" \ 94testing "od -D (little-endian)" \
96 "od -D" \ 95 "od -D" \
97"\ 96"\
980000000 167969281 4265820737 970000000 167969281 4265820737
@@ -133,9 +132,8 @@ testing "od -f (little-endian)" \
133 "" "$input" 132 "" "$input"
134SKIP= 133SKIP=
135 134
136optional !DESKTOP #DESKTOP: unrecognized option: H
137$le || SKIP=1 135$le || SKIP=1
138testing "od -H (!DESKTOP little-endian)" \ 136testing "od -H (little-endian)" \
139 "od -H" \ 137 "od -H" \
140"\ 138"\
1410000000 0a030201 fe434241 1390000000 0a030201 fe434241
@@ -144,9 +142,8 @@ testing "od -H (!DESKTOP little-endian)" \
144 "" "$input" 142 "" "$input"
145SKIP= 143SKIP=
146 144
147optional !DESKTOP #DESKTOP: unrecognized option: X
148$le || SKIP=1 145$le || SKIP=1
149testing "od -X (!DESKTOP little-endian)" \ 146testing "od -X (little-endian)" \
150 "od -X" \ 147 "od -X" \
151"\ 148"\
1520000000 0a030201 fe434241 1490000000 0a030201 fe434241
@@ -175,51 +172,42 @@ testing "od -x (little-endian)" \
175 "" "$input" 172 "" "$input"
176SKIP= 173SKIP=
177 174
178optional !DESKTOP #DESKTOP: unrecognized option: I
179$le || SKIP=1 175$le || SKIP=1
180testing "od -I (!DESKTOP little-endian)" \ 176testing "od -i (little-endian)" \
181 "od -I" \ 177 "od -i" \
182"\ 178"\
1830000000 -125183517527965183 1790000000 167969281 -29146559
1840000010 1800000010
185" \ 181" \
186 "" "$input" 182 "" "$input"
187SKIP= 183SKIP=
188 184
189optional !DESKTOP #DESKTOP: unrecognized option: L
190$le || SKIP=1 185$le || SKIP=1
191testing "od -L (!DESKTOP little-endian)" \ 186testing "od -O (little-endian)" \
192 "od -L" \ 187 "od -O" \
193"\ 188"\
1940000000 -125183517527965183 1890000000 01200601001 37620641101
1950000010 1900000010
196" \ 191" \
197 "" "$input" 192 "" "$input"
198SKIP= 193SKIP=
199 194
195# This probably also depends on word width of the arch (what is "long"?)
200$le || SKIP=1 196$le || SKIP=1
201testing "od -i (little-endian)" \ 197testing "od -I (little-endian)" \
202 "od -i" \ 198 "od -I" \
203"\ 199"\
2040000000 167969281 -29146559 2000000000 -125183517527965183
2050000010 2010000010
206" \ 202" \
207 "" "$input" 203 "" "$input"
208SKIP= 204testing "od -L (little-endian)" \
209 205 "od -L" \
210optional !DESKTOP #DESKTOP: unrecognized option: O
211$le || SKIP=1
212testing "od -O (!DESKTOP little-endian)" \
213 "od -O" \
214"\ 206"\
2150000000 01200601001 37620641101 2070000000 -125183517527965183
2160000010 2080000010
217" \ 209" \
218 "" "$input" 210 "" "$input"
219SKIP=
220
221# This probably also depends on word width of the arch (what is "long"?)
222$le || SKIP=1
223testing "od -l (little-endian)" \ 211testing "od -l (little-endian)" \
224 "od -l" \ 212 "od -l" \
225"\ 213"\