diff options
author | aaronl <aaronl@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-12-06 03:22:43 +0000 |
---|---|---|
committer | aaronl <aaronl@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-12-06 03:22:43 +0000 |
commit | a28393db3d463d0c5283afcef124ae7c07f4137e (patch) | |
tree | 065055425b665de749ec94e478da724e199f48a4 /archival/gzip.c | |
parent | 5b1789dbed3ff81cda31f5846546d4f70f56e12a (diff) | |
download | busybox-w32-a28393db3d463d0c5283afcef124ae7c07f4137e.tar.gz busybox-w32-a28393db3d463d0c5283afcef124ae7c07f4137e.tar.bz2 busybox-w32-a28393db3d463d0c5283afcef124ae7c07f4137e.zip |
Commit my improvement on Rodney Brown's patch to g(un)zip, decreasing
binary size.
git-svn-id: svn://busybox.net/trunk/busybox@3831 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'archival/gzip.c')
-rw-r--r-- | archival/gzip.c | 42 |
1 files changed, 16 insertions, 26 deletions
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 |