diff options
author | Aaron Lehmann <aaronl@vitelius.com> | 2001-12-06 03:22:43 +0000 |
---|---|---|
committer | Aaron Lehmann <aaronl@vitelius.com> | 2001-12-06 03:22:43 +0000 |
commit | b9df470c4d886f03b26d9277ec059130e6472f40 (patch) | |
tree | 065055425b665de749ec94e478da724e199f48a4 | |
parent | 249f39a2650a1f002803b59c4be82ee98fca5652 (diff) | |
download | busybox-w32-b9df470c4d886f03b26d9277ec059130e6472f40.tar.gz busybox-w32-b9df470c4d886f03b26d9277ec059130e6472f40.tar.bz2 busybox-w32-b9df470c4d886f03b26d9277ec059130e6472f40.zip |
Commit my improvement on Rodney Brown's patch to g(un)zip, decreasing
binary size.
-rw-r--r-- | archival/bunzip2.c | 2 | ||||
-rw-r--r-- | archival/gzip.c | 42 | ||||
-rw-r--r-- | archival/libunarchive/decompress_unzip.c | 55 | ||||
-rw-r--r-- | archival/libunarchive/unzip.c | 55 | ||||
-rw-r--r-- | libbb/unzip.c | 55 |
5 files changed, 104 insertions, 105 deletions
diff --git a/archival/bunzip2.c b/archival/bunzip2.c index 290681dd3..c07fe1892 100644 --- a/archival/bunzip2.c +++ b/archival/bunzip2.c | |||
@@ -276,7 +276,7 @@ int numFileNames; | |||
276 | int numFilesProcessed; | 276 | int numFilesProcessed; |
277 | int exitValue; | 277 | int exitValue; |
278 | 278 | ||
279 | unsigned int BZ2_crc32Table[256] = { | 279 | const unsigned int BZ2_crc32Table[256] = { |
280 | 280 | ||
281 | /*-- Ugly, innit? --*/ | 281 | /*-- Ugly, innit? --*/ |
282 | 282 | ||
diff --git a/archival/gzip.c b/archival/gzip.c index df665c121..436393ed5 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -174,15 +174,6 @@ typedef int file_t; /* Do not use stdio */ | |||
174 | #define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\ | 174 | #define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\ |
175 | flush_outbuf();} | 175 | flush_outbuf();} |
176 | 176 | ||
177 | /* Output a 16 bit value, lsb first */ | ||
178 | #define put_short(w) \ | ||
179 | { if (outcnt < OUTBUFSIZ-2) { \ | ||
180 | outbuf[outcnt++] = (uch) ((w) & 0xff); \ | ||
181 | outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \ | ||
182 | } else { \ | ||
183 | put_short_when_full(w); \ | ||
184 | } \ | ||
185 | } | ||
186 | 177 | ||
187 | /* Output a 32 bit value to the bit stream, lsb first */ | 178 | /* Output a 32 bit value to the bit stream, lsb first */ |
188 | #if 0 | 179 | #if 0 |
@@ -247,9 +238,6 @@ static int (*read_buf) (char *buf, unsigned size); | |||
247 | /* from util.c: */ | 238 | /* from util.c: */ |
248 | static void flush_outbuf (void); | 239 | static void flush_outbuf (void); |
249 | 240 | ||
250 | static void put_short_when_full (ush); | ||
251 | |||
252 | |||
253 | /* lzw.h -- define the lzw functions. | 241 | /* lzw.h -- define the lzw functions. |
254 | * Copyright (C) 1992-1993 Jean-loup Gailly. | 242 | * Copyright (C) 1992-1993 Jean-loup Gailly. |
255 | * This is free software; you can redistribute it and/or modify it under the | 243 | * This is free software; you can redistribute it and/or modify it under the |
@@ -336,6 +324,19 @@ static int ofd; /* output file descriptor */ | |||
336 | static unsigned insize; /* valid bytes in inbuf */ | 324 | static unsigned insize; /* valid bytes in inbuf */ |
337 | static unsigned outcnt; /* bytes in output buffer */ | 325 | static unsigned outcnt; /* bytes in output buffer */ |
338 | 326 | ||
327 | |||
328 | /* Output a 16 bit value, lsb first */ | ||
329 | static void put_short(ush w) | ||
330 | { | ||
331 | if (outcnt < OUTBUFSIZ-2) { | ||
332 | outbuf[outcnt++] = (uch) ((w) & 0xff); | ||
333 | outbuf[outcnt++] = (uch) ((ush)(w) >> 8); | ||
334 | } else { | ||
335 | put_byte((uch)((w) & 0xff)); | ||
336 | put_byte((uch)((ush)(w) >> 8)); | ||
337 | } | ||
338 | } | ||
339 | |||
339 | /* ======================================================================== | 340 | /* ======================================================================== |
340 | * Signal and error handler. | 341 | * Signal and error handler. |
341 | */ | 342 | */ |
@@ -1481,7 +1482,7 @@ static const extra_bits_t extra_blbits[BL_CODES] | |||
1481 | * if we rely on DIST_BUFSIZE == LIT_BUFSIZE. | 1482 | * if we rely on DIST_BUFSIZE == LIT_BUFSIZE. |
1482 | */ | 1483 | */ |
1483 | #if LIT_BUFSIZE > INBUFSIZ | 1484 | #if LIT_BUFSIZE > INBUFSIZ |
1484 | error cannot overlay l_buf and inbuf | 1485 | #error cannot overlay l_buf and inbuf |
1485 | #endif | 1486 | #endif |
1486 | #define REP_3_6 16 | 1487 | #define REP_3_6 16 |
1487 | /* repeat previous bit length 3-6 times (2 bits of repeat count) */ | 1488 | /* repeat previous bit length 3-6 times (2 bits of repeat count) */ |
@@ -2462,21 +2463,10 @@ static void set_file_type() | |||
2462 | static ulg crc; /* crc on uncompressed file data */ | 2463 | static ulg crc; /* crc on uncompressed file data */ |
2463 | static long header_bytes; /* number of bytes in gzip header */ | 2464 | static long header_bytes; /* number of bytes in gzip header */ |
2464 | 2465 | ||
2465 | static void put_short_when_full(ush w) | ||
2466 | { | ||
2467 | put_byte((uch)((w) & 0xff)); | ||
2468 | put_byte((uch)((ush)(w) >> 8)); | ||
2469 | } | ||
2470 | |||
2471 | static void put_short_function(ush n) | ||
2472 | { | ||
2473 | put_short(n); | ||
2474 | } | ||
2475 | |||
2476 | static void put_long(ulg n) | 2466 | static void put_long(ulg n) |
2477 | { | 2467 | { |
2478 | put_short_function((n) & 0xffff); | 2468 | put_short((n) & 0xffff); |
2479 | put_short_function(((ulg)(n)) >> 16); | 2469 | put_short(((ulg)(n)) >> 16); |
2480 | } | 2470 | } |
2481 | 2471 | ||
2482 | /* put_header_byte is used for the compressed output | 2472 | /* put_header_byte is used for the compressed output |
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index a747baea5..6c3f3229a 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c | |||
@@ -186,6 +186,8 @@ static int huft_free(huft_t *t) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | typedef unsigned char extra_bits_t; | ||
190 | |||
189 | /* Given a list of code lengths and a maximum table size, make a set of | 191 | /* Given a list of code lengths and a maximum table size, make a set of |
190 | * tables to decode that set of codes. Return zero on success, one if | 192 | * tables to decode that set of codes. Return zero on success, one if |
191 | * the given code set is incomplete (the tables are still built in this | 193 | * the given code set is incomplete (the tables are still built in this |
@@ -201,7 +203,7 @@ static int huft_free(huft_t *t) | |||
201 | * m: maximum lookup bits, returns actual | 203 | * m: maximum lookup bits, returns actual |
202 | */ | 204 | */ |
203 | static int huft_build(unsigned int *b, const unsigned int n, const unsigned int s, | 205 | static int huft_build(unsigned int *b, const unsigned int n, const unsigned int s, |
204 | const unsigned short *d, const unsigned short *e, huft_t **t, int *m) | 206 | const unsigned short *d, const extra_bits_t *e, huft_t **t, int *m) |
205 | { | 207 | { |
206 | unsigned a; /* counter for codes of length k */ | 208 | unsigned a; /* counter for codes of length k */ |
207 | unsigned c[BMAX + 1]; /* bit length count table */ | 209 | unsigned c[BMAX + 1]; /* bit length count table */ |
@@ -489,6 +491,30 @@ static int inflate_codes(huft_t *tl, huft_t *td, int bl, int bd) | |||
489 | return 0; | 491 | return 0; |
490 | } | 492 | } |
491 | 493 | ||
494 | static const unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
495 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
496 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 | ||
497 | }; | ||
498 | /* note: see note #13 above about the 258 in this list. */ | ||
499 | static const extra_bits_t cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
500 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
501 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 | ||
502 | }; /* 99==invalid */ | ||
503 | static const unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
504 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
505 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
506 | 8193, 12289, 16385, 24577 | ||
507 | }; | ||
508 | static const extra_bits_t cpdext[] = { /* Extra bits for distance codes */ | ||
509 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
510 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
511 | 12, 12, 13, 13 | ||
512 | }; | ||
513 | /* Tables for deflate from PKZIP's appnote.txt. */ | ||
514 | static const extra_bits_t border[] = { /* Order of the bit length code lengths */ | ||
515 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 | ||
516 | }; | ||
517 | |||
492 | /* | 518 | /* |
493 | * decompress an inflated block | 519 | * decompress an inflated block |
494 | * e: last block flag | 520 | * e: last block flag |
@@ -500,25 +526,6 @@ static int inflate_block(int *e) | |||
500 | unsigned t; /* block type */ | 526 | unsigned t; /* block type */ |
501 | register unsigned long b; /* bit buffer */ | 527 | register unsigned long b; /* bit buffer */ |
502 | register unsigned k; /* number of bits in bit buffer */ | 528 | register unsigned k; /* number of bits in bit buffer */ |
503 | static unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
504 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
505 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 | ||
506 | }; | ||
507 | /* note: see note #13 above about the 258 in this list. */ | ||
508 | static unsigned short cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
509 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
510 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 | ||
511 | }; /* 99==invalid */ | ||
512 | static unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
513 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
514 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
515 | 8193, 12289, 16385, 24577 | ||
516 | }; | ||
517 | static unsigned short cpdext[] = { /* Extra bits for distance codes */ | ||
518 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
519 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
520 | 12, 12, 13, 13 | ||
521 | }; | ||
522 | 529 | ||
523 | /* make local bit buffer */ | 530 | /* make local bit buffer */ |
524 | b = bb; | 531 | b = bb; |
@@ -657,12 +664,8 @@ static int inflate_block(int *e) | |||
657 | } | 664 | } |
658 | case 2: /* Inflate dynamic */ | 665 | case 2: /* Inflate dynamic */ |
659 | { | 666 | { |
660 | /* Tables for deflate from PKZIP's appnote.txt. */ | 667 | const int dbits = 6; /* bits in base distance lookup table */ |
661 | static unsigned border[] = { /* Order of the bit length code lengths */ | 668 | const int lbits = 9; /* bits in base literal/length lookup table */ |
662 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 | ||
663 | }; | ||
664 | int dbits = 6; /* bits in base distance lookup table */ | ||
665 | int lbits = 9; /* bits in base literal/length lookup table */ | ||
666 | 669 | ||
667 | int i; /* temporary variables */ | 670 | int i; /* temporary variables */ |
668 | unsigned j; | 671 | unsigned j; |
diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c index a747baea5..6c3f3229a 100644 --- a/archival/libunarchive/unzip.c +++ b/archival/libunarchive/unzip.c | |||
@@ -186,6 +186,8 @@ static int huft_free(huft_t *t) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | typedef unsigned char extra_bits_t; | ||
190 | |||
189 | /* Given a list of code lengths and a maximum table size, make a set of | 191 | /* Given a list of code lengths and a maximum table size, make a set of |
190 | * tables to decode that set of codes. Return zero on success, one if | 192 | * tables to decode that set of codes. Return zero on success, one if |
191 | * the given code set is incomplete (the tables are still built in this | 193 | * the given code set is incomplete (the tables are still built in this |
@@ -201,7 +203,7 @@ static int huft_free(huft_t *t) | |||
201 | * m: maximum lookup bits, returns actual | 203 | * m: maximum lookup bits, returns actual |
202 | */ | 204 | */ |
203 | static int huft_build(unsigned int *b, const unsigned int n, const unsigned int s, | 205 | static int huft_build(unsigned int *b, const unsigned int n, const unsigned int s, |
204 | const unsigned short *d, const unsigned short *e, huft_t **t, int *m) | 206 | const unsigned short *d, const extra_bits_t *e, huft_t **t, int *m) |
205 | { | 207 | { |
206 | unsigned a; /* counter for codes of length k */ | 208 | unsigned a; /* counter for codes of length k */ |
207 | unsigned c[BMAX + 1]; /* bit length count table */ | 209 | unsigned c[BMAX + 1]; /* bit length count table */ |
@@ -489,6 +491,30 @@ static int inflate_codes(huft_t *tl, huft_t *td, int bl, int bd) | |||
489 | return 0; | 491 | return 0; |
490 | } | 492 | } |
491 | 493 | ||
494 | static const unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
495 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
496 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 | ||
497 | }; | ||
498 | /* note: see note #13 above about the 258 in this list. */ | ||
499 | static const extra_bits_t cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
500 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
501 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 | ||
502 | }; /* 99==invalid */ | ||
503 | static const unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
504 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
505 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
506 | 8193, 12289, 16385, 24577 | ||
507 | }; | ||
508 | static const extra_bits_t cpdext[] = { /* Extra bits for distance codes */ | ||
509 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
510 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
511 | 12, 12, 13, 13 | ||
512 | }; | ||
513 | /* Tables for deflate from PKZIP's appnote.txt. */ | ||
514 | static const extra_bits_t border[] = { /* Order of the bit length code lengths */ | ||
515 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 | ||
516 | }; | ||
517 | |||
492 | /* | 518 | /* |
493 | * decompress an inflated block | 519 | * decompress an inflated block |
494 | * e: last block flag | 520 | * e: last block flag |
@@ -500,25 +526,6 @@ static int inflate_block(int *e) | |||
500 | unsigned t; /* block type */ | 526 | unsigned t; /* block type */ |
501 | register unsigned long b; /* bit buffer */ | 527 | register unsigned long b; /* bit buffer */ |
502 | register unsigned k; /* number of bits in bit buffer */ | 528 | register unsigned k; /* number of bits in bit buffer */ |
503 | static unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
504 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
505 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 | ||
506 | }; | ||
507 | /* note: see note #13 above about the 258 in this list. */ | ||
508 | static unsigned short cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
509 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
510 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 | ||
511 | }; /* 99==invalid */ | ||
512 | static unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
513 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
514 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
515 | 8193, 12289, 16385, 24577 | ||
516 | }; | ||
517 | static unsigned short cpdext[] = { /* Extra bits for distance codes */ | ||
518 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
519 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
520 | 12, 12, 13, 13 | ||
521 | }; | ||
522 | 529 | ||
523 | /* make local bit buffer */ | 530 | /* make local bit buffer */ |
524 | b = bb; | 531 | b = bb; |
@@ -657,12 +664,8 @@ static int inflate_block(int *e) | |||
657 | } | 664 | } |
658 | case 2: /* Inflate dynamic */ | 665 | case 2: /* Inflate dynamic */ |
659 | { | 666 | { |
660 | /* Tables for deflate from PKZIP's appnote.txt. */ | 667 | const int dbits = 6; /* bits in base distance lookup table */ |
661 | static unsigned border[] = { /* Order of the bit length code lengths */ | 668 | const int lbits = 9; /* bits in base literal/length lookup table */ |
662 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 | ||
663 | }; | ||
664 | int dbits = 6; /* bits in base distance lookup table */ | ||
665 | int lbits = 9; /* bits in base literal/length lookup table */ | ||
666 | 669 | ||
667 | int i; /* temporary variables */ | 670 | int i; /* temporary variables */ |
668 | unsigned j; | 671 | unsigned j; |
diff --git a/libbb/unzip.c b/libbb/unzip.c index a747baea5..6c3f3229a 100644 --- a/libbb/unzip.c +++ b/libbb/unzip.c | |||
@@ -186,6 +186,8 @@ static int huft_free(huft_t *t) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | typedef unsigned char extra_bits_t; | ||
190 | |||
189 | /* Given a list of code lengths and a maximum table size, make a set of | 191 | /* Given a list of code lengths and a maximum table size, make a set of |
190 | * tables to decode that set of codes. Return zero on success, one if | 192 | * tables to decode that set of codes. Return zero on success, one if |
191 | * the given code set is incomplete (the tables are still built in this | 193 | * the given code set is incomplete (the tables are still built in this |
@@ -201,7 +203,7 @@ static int huft_free(huft_t *t) | |||
201 | * m: maximum lookup bits, returns actual | 203 | * m: maximum lookup bits, returns actual |
202 | */ | 204 | */ |
203 | static int huft_build(unsigned int *b, const unsigned int n, const unsigned int s, | 205 | static int huft_build(unsigned int *b, const unsigned int n, const unsigned int s, |
204 | const unsigned short *d, const unsigned short *e, huft_t **t, int *m) | 206 | const unsigned short *d, const extra_bits_t *e, huft_t **t, int *m) |
205 | { | 207 | { |
206 | unsigned a; /* counter for codes of length k */ | 208 | unsigned a; /* counter for codes of length k */ |
207 | unsigned c[BMAX + 1]; /* bit length count table */ | 209 | unsigned c[BMAX + 1]; /* bit length count table */ |
@@ -489,6 +491,30 @@ static int inflate_codes(huft_t *tl, huft_t *td, int bl, int bd) | |||
489 | return 0; | 491 | return 0; |
490 | } | 492 | } |
491 | 493 | ||
494 | static const unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
495 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
496 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 | ||
497 | }; | ||
498 | /* note: see note #13 above about the 258 in this list. */ | ||
499 | static const extra_bits_t cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
500 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
501 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 | ||
502 | }; /* 99==invalid */ | ||
503 | static const unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
504 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
505 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
506 | 8193, 12289, 16385, 24577 | ||
507 | }; | ||
508 | static const extra_bits_t cpdext[] = { /* Extra bits for distance codes */ | ||
509 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
510 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
511 | 12, 12, 13, 13 | ||
512 | }; | ||
513 | /* Tables for deflate from PKZIP's appnote.txt. */ | ||
514 | static const extra_bits_t border[] = { /* Order of the bit length code lengths */ | ||
515 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 | ||
516 | }; | ||
517 | |||
492 | /* | 518 | /* |
493 | * decompress an inflated block | 519 | * decompress an inflated block |
494 | * e: last block flag | 520 | * e: last block flag |
@@ -500,25 +526,6 @@ static int inflate_block(int *e) | |||
500 | unsigned t; /* block type */ | 526 | unsigned t; /* block type */ |
501 | register unsigned long b; /* bit buffer */ | 527 | register unsigned long b; /* bit buffer */ |
502 | register unsigned k; /* number of bits in bit buffer */ | 528 | register unsigned k; /* number of bits in bit buffer */ |
503 | static unsigned short cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
504 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
505 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 | ||
506 | }; | ||
507 | /* note: see note #13 above about the 258 in this list. */ | ||
508 | static unsigned short cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
509 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
510 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 | ||
511 | }; /* 99==invalid */ | ||
512 | static unsigned short cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
513 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
514 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
515 | 8193, 12289, 16385, 24577 | ||
516 | }; | ||
517 | static unsigned short cpdext[] = { /* Extra bits for distance codes */ | ||
518 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
519 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
520 | 12, 12, 13, 13 | ||
521 | }; | ||
522 | 529 | ||
523 | /* make local bit buffer */ | 530 | /* make local bit buffer */ |
524 | b = bb; | 531 | b = bb; |
@@ -657,12 +664,8 @@ static int inflate_block(int *e) | |||
657 | } | 664 | } |
658 | case 2: /* Inflate dynamic */ | 665 | case 2: /* Inflate dynamic */ |
659 | { | 666 | { |
660 | /* Tables for deflate from PKZIP's appnote.txt. */ | 667 | const int dbits = 6; /* bits in base distance lookup table */ |
661 | static unsigned border[] = { /* Order of the bit length code lengths */ | 668 | const int lbits = 9; /* bits in base literal/length lookup table */ |
662 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 | ||
663 | }; | ||
664 | int dbits = 6; /* bits in base distance lookup table */ | ||
665 | int lbits = 9; /* bits in base literal/length lookup table */ | ||
666 | 669 | ||
667 | int i; /* temporary variables */ | 670 | int i; /* temporary variables */ |
668 | unsigned j; | 671 | unsigned j; |