From ce9041567003b665e1b95eb82183356fd5d86e2c Mon Sep 17 00:00:00 2001 From: justin1014 Date: Thu, 3 Oct 2002 06:22:06 +0000 Subject: [PATCH] more size savings, and fixed bzip2 small mode git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1292 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/bzip2/bzlib.c | 37 +++++++++++++++++-------------------- Source/bzip2/bzlib.h | 10 ++-------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Source/bzip2/bzlib.c b/Source/bzip2/bzlib.c index 24dd2657..84fb28fb 100644 --- a/Source/bzip2/bzlib.c +++ b/Source/bzip2/bzlib.c @@ -436,23 +436,23 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) } #else // EXEHEAD -/*---------------------------------------------------*/ -/*--- Decompression stuff ---*/ +#ifdef NSIS_COMPRESS_BZIP2_SMALLMODE /*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressInit) - ( DState * s) -{ - s->state = BZ_X_BLKHDR_1; - - return BZ_OK; +Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) +{ + Int32 nb, na, mid; + nb = 0; + na = 256; + do { + mid = (nb + na) >> 1; + if (indx >= cftab[mid]) nb = mid; + else na = mid; + } while (na - nb != 1); + return nb; } - - -#ifdef NSIS_COMPRESS_BZIP2_SMALLMODE -/*---------------------------------------------------*/ static void unRLE_obuf_to_output_SMALL ( DState* s ) { @@ -460,14 +460,12 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) while (True) { /* try to finish existing run */ while (True) { - if (s->strm->avail_out == 0) return; + if (s->avail_out == 0) return; if (s->state_out_len == 0) break; - *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; + *( (UChar*)(s->next_out) ) = s->state_out_ch; s->state_out_len--; - s->strm->next_out++; - s->strm->avail_out--; -// s->strm->total_out_lo32++; -// if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; + s->next_out++; + s->avail_out--; } /* can a new run be started? */ @@ -495,8 +493,7 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) } } #else//!small, fast -static -void unRLE_obuf_to_output_FAST ( DState* s ) +static void unRLE_obuf_to_output_FAST ( DState* s ) { UChar k1; diff --git a/Source/bzip2/bzlib.h b/Source/bzip2/bzlib.h index f1a494c8..2cb431c7 100644 --- a/Source/bzip2/bzlib.h +++ b/Source/bzip2/bzlib.h @@ -480,19 +480,13 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); +#define BZ2_bzDecompressInit(s) { (s)->state = BZ_X_BLKHDR_1; } -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - DState *s - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - DState * s - ); +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( DState * s ); #endif - /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ #ifdef BZ_NO_STDIO