diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-26 12:56:17 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-26 12:56:17 +0200 |
commit | 60d4d55b870757089cdae96920cf6c416ba2de37 (patch) | |
tree | ca1883766cb079e79b41a537580fa3d171cda65a | |
parent | 3c6f6382eef14b880550cbf28ac5a517d0a075fc (diff) | |
download | busybox-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.c | 4 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 43 | ||||
-rwxr-xr-x | testsuite/od.tests | 44 |
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" |
91 | SKIP= | 91 | SKIP= |
92 | 92 | ||
93 | optional !DESKTOP #DESKTOP: unrecognized option: D | ||
94 | $le || SKIP=1 | 93 | $le || SKIP=1 |
95 | testing "od -D (!DESKTOP little-endian)" \ | 94 | testing "od -D (little-endian)" \ |
96 | "od -D" \ | 95 | "od -D" \ |
97 | "\ | 96 | "\ |
98 | 0000000 167969281 4265820737 | 97 | 0000000 167969281 4265820737 |
@@ -133,9 +132,8 @@ testing "od -f (little-endian)" \ | |||
133 | "" "$input" | 132 | "" "$input" |
134 | SKIP= | 133 | SKIP= |
135 | 134 | ||
136 | optional !DESKTOP #DESKTOP: unrecognized option: H | ||
137 | $le || SKIP=1 | 135 | $le || SKIP=1 |
138 | testing "od -H (!DESKTOP little-endian)" \ | 136 | testing "od -H (little-endian)" \ |
139 | "od -H" \ | 137 | "od -H" \ |
140 | "\ | 138 | "\ |
141 | 0000000 0a030201 fe434241 | 139 | 0000000 0a030201 fe434241 |
@@ -144,9 +142,8 @@ testing "od -H (!DESKTOP little-endian)" \ | |||
144 | "" "$input" | 142 | "" "$input" |
145 | SKIP= | 143 | SKIP= |
146 | 144 | ||
147 | optional !DESKTOP #DESKTOP: unrecognized option: X | ||
148 | $le || SKIP=1 | 145 | $le || SKIP=1 |
149 | testing "od -X (!DESKTOP little-endian)" \ | 146 | testing "od -X (little-endian)" \ |
150 | "od -X" \ | 147 | "od -X" \ |
151 | "\ | 148 | "\ |
152 | 0000000 0a030201 fe434241 | 149 | 0000000 0a030201 fe434241 |
@@ -175,51 +172,42 @@ testing "od -x (little-endian)" \ | |||
175 | "" "$input" | 172 | "" "$input" |
176 | SKIP= | 173 | SKIP= |
177 | 174 | ||
178 | optional !DESKTOP #DESKTOP: unrecognized option: I | ||
179 | $le || SKIP=1 | 175 | $le || SKIP=1 |
180 | testing "od -I (!DESKTOP little-endian)" \ | 176 | testing "od -i (little-endian)" \ |
181 | "od -I" \ | 177 | "od -i" \ |
182 | "\ | 178 | "\ |
183 | 0000000 -125183517527965183 | 179 | 0000000 167969281 -29146559 |
184 | 0000010 | 180 | 0000010 |
185 | " \ | 181 | " \ |
186 | "" "$input" | 182 | "" "$input" |
187 | SKIP= | 183 | SKIP= |
188 | 184 | ||
189 | optional !DESKTOP #DESKTOP: unrecognized option: L | ||
190 | $le || SKIP=1 | 185 | $le || SKIP=1 |
191 | testing "od -L (!DESKTOP little-endian)" \ | 186 | testing "od -O (little-endian)" \ |
192 | "od -L" \ | 187 | "od -O" \ |
193 | "\ | 188 | "\ |
194 | 0000000 -125183517527965183 | 189 | 0000000 01200601001 37620641101 |
195 | 0000010 | 190 | 0000010 |
196 | " \ | 191 | " \ |
197 | "" "$input" | 192 | "" "$input" |
198 | SKIP= | 193 | SKIP= |
199 | 194 | ||
195 | # This probably also depends on word width of the arch (what is "long"?) | ||
200 | $le || SKIP=1 | 196 | $le || SKIP=1 |
201 | testing "od -i (little-endian)" \ | 197 | testing "od -I (little-endian)" \ |
202 | "od -i" \ | 198 | "od -I" \ |
203 | "\ | 199 | "\ |
204 | 0000000 167969281 -29146559 | 200 | 0000000 -125183517527965183 |
205 | 0000010 | 201 | 0000010 |
206 | " \ | 202 | " \ |
207 | "" "$input" | 203 | "" "$input" |
208 | SKIP= | 204 | testing "od -L (little-endian)" \ |
209 | 205 | "od -L" \ | |
210 | optional !DESKTOP #DESKTOP: unrecognized option: O | ||
211 | $le || SKIP=1 | ||
212 | testing "od -O (!DESKTOP little-endian)" \ | ||
213 | "od -O" \ | ||
214 | "\ | 206 | "\ |
215 | 0000000 01200601001 37620641101 | 207 | 0000000 -125183517527965183 |
216 | 0000010 | 208 | 0000010 |
217 | " \ | 209 | " \ |
218 | "" "$input" | 210 | "" "$input" |
219 | SKIP= | ||
220 | |||
221 | # This probably also depends on word width of the arch (what is "long"?) | ||
222 | $le || SKIP=1 | ||
223 | testing "od -l (little-endian)" \ | 211 | testing "od -l (little-endian)" \ |
224 | "od -l" \ | 212 | "od -l" \ |
225 | "\ | 213 | "\ |