unzip: better match for "standard" unzip's output; string shrinkage
function old new delta unzip_main 2490 2426 -64 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-64) Total: -64 bytes text data bss dec hex filename 924008 906 17160 942074 e5ffa busybox_old 923846 906 17160 941912 e5f58 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
bca4deee83
commit
07bd979921
@ -514,11 +514,11 @@ int unzip_main(int argc, char **argv)
|
|||||||
printf("Archive: %s\n", src_fn);
|
printf("Archive: %s\n", src_fn);
|
||||||
if (listing) {
|
if (listing) {
|
||||||
puts(verbose ?
|
puts(verbose ?
|
||||||
" Length Method Size Ratio Date Time CRC-32 Name\n"
|
" Length Method Size Cmpr Date Time CRC-32 Name\n"
|
||||||
"-------- ------ ------- ----- ---- ---- ------ ----"
|
"-------- ------ ------- ---- ---------- ----- -------- ----"
|
||||||
:
|
:
|
||||||
" Length Date Time Name\n"
|
" Length Date Time Name\n"
|
||||||
" -------- ---- ---- ----"
|
"--------- ---------- ----- ----"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -643,16 +643,20 @@ int unzip_main(int argc, char **argv)
|
|||||||
if (listing) {
|
if (listing) {
|
||||||
/* List entry */
|
/* List entry */
|
||||||
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
||||||
if (!verbose) {
|
char dtbuf[sizeof("mm-dd-yyyy hh:mm")];
|
||||||
// " Length Date Time Name\n"
|
sprintf(dtbuf, "%02u-%02u-%04u %02u:%02u",
|
||||||
// " -------- ---- ---- ----"
|
|
||||||
printf( "%9u %02u-%02u-%02u %02u:%02u %s\n",
|
|
||||||
(unsigned)zip_header.formatted.ucmpsize,
|
|
||||||
(dostime & 0x01e00000) >> 21,
|
(dostime & 0x01e00000) >> 21,
|
||||||
(dostime & 0x001f0000) >> 16,
|
(dostime & 0x001f0000) >> 16,
|
||||||
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
|
((dostime & 0xfe000000) >> 25) + 1980,
|
||||||
(dostime & 0x0000f800) >> 11,
|
(dostime & 0x0000f800) >> 11,
|
||||||
(dostime & 0x000007e0) >> 5,
|
(dostime & 0x000007e0) >> 5
|
||||||
|
);
|
||||||
|
if (!verbose) {
|
||||||
|
// " Length Date Time Name\n"
|
||||||
|
// "--------- ---------- ----- ----"
|
||||||
|
printf( "%9u " "%s " "%s\n",
|
||||||
|
(unsigned)zip_header.formatted.ucmpsize,
|
||||||
|
dtbuf,
|
||||||
dst_fn);
|
dst_fn);
|
||||||
} else {
|
} else {
|
||||||
unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize;
|
unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize;
|
||||||
@ -661,9 +665,9 @@ int unzip_main(int argc, char **argv)
|
|||||||
percents = percents * 100;
|
percents = percents * 100;
|
||||||
if (zip_header.formatted.ucmpsize)
|
if (zip_header.formatted.ucmpsize)
|
||||||
percents /= zip_header.formatted.ucmpsize;
|
percents /= zip_header.formatted.ucmpsize;
|
||||||
// " Length Method Size Ratio Date Time CRC-32 Name\n"
|
// " Length Method Size Cmpr Date Time CRC-32 Name\n"
|
||||||
// "-------- ------ ------- ----- ---- ---- ------ ----"
|
// "-------- ------ ------- ---- ---------- ----- -------- ----"
|
||||||
printf( "%8u %s" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n",
|
printf( "%8u %s" "%9u%4u%% " "%s " "%08x " "%s\n",
|
||||||
(unsigned)zip_header.formatted.ucmpsize,
|
(unsigned)zip_header.formatted.ucmpsize,
|
||||||
zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */
|
zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */
|
||||||
/* TODO: show other methods?
|
/* TODO: show other methods?
|
||||||
@ -681,11 +685,7 @@ int unzip_main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
(unsigned)zip_header.formatted.cmpsize,
|
(unsigned)zip_header.formatted.cmpsize,
|
||||||
(unsigned)percents,
|
(unsigned)percents,
|
||||||
(dostime & 0x01e00000) >> 21,
|
dtbuf,
|
||||||
(dostime & 0x001f0000) >> 16,
|
|
||||||
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
|
|
||||||
(dostime & 0x0000f800) >> 11,
|
|
||||||
(dostime & 0x000007e0) >> 5,
|
|
||||||
zip_header.formatted.crc32,
|
zip_header.formatted.crc32,
|
||||||
dst_fn);
|
dst_fn);
|
||||||
total_size += zip_header.formatted.cmpsize;
|
total_size += zip_header.formatted.cmpsize;
|
||||||
@ -793,21 +793,25 @@ int unzip_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (listing && quiet <= 1) {
|
if (listing && quiet <= 1) {
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
// " Length Date Time Name\n"
|
// " Length Date Time Name\n"
|
||||||
// " -------- ---- ---- ----"
|
// "--------- ---------- ----- ----"
|
||||||
printf( " -------- -------\n"
|
printf( " --------%21s" "-------\n"
|
||||||
"%9lu" " %u files\n",
|
"%9lu%21s" "%u files\n",
|
||||||
total_usize, total_entries);
|
"",
|
||||||
|
total_usize, "", total_entries);
|
||||||
} else {
|
} else {
|
||||||
unsigned long percents = total_usize - total_size;
|
unsigned long percents = total_usize - total_size;
|
||||||
|
if ((long)percents < 0)
|
||||||
|
percents = 0; /* happens if usize < size */
|
||||||
percents = percents * 100;
|
percents = percents * 100;
|
||||||
if (total_usize)
|
if (total_usize)
|
||||||
percents /= total_usize;
|
percents /= total_usize;
|
||||||
// " Length Method Size Ratio Date Time CRC-32 Name\n"
|
// " Length Method Size Cmpr Date Time CRC-32 Name\n"
|
||||||
// "-------- ------ ------- ----- ---- ---- ------ ----"
|
// "-------- ------ ------- ---- ---------- ----- -------- ----"
|
||||||
printf( "-------- ------- --- -------\n"
|
printf( "-------- ------- ----%28s" "----\n"
|
||||||
"%8lu" "%17lu%4u%% %u files\n",
|
"%8lu" "%17lu%4u%%%28s" "%u files\n",
|
||||||
total_usize, total_size, (unsigned)percents,
|
"",
|
||||||
|
total_usize, total_size, (unsigned)percents, "",
|
||||||
total_entries);
|
total_entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user