aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-07 19:44:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-07 19:44:35 +0000
commit2f6df7fa0a70810d70e8ca0816b64c0f40b76847 (patch)
tree83c68c37ebebd878f2ec3129214b20a3d041d2ea
parent56c83eaaf5c9245b46b7dc0606faba2e53f90737 (diff)
downloadbusybox-w32-2f6df7fa0a70810d70e8ca0816b64c0f40b76847.tar.gz
busybox-w32-2f6df7fa0a70810d70e8ca0816b64c0f40b76847.tar.bz2
busybox-w32-2f6df7fa0a70810d70e8ca0816b64c0f40b76847.zip
gzip cleanup part #11
-rw-r--r--archival/gzip.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index 034bda005..17010438a 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -16,6 +16,22 @@
16 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 16 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
17 */ 17 */
18 18
19/* big objects in bss:
20 * 00000020 b bl_count
21 * 00000074 b base_length
22 * 00000078 b base_dist
23 * 00000078 b static_dtree
24 * 0000009c b bl_tree
25 * 000000f4 b dyn_dtree
26 * 00000100 b length_code
27 * 00000200 b dist_code
28 * 0000023d b depth
29 * 00000400 b flag_buf
30 * 00000480 b static_ltree
31 * 000008f4 b dyn_ltree
32 * 000008f4 b heap
33 */
34
19/* TODO: full support for -v for DESKTOP 35/* TODO: full support for -v for DESKTOP
20/usr/bin/gzip -v a bogus aa 36/usr/bin/gzip -v a bogus aa
21a: 85.1% -- replaced with a.gz 37a: 85.1% -- replaced with a.gz
@@ -329,7 +345,7 @@ static int foreground; /* set if program run in foreground */
329static int method = DEFLATED; /* compression method */ 345static int method = DEFLATED; /* compression method */
330static int exit_code; /* program exit code */ 346static int exit_code; /* program exit code */
331static long time_stamp; /* original time stamp (modification time) */ 347static long time_stamp; /* original time stamp (modification time) */
332static char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */ 348////static char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
333 349
334static int ifd; /* input file descriptor */ 350static int ifd; /* input file descriptor */
335static int ofd; /* output file descriptor */ 351static int ofd; /* output file descriptor */
@@ -1046,7 +1062,7 @@ static int base_dist[D_CODES];
1046 1062
1047/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */ 1063/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */
1048 1064
1049static uch flag_buf[(LIT_BUFSIZE / 8)]; 1065static uch flag_buf[LIT_BUFSIZE / 8];
1050 1066
1051/* flag_buf is a bit array distinguishing literals from lengths in 1067/* flag_buf is a bit array distinguishing literals from lengths in
1052 * l_buf, thus indicating the presence or absence of a distance. 1068 * l_buf, thus indicating the presence or absence of a distance.
@@ -1130,6 +1146,7 @@ static void init_block(void)
1130 * Allocate the match buffer, initialize the various tables and save the 1146 * Allocate the match buffer, initialize the various tables and save the
1131 * location of the internal file attribute (ascii/binary) and method 1147 * location of the internal file attribute (ascii/binary) and method
1132 * (DEFLATE/STORE). 1148 * (DEFLATE/STORE).
1149 * One callsite in zip()
1133 */ 1150 */
1134static void ct_init(ush * attr, int *methodp) 1151static void ct_init(ush * attr, int *methodp)
1135{ 1152{
@@ -1143,8 +1160,10 @@ static void ct_init(ush * attr, int *methodp)
1143 file_method = methodp; 1160 file_method = methodp;
1144 compressed_len = 0L; 1161 compressed_len = 0L;
1145 1162
1163#ifdef NOT_NEEDED
1146 if (static_dtree[0].Len != 0) 1164 if (static_dtree[0].Len != 0)
1147 return; /* ct_init already called */ 1165 return; /* ct_init already called */
1166#endif
1148 1167
1149 /* Initialize the mapping length (0..255) -> length code (0..28) */ 1168 /* Initialize the mapping length (0..255) -> length code (0..28) */
1150 length = 0; 1169 length = 0;
@@ -1174,14 +1193,15 @@ static void ct_init(ush * attr, int *methodp)
1174 for (; code < D_CODES; code++) { 1193 for (; code < D_CODES; code++) {
1175 base_dist[code] = dist << 7; 1194 base_dist[code] = dist << 7;
1176 for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { 1195 for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
1177 dist_code[256 + dist++] = (uch) code; 1196 dist_code[256 + dist++] = code;
1178 } 1197 }
1179 } 1198 }
1180 Assert(dist == 256, "ct_init: 256+dist != 512"); 1199 Assert(dist == 256, "ct_init: 256+dist != 512");
1181 1200
1182 /* Construct the codes of the static literal tree */ 1201 /* Construct the codes of the static literal tree */
1202 /* already zeroed - it's in bss
1183 for (bits = 0; bits <= MAX_BITS; bits++) 1203 for (bits = 0; bits <= MAX_BITS; bits++)
1184 bl_count[bits] = 0; 1204 bl_count[bits] = 0; */
1185 1205
1186 n = 0; 1206 n = 0;
1187 while (n <= 143) { 1207 while (n <= 143) {
@@ -1478,7 +1498,7 @@ static void build_tree(tree_desc * desc)
1478 1498
1479 /* Create a new node father of n and m */ 1499 /* Create a new node father of n and m */
1480 tree[node].Freq = tree[n].Freq + tree[m].Freq; 1500 tree[node].Freq = tree[n].Freq + tree[m].Freq;
1481 depth[node] = (uch) (MAX(depth[n], depth[m]) + 1); 1501 depth[node] = MAX(depth[n], depth[m]) + 1;
1482 tree[n].Dad = tree[m].Dad = (ush) node; 1502 tree[n].Dad = tree[m].Dad = (ush) node;
1483#ifdef DUMP_BL_TREE 1503#ifdef DUMP_BL_TREE
1484 if (tree == bl_tree) { 1504 if (tree == bl_tree) {
@@ -1524,14 +1544,15 @@ static void scan_tree(ct_data * tree, int max_code)
1524 max_count = 138; 1544 max_count = 138;
1525 min_count = 3; 1545 min_count = 3;
1526 } 1546 }
1527 tree[max_code + 1].Len = (ush) 0xffff; /* guard */ 1547 tree[max_code + 1].Len = 0xffff; /* guard */
1528 1548
1529 for (n = 0; n <= max_code; n++) { 1549 for (n = 0; n <= max_code; n++) {
1530 curlen = nextlen; 1550 curlen = nextlen;
1531 nextlen = tree[n + 1].Len; 1551 nextlen = tree[n + 1].Len;
1532 if (++count < max_count && curlen == nextlen) { 1552 if (++count < max_count && curlen == nextlen)
1533 continue; 1553 continue;
1534 } else if (count < min_count) { 1554
1555 if (count < min_count) {
1535 bl_tree[curlen].Freq += count; 1556 bl_tree[curlen].Freq += count;
1536 } else if (curlen != 0) { 1557 } else if (curlen != 0) {
1537 if (curlen != prevlen) 1558 if (curlen != prevlen)
@@ -1544,15 +1565,15 @@ static void scan_tree(ct_data * tree, int max_code)
1544 } 1565 }
1545 count = 0; 1566 count = 0;
1546 prevlen = curlen; 1567 prevlen = curlen;
1568
1569 max_count = 7;
1570 min_count = 4;
1547 if (nextlen == 0) { 1571 if (nextlen == 0) {
1548 max_count = 138; 1572 max_count = 138;
1549 min_count = 3; 1573 min_count = 3;
1550 } else if (curlen == nextlen) { 1574 } else if (curlen == nextlen) {
1551 max_count = 6; 1575 max_count = 6;
1552 min_count = 3; 1576 min_count = 3;
1553 } else {
1554 max_count = 7;
1555 min_count = 4;
1556 } 1577 }
1557 } 1578 }
1558} 1579}
@@ -2152,7 +2173,7 @@ int gzip_main(int argc, char **argv)
2152 } 2173 }
2153#endif 2174#endif
2154 2175
2155 strncpy(z_suffix, ".gz", sizeof(z_suffix) - 1); 2176//// strncpy(z_suffix, ".gz", sizeof(z_suffix) - 1);
2156 2177
2157 /* Allocate all global buffers (for DYN_ALLOC option) */ 2178 /* Allocate all global buffers (for DYN_ALLOC option) */
2158 ALLOC(uch, inbuf, INBUFSIZ + INBUF_EXTRA); 2179 ALLOC(uch, inbuf, INBUFSIZ + INBUF_EXTRA);