diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-26 00:21:25 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-26 00:21:25 +0100 |
commit | e50396298118b1076511f86af373434292102960 (patch) | |
tree | 7fda13304b9167206c960f2344e0d80c2360fcda | |
parent | 77a6678c427db5ea15d6d0005a579f441277df06 (diff) | |
download | busybox-w32-e50396298118b1076511f86af373434292102960.tar.gz busybox-w32-e50396298118b1076511f86af373434292102960.tar.bz2 busybox-w32-e50396298118b1076511f86af373434292102960.zip |
gzip: fix debug code. Closes 10681
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/gzip.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/archival/gzip.c b/archival/gzip.c index ac6633044..2a5288cce 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -114,6 +114,7 @@ aa: 85.1% -- replaced with aa.gz | |||
114 | //#define DEBUG 1 | 114 | //#define DEBUG 1 |
115 | /* Diagnostic functions */ | 115 | /* Diagnostic functions */ |
116 | #ifdef DEBUG | 116 | #ifdef DEBUG |
117 | static int verbose; | ||
117 | # define Assert(cond,msg) { if (!(cond)) bb_error_msg(msg); } | 118 | # define Assert(cond,msg) { if (!(cond)) bb_error_msg(msg); } |
118 | # define Trace(x) fprintf x | 119 | # define Trace(x) fprintf x |
119 | # define Tracev(x) {if (verbose) fprintf x; } | 120 | # define Tracev(x) {if (verbose) fprintf x; } |
@@ -1538,7 +1539,7 @@ static int build_bl_tree(void) | |||
1538 | } | 1539 | } |
1539 | /* Update opt_len to include the bit length tree and counts */ | 1540 | /* Update opt_len to include the bit length tree and counts */ |
1540 | G2.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; | 1541 | G2.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; |
1541 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", G2.opt_len, G2.static_len)); | 1542 | Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", (long)G2.opt_len, (long)G2.static_len)); |
1542 | 1543 | ||
1543 | return max_blindex; | 1544 | return max_blindex; |
1544 | } | 1545 | } |
@@ -1564,13 +1565,13 @@ static void send_all_trees(int lcodes, int dcodes, int blcodes) | |||
1564 | Tracev((stderr, "\nbl code %2d ", bl_order[rank])); | 1565 | Tracev((stderr, "\nbl code %2d ", bl_order[rank])); |
1565 | send_bits(G2.bl_tree[bl_order[rank]].Len, 3); | 1566 | send_bits(G2.bl_tree[bl_order[rank]].Len, 3); |
1566 | } | 1567 | } |
1567 | Tracev((stderr, "\nbl tree: sent %ld", G1.bits_sent)); | 1568 | Tracev((stderr, "\nbl tree: sent %ld", (long)G1.bits_sent)); |
1568 | 1569 | ||
1569 | send_tree((ct_data *) G2.dyn_ltree, lcodes - 1); /* send the literal tree */ | 1570 | send_tree((ct_data *) G2.dyn_ltree, lcodes - 1); /* send the literal tree */ |
1570 | Tracev((stderr, "\nlit tree: sent %ld", G1.bits_sent)); | 1571 | Tracev((stderr, "\nlit tree: sent %ld", (long)G1.bits_sent)); |
1571 | 1572 | ||
1572 | send_tree((ct_data *) G2.dyn_dtree, dcodes - 1); /* send the distance tree */ | 1573 | send_tree((ct_data *) G2.dyn_dtree, dcodes - 1); /* send the distance tree */ |
1573 | Tracev((stderr, "\ndist tree: sent %ld", G1.bits_sent)); | 1574 | Tracev((stderr, "\ndist tree: sent %ld", (long)G1.bits_sent)); |
1574 | } | 1575 | } |
1575 | 1576 | ||
1576 | 1577 | ||
@@ -1619,7 +1620,8 @@ static int ct_tally(int dist, int lc) | |||
1619 | out_length >>= 3; | 1620 | out_length >>= 3; |
1620 | Trace((stderr, | 1621 | Trace((stderr, |
1621 | "\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", | 1622 | "\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", |
1622 | G2.last_lit, G2.last_dist, in_length, out_length, | 1623 | G2.last_lit, G2.last_dist, |
1624 | (long)in_length, (long)out_length, | ||
1623 | 100L - out_length * 100L / in_length)); | 1625 | 100L - out_length * 100L / in_length)); |
1624 | if (G2.last_dist < G2.last_lit / 2 && out_length < in_length / 2) | 1626 | if (G2.last_dist < G2.last_lit / 2 && out_length < in_length / 2) |
1625 | return 1; | 1627 | return 1; |
@@ -1694,10 +1696,10 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1694 | 1696 | ||
1695 | /* Construct the literal and distance trees */ | 1697 | /* Construct the literal and distance trees */ |
1696 | build_tree(&G2.l_desc); | 1698 | build_tree(&G2.l_desc); |
1697 | Tracev((stderr, "\nlit data: dyn %ld, stat %ld", G2.opt_len, G2.static_len)); | 1699 | Tracev((stderr, "\nlit data: dyn %ld, stat %ld", (long)G2.opt_len, (long)G2.static_len)); |
1698 | 1700 | ||
1699 | build_tree(&G2.d_desc); | 1701 | build_tree(&G2.d_desc); |
1700 | Tracev((stderr, "\ndist data: dyn %ld, stat %ld", G2.opt_len, G2.static_len)); | 1702 | Tracev((stderr, "\ndist data: dyn %ld, stat %ld", (long)G2.opt_len, (long)G2.static_len)); |
1701 | /* At this point, opt_len and static_len are the total bit lengths of | 1703 | /* At this point, opt_len and static_len are the total bit lengths of |
1702 | * the compressed block data, excluding the tree representations. | 1704 | * the compressed block data, excluding the tree representations. |
1703 | */ | 1705 | */ |
@@ -1713,7 +1715,9 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1713 | 1715 | ||
1714 | Trace((stderr, | 1716 | Trace((stderr, |
1715 | "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", | 1717 | "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", |
1716 | opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len, | 1718 | (unsigned long)opt_lenb, (unsigned long)G2.opt_len, |
1719 | (unsigned long)static_lenb, (unsigned long)G2.static_len, | ||
1720 | (unsigned long)stored_len, | ||
1717 | G2.last_lit, G2.last_dist)); | 1721 | G2.last_lit, G2.last_dist)); |
1718 | 1722 | ||
1719 | if (static_lenb <= opt_lenb) | 1723 | if (static_lenb <= opt_lenb) |
@@ -1761,8 +1765,9 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1761 | bi_windup(); | 1765 | bi_windup(); |
1762 | G2.compressed_len += 7; /* align on byte boundary */ | 1766 | G2.compressed_len += 7; /* align on byte boundary */ |
1763 | } | 1767 | } |
1764 | Tracev((stderr, "\ncomprlen %lu(%lu) ", G2.compressed_len >> 3, | 1768 | Tracev((stderr, "\ncomprlen %lu(%lu) ", |
1765 | G2.compressed_len - 7 * eof)); | 1769 | (unsigned long)G2.compressed_len >> 3, |
1770 | (unsigned long)G2.compressed_len - 7 * eof)); | ||
1766 | 1771 | ||
1767 | return G2.compressed_len >> 3; | 1772 | return G2.compressed_len >> 3; |
1768 | } | 1773 | } |
@@ -1900,7 +1905,7 @@ static ulg deflate(void) | |||
1900 | G1.strstart++; | 1905 | G1.strstart++; |
1901 | G1.lookahead--; | 1906 | G1.lookahead--; |
1902 | } | 1907 | } |
1903 | Assert(G1.strstart <= G1.isize && lookahead <= G1.isize, "a bit too far"); | 1908 | Assert(G1.strstart <= G1.isize && G1.lookahead <= G1.isize, "a bit too far"); |
1904 | 1909 | ||
1905 | /* Make sure that we always have enough lookahead, except | 1910 | /* Make sure that we always have enough lookahead, except |
1906 | * at the end of the input file. We need MAX_MATCH bytes | 1911 | * at the end of the input file. We need MAX_MATCH bytes |