diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-18 01:43:24 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-18 01:43:24 +0200 |
commit | 07bd9799217038391c8d299e6a2e031fef23c20b (patch) | |
tree | 6cc76423a4d0de144329b0faaf1ff9673a2017ba /archival/unzip.c | |
parent | bca4deee8393395f77630ad320c306d06ea186ed (diff) | |
download | busybox-w32-07bd9799217038391c8d299e6a2e031fef23c20b.tar.gz busybox-w32-07bd9799217038391c8d299e6a2e031fef23c20b.tar.bz2 busybox-w32-07bd9799217038391c8d299e6a2e031fef23c20b.zip |
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>
Diffstat (limited to 'archival/unzip.c')
-rw-r--r-- | archival/unzip.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/archival/unzip.c b/archival/unzip.c index 7bf51f466..a7532e0ff 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -514,11 +514,11 @@ int unzip_main(int argc, char **argv) | |||
514 | printf("Archive: %s\n", src_fn); | 514 | printf("Archive: %s\n", src_fn); |
515 | if (listing) { | 515 | if (listing) { |
516 | puts(verbose ? | 516 | puts(verbose ? |
517 | " Length Method Size Ratio Date Time CRC-32 Name\n" | 517 | " Length Method Size Cmpr Date Time CRC-32 Name\n" |
518 | "-------- ------ ------- ----- ---- ---- ------ ----" | 518 | "-------- ------ ------- ---- ---------- ----- -------- ----" |
519 | : | 519 | : |
520 | " Length Date Time Name\n" | 520 | " Length Date Time Name\n" |
521 | " -------- ---- ---- ----" | 521 | "--------- ---------- ----- ----" |
522 | ); | 522 | ); |
523 | } | 523 | } |
524 | } | 524 | } |
@@ -643,16 +643,20 @@ int unzip_main(int argc, char **argv) | |||
643 | if (listing) { | 643 | if (listing) { |
644 | /* List entry */ | 644 | /* List entry */ |
645 | unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16); | 645 | unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16); |
646 | if (!verbose) { | 646 | char dtbuf[sizeof("mm-dd-yyyy hh:mm")]; |
647 | // " Length Date Time Name\n" | 647 | sprintf(dtbuf, "%02u-%02u-%04u %02u:%02u", |
648 | // " -------- ---- ---- ----" | ||
649 | printf( "%9u %02u-%02u-%02u %02u:%02u %s\n", | ||
650 | (unsigned)zip_header.formatted.ucmpsize, | ||
651 | (dostime & 0x01e00000) >> 21, | 648 | (dostime & 0x01e00000) >> 21, |
652 | (dostime & 0x001f0000) >> 16, | 649 | (dostime & 0x001f0000) >> 16, |
653 | (((dostime & 0xfe000000) >> 25) + 1980) % 100, | 650 | ((dostime & 0xfe000000) >> 25) + 1980, |
654 | (dostime & 0x0000f800) >> 11, | 651 | (dostime & 0x0000f800) >> 11, |
655 | (dostime & 0x000007e0) >> 5, | 652 | (dostime & 0x000007e0) >> 5 |
653 | ); | ||
654 | if (!verbose) { | ||
655 | // " Length Date Time Name\n" | ||
656 | // "--------- ---------- ----- ----" | ||
657 | printf( "%9u " "%s " "%s\n", | ||
658 | (unsigned)zip_header.formatted.ucmpsize, | ||
659 | dtbuf, | ||
656 | dst_fn); | 660 | dst_fn); |
657 | } else { | 661 | } else { |
658 | unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize; | 662 | unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize; |
@@ -661,9 +665,9 @@ int unzip_main(int argc, char **argv) | |||
661 | percents = percents * 100; | 665 | percents = percents * 100; |
662 | if (zip_header.formatted.ucmpsize) | 666 | if (zip_header.formatted.ucmpsize) |
663 | percents /= zip_header.formatted.ucmpsize; | 667 | percents /= zip_header.formatted.ucmpsize; |
664 | // " Length Method Size Ratio Date Time CRC-32 Name\n" | 668 | // " Length Method Size Cmpr Date Time CRC-32 Name\n" |
665 | // "-------- ------ ------- ----- ---- ---- ------ ----" | 669 | // "-------- ------ ------- ---- ---------- ----- -------- ----" |
666 | printf( "%8u %s" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n", | 670 | printf( "%8u %s" "%9u%4u%% " "%s " "%08x " "%s\n", |
667 | (unsigned)zip_header.formatted.ucmpsize, | 671 | (unsigned)zip_header.formatted.ucmpsize, |
668 | zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */ | 672 | zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */ |
669 | /* TODO: show other methods? | 673 | /* TODO: show other methods? |
@@ -681,11 +685,7 @@ int unzip_main(int argc, char **argv) | |||
681 | */ | 685 | */ |
682 | (unsigned)zip_header.formatted.cmpsize, | 686 | (unsigned)zip_header.formatted.cmpsize, |
683 | (unsigned)percents, | 687 | (unsigned)percents, |
684 | (dostime & 0x01e00000) >> 21, | 688 | dtbuf, |
685 | (dostime & 0x001f0000) >> 16, | ||
686 | (((dostime & 0xfe000000) >> 25) + 1980) % 100, | ||
687 | (dostime & 0x0000f800) >> 11, | ||
688 | (dostime & 0x000007e0) >> 5, | ||
689 | zip_header.formatted.crc32, | 689 | zip_header.formatted.crc32, |
690 | dst_fn); | 690 | dst_fn); |
691 | total_size += zip_header.formatted.cmpsize; | 691 | total_size += zip_header.formatted.cmpsize; |
@@ -793,21 +793,25 @@ int unzip_main(int argc, char **argv) | |||
793 | 793 | ||
794 | if (listing && quiet <= 1) { | 794 | if (listing && quiet <= 1) { |
795 | if (!verbose) { | 795 | if (!verbose) { |
796 | // " Length Date Time Name\n" | 796 | // " Length Date Time Name\n" |
797 | // " -------- ---- ---- ----" | 797 | // "--------- ---------- ----- ----" |
798 | printf( " -------- -------\n" | 798 | printf( " --------%21s" "-------\n" |
799 | "%9lu" " %u files\n", | 799 | "%9lu%21s" "%u files\n", |
800 | total_usize, total_entries); | 800 | "", |
801 | total_usize, "", total_entries); | ||
801 | } else { | 802 | } else { |
802 | unsigned long percents = total_usize - total_size; | 803 | unsigned long percents = total_usize - total_size; |
804 | if ((long)percents < 0) | ||
805 | percents = 0; /* happens if usize < size */ | ||
803 | percents = percents * 100; | 806 | percents = percents * 100; |
804 | if (total_usize) | 807 | if (total_usize) |
805 | percents /= total_usize; | 808 | percents /= total_usize; |
806 | // " Length Method Size Ratio Date Time CRC-32 Name\n" | 809 | // " Length Method Size Cmpr Date Time CRC-32 Name\n" |
807 | // "-------- ------ ------- ----- ---- ---- ------ ----" | 810 | // "-------- ------ ------- ---- ---------- ----- -------- ----" |
808 | printf( "-------- ------- --- -------\n" | 811 | printf( "-------- ------- ----%28s" "----\n" |
809 | "%8lu" "%17lu%4u%% %u files\n", | 812 | "%8lu" "%17lu%4u%%%28s" "%u files\n", |
810 | total_usize, total_size, (unsigned)percents, | 813 | "", |
814 | total_usize, total_size, (unsigned)percents, "", | ||
811 | total_entries); | 815 | total_entries); |
812 | } | 816 | } |
813 | } | 817 | } |