diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-24 12:28:03 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-24 12:28:03 +0000 |
commit | bcb66ec22e82f6b1ab93f3aec917269393a5b464 (patch) | |
tree | 3d48b319dfbb959d465a1378bc984826640d1ed9 | |
parent | 1da77728d75884b7dd1a02ca3ab89d5313d8e9fd (diff) | |
download | busybox-w32-bcb66ec22e82f6b1ab93f3aec917269393a5b464.tar.gz busybox-w32-bcb66ec22e82f6b1ab93f3aec917269393a5b464.tar.bz2 busybox-w32-bcb66ec22e82f6b1ab93f3aec917269393a5b464.zip |
od: shrink a bit
verbose 12 13 +1
open_next_file 102 99 -3
limit_bytes_to_format 4 1 -3
ioerror 4 1 -3
flag_pseudo_start 4 1 -3
flag_dump_strings 4 1 -3
abbreviate_duplicate_blocks 4 - -4
check_and_close 96 90 -6
od_main 2988 2955 -33
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/7 up/down: 1/-58) Total: -57 bytes
text data bss dec hex filename
781314 1328 11876 794518 c1f96 busybox_old
781266 1328 11844 794438 c1f46 busybox_unstripped
-rw-r--r-- | coreutils/od_bloaty.c | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index 335efe7ca..0b77f8b94 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -153,7 +153,6 @@ static const signed char width_bytes[] = { | |||
153 | sizeof(double), | 153 | sizeof(double), |
154 | sizeof(longdouble_t) | 154 | sizeof(longdouble_t) |
155 | }; | 155 | }; |
156 | |||
157 | /* Ensure that for each member of 'enum size_spec' there is an | 156 | /* Ensure that for each member of 'enum size_spec' there is an |
158 | initializer in the width_bytes array. */ | 157 | initializer in the width_bytes array. */ |
159 | struct dummy { | 158 | struct dummy { |
@@ -161,42 +160,37 @@ struct dummy { | |||
161 | [ARRAY_SIZE(width_bytes) == N_SIZE_SPECS ? 1 : -1]; | 160 | [ARRAY_SIZE(width_bytes) == N_SIZE_SPECS ? 1 : -1]; |
162 | }; | 161 | }; |
163 | 162 | ||
163 | static smallint flag_dump_strings; | ||
164 | /* Non-zero if an old-style 'pseudo-address' was specified. */ | ||
165 | static smallint flag_pseudo_start; | ||
166 | static smallint limit_bytes_to_format; | ||
167 | /* When zero and two or more consecutive blocks are equal, format | ||
168 | only the first block and output an asterisk alone on the following | ||
169 | line to indicate that identical blocks have been elided. */ | ||
170 | static smallint verbose; | ||
171 | static smallint ioerror; | ||
172 | |||
164 | static size_t string_min; | 173 | static size_t string_min; |
165 | static int flag_dump_strings; | ||
166 | 174 | ||
167 | /* Non-zero if an old-style 'pseudo-address' was specified. */ | 175 | /* An array of specs describing how to format each input block. */ |
168 | static int flag_pseudo_start; | 176 | static size_t n_specs; |
177 | static struct tspec *spec; | ||
169 | 178 | ||
179 | /* Function that accepts an address and an optional following char, | ||
180 | and prints the address and char to stdout. */ | ||
181 | static void (*format_address)(off_t, char); | ||
170 | /* The difference between the old-style pseudo starting address and | 182 | /* The difference between the old-style pseudo starting address and |
171 | the number of bytes to skip. */ | 183 | the number of bytes to skip. */ |
172 | static off_t pseudo_offset; | 184 | static off_t pseudo_offset; |
173 | |||
174 | /* Function that accepts an address and an optional following char, | ||
175 | and prints the address and char to stdout. */ | ||
176 | static void (*format_address) (off_t, char); | ||
177 | |||
178 | /* The number of input bytes to skip before formatting and writing. */ | 185 | /* The number of input bytes to skip before formatting and writing. */ |
179 | static off_t n_bytes_to_skip; // = 0; | 186 | static off_t n_bytes_to_skip; |
180 | |||
181 | /* When zero, MAX_BYTES_TO_FORMAT and END_OFFSET are ignored, and all | 187 | /* When zero, MAX_BYTES_TO_FORMAT and END_OFFSET are ignored, and all |
182 | input is formatted. */ | 188 | input is formatted. */ |
183 | static int limit_bytes_to_format; // = 0; | ||
184 | |||
185 | /* The maximum number of bytes that will be formatted. */ | 189 | /* The maximum number of bytes that will be formatted. */ |
186 | static off_t max_bytes_to_format; | 190 | static off_t max_bytes_to_format; |
187 | |||
188 | /* The offset of the first byte after the last byte to be formatted. */ | 191 | /* The offset of the first byte after the last byte to be formatted. */ |
189 | static off_t end_offset; | 192 | static off_t end_offset; |
190 | 193 | ||
191 | /* When nonzero and two or more consecutive blocks are equal, format | ||
192 | only the first block and output an asterisk alone on the following | ||
193 | line to indicate that identical blocks have been elided. */ | ||
194 | static int abbreviate_duplicate_blocks = 1; | ||
195 | |||
196 | /* An array of specs describing how to format each input block. */ | ||
197 | static size_t n_specs; | ||
198 | static struct tspec *spec; | ||
199 | |||
200 | /* The number of input bytes formatted per output line. It must be | 194 | /* The number of input bytes formatted per output line. It must be |
201 | a multiple of the least common multiple of the sizes associated with | 195 | a multiple of the least common multiple of the sizes associated with |
202 | the specified output types. It should be as large as possible, but | 196 | the specified output types. It should be as large as possible, but |
@@ -217,8 +211,6 @@ static char const *const default_file_list[] = { "-", NULL }; | |||
217 | /* The input stream associated with the current file. */ | 211 | /* The input stream associated with the current file. */ |
218 | static FILE *in_stream; | 212 | static FILE *in_stream; |
219 | 213 | ||
220 | static int ioerror; | ||
221 | |||
222 | #define MAX_INTEGRAL_TYPE_SIZE sizeof(ulonglong_t) | 214 | #define MAX_INTEGRAL_TYPE_SIZE sizeof(ulonglong_t) |
223 | static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] = { | 215 | static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] = { |
224 | [sizeof(char)] = CHAR, | 216 | [sizeof(char)] = CHAR, |
@@ -907,8 +899,7 @@ write_block(off_t current_offset, size_t n_bytes, | |||
907 | static char prev_pair_equal = 0; | 899 | static char prev_pair_equal = 0; |
908 | size_t i; | 900 | size_t i; |
909 | 901 | ||
910 | if (abbreviate_duplicate_blocks | 902 | if (!verbose && !first |
911 | && !first | ||
912 | && n_bytes == bytes_per_block | 903 | && n_bytes == bytes_per_block |
913 | && memcmp(prev_block, curr_block, bytes_per_block) == 0 | 904 | && memcmp(prev_block, curr_block, bytes_per_block) == 0 |
914 | ) { | 905 | ) { |
@@ -1261,7 +1252,7 @@ int od_main(int argc, char **argv) | |||
1261 | format_address = format_address_std; | 1252 | format_address = format_address_std; |
1262 | address_base_char = 'o'; | 1253 | address_base_char = 'o'; |
1263 | address_pad_len_char = '7'; | 1254 | address_pad_len_char = '7'; |
1264 | flag_dump_strings = 0; | 1255 | /* flag_dump_strings = 0; - already is */ |
1265 | 1256 | ||
1266 | /* Parse command line */ | 1257 | /* Parse command line */ |
1267 | opt_complementary = "t::"; // list | 1258 | opt_complementary = "t::"; // list |
@@ -1314,7 +1305,7 @@ int od_main(int argc, char **argv) | |||
1314 | decode_format_string(lst_t->data); | 1305 | decode_format_string(lst_t->data); |
1315 | lst_t = lst_t->link; | 1306 | lst_t = lst_t->link; |
1316 | } | 1307 | } |
1317 | if (opt & OPT_v) abbreviate_duplicate_blocks = 0; | 1308 | if (opt & OPT_v) verbose = 1; |
1318 | if (opt & OPT_x) decode_format_string("x2"); | 1309 | if (opt & OPT_x) decode_format_string("x2"); |
1319 | if (opt & OPT_s) decode_format_string("d2"); | 1310 | if (opt & OPT_s) decode_format_string("d2"); |
1320 | if (opt & OPT_S) { | 1311 | if (opt & OPT_S) { |
@@ -1458,5 +1449,5 @@ int od_main(int argc, char **argv) | |||
1458 | if (fclose(stdin) == EOF) | 1449 | if (fclose(stdin) == EOF) |
1459 | bb_perror_msg_and_die(bb_msg_standard_input); | 1450 | bb_perror_msg_and_die(bb_msg_standard_input); |
1460 | 1451 | ||
1461 | return (ioerror != 0); /* err != 0 - return 1 (failure) */ | 1452 | return ioerror; |
1462 | } | 1453 | } |