338 bytes (code) saved from bzip2
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1210 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b663923ebc
commit
d02c47ebd5
3 changed files with 180 additions and 194 deletions
|
@ -18,16 +18,16 @@
|
|||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
2. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
|
@ -114,8 +114,8 @@ Bool isempty_RL ( EState* s )
|
|||
}
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
int BZ_API(BZ2_bzCompressInit)
|
||||
( bz_stream* strm,
|
||||
int BZ_API(BZ2_bzCompressInit)
|
||||
( bz_stream* strm,
|
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor )
|
||||
|
@ -123,7 +123,7 @@ int BZ_API(BZ2_bzCompressInit)
|
|||
Int32 n;
|
||||
EState* s;
|
||||
|
||||
if (strm == NULL ||
|
||||
if (strm == NULL ||
|
||||
workFactor < 0 || workFactor > 250)
|
||||
return BZ_PARAM_ERROR;
|
||||
|
||||
|
@ -255,7 +255,7 @@ Bool copy_input_until_stop ( EState* s )
|
|||
/*-- no input? --*/
|
||||
if (s->strm->avail_in == 0) break;
|
||||
progress_in = True;
|
||||
ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
|
||||
ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
|
||||
s->strm->next_in++;
|
||||
s->strm->avail_in--;
|
||||
// s->strm->total_in_lo32++;
|
||||
|
@ -273,7 +273,7 @@ Bool copy_input_until_stop ( EState* s )
|
|||
/*-- flush/finish end? --*/
|
||||
if (s->avail_in_expect == 0) break;
|
||||
progress_in = True;
|
||||
ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
|
||||
ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
|
||||
s->strm->next_in++;
|
||||
s->strm->avail_in--;
|
||||
// s->strm->total_in_lo32++;
|
||||
|
@ -319,18 +319,18 @@ Bool handle_compress ( bz_stream* strm )
|
|||
Bool progress_in = False;
|
||||
Bool progress_out = False;
|
||||
EState* s = strm->state;
|
||||
|
||||
|
||||
while (True) {
|
||||
|
||||
if (s->state == BZ_S_OUTPUT) {
|
||||
progress_out |= copy_output_until_stop ( s );
|
||||
if (s->state_out_pos < s->numZ) break;
|
||||
if (s->mode == BZ_M_FINISHING &&
|
||||
if (s->mode == BZ_M_FINISHING &&
|
||||
s->avail_in_expect == 0 &&
|
||||
isempty_RL(s)) break;
|
||||
prepare_new_block ( s );
|
||||
s->state = BZ_S_INPUT;
|
||||
if (s->mode == BZ_M_FLUSHING &&
|
||||
if (s->mode == BZ_M_FLUSHING &&
|
||||
s->avail_in_expect == 0 &&
|
||||
isempty_RL(s)) break;
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
|||
if (action == BZ_RUN) {
|
||||
progress = handle_compress ( strm );
|
||||
return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (action == BZ_FLUSH) {
|
||||
s->avail_in_expect = strm->avail_in;
|
||||
|
@ -392,12 +392,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
|||
s->mode = BZ_M_FINISHING;
|
||||
goto preswitch;
|
||||
}
|
||||
else
|
||||
else
|
||||
return BZ_PARAM_ERROR;
|
||||
|
||||
case BZ_M_FLUSHING:
|
||||
if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
|
||||
if (s->avail_in_expect != s->strm->avail_in)
|
||||
if (s->avail_in_expect != s->strm->avail_in)
|
||||
return BZ_SEQUENCE_ERROR;
|
||||
progress = handle_compress ( strm );
|
||||
if (s->avail_in_expect > 0 || !isempty_RL(s) ||
|
||||
|
@ -407,7 +407,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
|
|||
|
||||
case BZ_M_FINISHING:
|
||||
if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
|
||||
if (s->avail_in_expect != s->strm->avail_in)
|
||||
if (s->avail_in_expect != s->strm->avail_in)
|
||||
return BZ_SEQUENCE_ERROR;
|
||||
progress = handle_compress ( strm );
|
||||
if (!progress) return BZ_SEQUENCE_ERROR;
|
||||
|
@ -434,7 +434,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
|
|||
BZFREE(s->ftab);
|
||||
BZFREE(strm->state);
|
||||
|
||||
strm->state = NULL;
|
||||
strm->state = NULL;
|
||||
|
||||
return BZ_OK;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
|
|||
static DState local_state;
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
int BZ_API(BZ2_bzDecompressInit)
|
||||
int BZ_API(BZ2_bzDecompressInit)
|
||||
( bz_stream* strm)
|
||||
{
|
||||
DState* s=&local_state;
|
||||
|
@ -464,8 +464,8 @@ int BZ_API(BZ2_bzDecompressInit)
|
|||
// strm->total_out_hi32 = 0;
|
||||
#ifdef NSIS_COMPRESS_BZIP2_SMALLMODE
|
||||
// s->ll16 = BZALLOC( NSIS_COMPRESS_BZIP2_LEVEL*100000 * sizeof(UInt16) );
|
||||
// s->ll4 = BZALLOC(
|
||||
// ((1 + NSIS_COMPRESS_BZIP2_LEVEL*100000) >> 1) * sizeof(UChar)
|
||||
// s->ll4 = BZALLOC(
|
||||
// ((1 + NSIS_COMPRESS_BZIP2_LEVEL*100000) >> 1) * sizeof(UChar)
|
||||
// );
|
||||
// if (s->ll16 == NULL || s->ll4 == NULL) return (BZ_MEM_ERROR);
|
||||
#else
|
||||
|
@ -517,34 +517,34 @@ void unRLE_obuf_to_output_SMALL ( DState* s )
|
|||
// s->strm->total_out_lo32++;
|
||||
// if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
|
||||
}
|
||||
|
||||
|
||||
/* can a new run be started? */
|
||||
if (s->nblock_used == s->save_nblock+1) return;
|
||||
|
||||
|
||||
if (s->nblock_used == s->save.nblock+1) return;
|
||||
|
||||
|
||||
s->state_out_len = 1;
|
||||
s->state_out_ch = s->k0;
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
s->state_out_len = 2;
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
s->state_out_len = 3;
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
|
||||
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
s->state_out_len = ((Int32)k1) + 4;
|
||||
BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
|
||||
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
}
|
||||
|
||||
|
@ -562,26 +562,26 @@ void unRLE_obuf_to_output_SMALL ( DState* s )
|
|||
// s->strm->total_out_lo32++;
|
||||
// if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
|
||||
}
|
||||
|
||||
|
||||
/* can a new run be started? */
|
||||
if (s->nblock_used == s->save_nblock+1) return;
|
||||
|
||||
if (s->nblock_used == s->save.nblock+1) return;
|
||||
|
||||
s->state_out_len = 1;
|
||||
s->state_out_ch = s->k0;
|
||||
BZ_GET_SMALL(k1); s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
s->state_out_len = 2;
|
||||
BZ_GET_SMALL(k1); s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
s->state_out_len = 3;
|
||||
BZ_GET_SMALL(k1); s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
BZ_GET_SMALL(k1); s->nblock_used++;
|
||||
s->state_out_len = ((Int32)k1) + 4;
|
||||
BZ_GET_SMALL(s->k0); s->nblock_used++;
|
||||
|
@ -610,34 +610,34 @@ void unRLE_obuf_to_output_FAST ( DState* s )
|
|||
// s->strm->total_out_lo32++;
|
||||
// if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
|
||||
}
|
||||
|
||||
|
||||
/* can a new run be started? */
|
||||
if (s->nblock_used == s->save_nblock+1) return;
|
||||
|
||||
|
||||
if (s->nblock_used == s->save.nblock+1) return;
|
||||
|
||||
|
||||
s->state_out_len = 1;
|
||||
s->state_out_ch = s->k0;
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
s->state_out_len = 2;
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
|
||||
s->state_out_len = 3;
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
if (s->nblock_used == s->save_nblock+1) continue;
|
||||
if (s->nblock_used == s->save.nblock+1) continue;
|
||||
if (k1 != s->k0) { s->k0 = k1; continue; };
|
||||
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
|
||||
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
|
||||
k1 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
s->state_out_len = ((Int32)k1) + 4;
|
||||
BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
|
||||
BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
|
||||
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ void unRLE_obuf_to_output_FAST ( DState* s )
|
|||
/* end restore */
|
||||
|
||||
UInt32 avail_out_INIT = cs_avail_out;
|
||||
Int32 s_save_nblockPP = s->save_nblock+1;
|
||||
Int32 s_save_nblockPP = s->save.nblock+1;
|
||||
// unsigned int total_out_lo32_old;
|
||||
|
||||
while (True) {
|
||||
|
@ -674,7 +674,7 @@ void unRLE_obuf_to_output_FAST ( DState* s )
|
|||
}
|
||||
s_state_out_len_eq_one:
|
||||
{
|
||||
if (cs_avail_out == 0) {
|
||||
if (cs_avail_out == 0) {
|
||||
c_state_out_len = 1; goto return_notr;
|
||||
};
|
||||
*( (UChar*)(cs_next_out) ) = c_state_out_ch;
|
||||
|
@ -682,29 +682,29 @@ void unRLE_obuf_to_output_FAST ( DState* s )
|
|||
cs_next_out++;
|
||||
cs_avail_out--;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* can a new run be started? */
|
||||
if (c_nblock_used == s_save_nblockPP) {
|
||||
c_state_out_len = 0; goto return_notr;
|
||||
};
|
||||
};
|
||||
c_state_out_ch = c_k0;
|
||||
BZ_GET_FAST_C(k1); c_nblock_used++;
|
||||
if (k1 != c_k0) {
|
||||
c_k0 = k1; goto s_state_out_len_eq_one;
|
||||
if (k1 != c_k0) {
|
||||
c_k0 = k1; goto s_state_out_len_eq_one;
|
||||
};
|
||||
if (c_nblock_used == s_save_nblockPP)
|
||||
if (c_nblock_used == s_save_nblockPP)
|
||||
goto s_state_out_len_eq_one;
|
||||
|
||||
|
||||
c_state_out_len = 2;
|
||||
BZ_GET_FAST_C(k1); c_nblock_used++;
|
||||
if (c_nblock_used == s_save_nblockPP) continue;
|
||||
if (k1 != c_k0) { c_k0 = k1; continue; };
|
||||
|
||||
|
||||
c_state_out_len = 3;
|
||||
BZ_GET_FAST_C(k1); c_nblock_used++;
|
||||
if (c_nblock_used == s_save_nblockPP) continue;
|
||||
if (k1 != c_k0) { c_k0 = k1; continue; };
|
||||
|
||||
|
||||
BZ_GET_FAST_C(k1); c_nblock_used++;
|
||||
c_state_out_len = ((Int32)k1) + 4;
|
||||
BZ_GET_FAST_C(c_k0); c_nblock_used++;
|
||||
|
@ -747,7 +747,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
|
|||
#else
|
||||
unRLE_obuf_to_output_FAST ( s );
|
||||
#endif
|
||||
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
|
||||
if (s->nblock_used == s->save.nblock+1 && s->state_out_len == 0) {
|
||||
s->state = BZ_X_BLKHDR_1;
|
||||
} else {
|
||||
return BZ_OK;
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
#include "bzlib.h"
|
||||
|
||||
|
||||
|
||||
/*-- General stuff. --*/
|
||||
|
||||
#define BZ_VERSION "1.0.1, 23-June-2000"
|
||||
|
@ -103,6 +102,7 @@ typedef unsigned short UInt16;
|
|||
#define BZALLOC(items) my_GlobalAlloc(items)
|
||||
#else // def EXEHEAD
|
||||
#define BZALLOC(items) GlobalAlloc(GPTR,items)
|
||||
#define mini_memcpy memcpy
|
||||
#endif // def EXEHEAD
|
||||
#define BZFREE(addr) { if (addr) GlobalFree(addr); }
|
||||
|
||||
|
@ -316,6 +316,34 @@ BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
|
|||
|
||||
|
||||
|
||||
/* save area for scalars in the main decompress code */
|
||||
typedef struct {
|
||||
Int32 i;
|
||||
Int32 j;
|
||||
Int32 t;
|
||||
Int32 alphaSize;
|
||||
Int32 nGroups;
|
||||
Int32 nSelectors;
|
||||
Int32 EOB;
|
||||
Int32 groupNo;
|
||||
Int32 groupPos;
|
||||
Int32 nextSym;
|
||||
Int32 nblockMAX;
|
||||
Int32 nblock;
|
||||
Int32 es;
|
||||
Int32 N;
|
||||
Int32 curr;
|
||||
Int32 zt;
|
||||
Int32 zn;
|
||||
Int32 zvec;
|
||||
Int32 zj;
|
||||
Int32 gSel;
|
||||
Int32 gMinlen;
|
||||
Int32* gLimit;
|
||||
Int32* gBase;
|
||||
Int32* gPerm;
|
||||
} DState_save;
|
||||
|
||||
/*-- Structure holding all the decompression-side stuff. --*/
|
||||
|
||||
typedef
|
||||
|
@ -383,30 +411,7 @@ typedef
|
|||
Int32 minLens[BZ_N_GROUPS];
|
||||
|
||||
/* save area for scalars in the main decompress code */
|
||||
Int32 save_i;
|
||||
Int32 save_j;
|
||||
Int32 save_t;
|
||||
Int32 save_alphaSize;
|
||||
Int32 save_nGroups;
|
||||
Int32 save_nSelectors;
|
||||
Int32 save_EOB;
|
||||
Int32 save_groupNo;
|
||||
Int32 save_groupPos;
|
||||
Int32 save_nextSym;
|
||||
Int32 save_nblockMAX;
|
||||
Int32 save_nblock;
|
||||
Int32 save_es;
|
||||
Int32 save_N;
|
||||
Int32 save_curr;
|
||||
Int32 save_zt;
|
||||
Int32 save_zn;
|
||||
Int32 save_zvec;
|
||||
Int32 save_zj;
|
||||
Int32 save_gSel;
|
||||
Int32 save_gMinlen;
|
||||
Int32* save_gLimit;
|
||||
Int32* save_gBase;
|
||||
Int32* save_gPerm;
|
||||
DState_save save;
|
||||
|
||||
}
|
||||
DState;
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
2. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
|
@ -152,56 +152,35 @@ Int32 BZ2_decompress ( DState* s )
|
|||
bz_stream* strm = s->strm;
|
||||
|
||||
/* stuff that needs to be saved/restored */
|
||||
Int32 i;
|
||||
Int32 j;
|
||||
Int32 t;
|
||||
Int32 alphaSize;
|
||||
Int32 nGroups;
|
||||
Int32 nSelectors;
|
||||
Int32 EOB;
|
||||
Int32 groupNo;
|
||||
Int32 groupPos;
|
||||
Int32 nextSym;
|
||||
Int32 nblockMAX;
|
||||
Int32 nblock;
|
||||
Int32 es;
|
||||
Int32 N;
|
||||
Int32 curr;
|
||||
Int32 zt;
|
||||
Int32 zn;
|
||||
Int32 zvec;
|
||||
Int32 zj;
|
||||
Int32 gSel;
|
||||
Int32 gMinlen;
|
||||
Int32* gLimit;
|
||||
Int32* gBase;
|
||||
Int32* gPerm;
|
||||
DState_save sv;
|
||||
|
||||
/*restore from the save area*/
|
||||
i = s->save_i;
|
||||
j = s->save_j;
|
||||
t = s->save_t;
|
||||
alphaSize = s->save_alphaSize;
|
||||
nGroups = s->save_nGroups;
|
||||
nSelectors = s->save_nSelectors;
|
||||
EOB = s->save_EOB;
|
||||
groupNo = s->save_groupNo;
|
||||
groupPos = s->save_groupPos;
|
||||
nextSym = s->save_nextSym;
|
||||
nblockMAX = s->save_nblockMAX;
|
||||
nblock = s->save_nblock;
|
||||
es = s->save_es;
|
||||
N = s->save_N;
|
||||
curr = s->save_curr;
|
||||
zt = s->save_zt;
|
||||
zn = s->save_zn;
|
||||
zvec = s->save_zvec;
|
||||
zj = s->save_zj;
|
||||
gSel = s->save_gSel;
|
||||
gMinlen = s->save_gMinlen;
|
||||
gLimit = s->save_gLimit;
|
||||
gBase = s->save_gBase;
|
||||
gPerm = s->save_gPerm;
|
||||
mini_memcpy(&sv, &(s->save), sizeof(sv));
|
||||
|
||||
#define i (sv.i)
|
||||
#define j (sv.j)
|
||||
#define t (sv.t)
|
||||
#define alphaSize (sv.alphaSize)
|
||||
#define nGroups (sv.nGroups)
|
||||
#define nSelectors (sv.nSelectors)
|
||||
#define EOB (sv.EOB)
|
||||
#define groupNo (sv.groupNo)
|
||||
#define groupPos (sv.groupPos)
|
||||
#define nextSym (sv.nextSym)
|
||||
#define nblockMAX (sv.nblockMAX)
|
||||
#define nblock (sv.nblock)
|
||||
#define es (sv.es)
|
||||
#define N (sv.N)
|
||||
#define curr (sv.curr)
|
||||
#define zt (sv.zt)
|
||||
#define zn (sv.zn)
|
||||
#define zvec (sv.zvec)
|
||||
#define zj (sv.zj)
|
||||
#define gSel (sv.gSel)
|
||||
#define gMinlen (sv.gMinlen)
|
||||
#define gLimit (sv.gLimit)
|
||||
#define gBase (sv.gBase)
|
||||
#define gPerm (sv.gPerm)
|
||||
|
||||
retVal = BZ_OK;
|
||||
|
||||
|
@ -210,7 +189,7 @@ Int32 BZ2_decompress ( DState* s )
|
|||
|
||||
GET_UCHAR(BZ_X_BLKHDR_1, uc);
|
||||
|
||||
if (uc == 0x17)
|
||||
if (uc == 0x17)
|
||||
{
|
||||
s->state = BZ_X_IDLE;
|
||||
RETURN(BZ_STREAM_END);
|
||||
|
@ -218,7 +197,7 @@ Int32 BZ2_decompress ( DState* s )
|
|||
if (uc != 0x31) RETURN(BZ_DATA_ERROR);
|
||||
|
||||
s->currBlockNo++;
|
||||
|
||||
|
||||
GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
|
||||
|
||||
s->origPtr = 0;
|
||||
|
@ -231,14 +210,14 @@ Int32 BZ2_decompress ( DState* s )
|
|||
|
||||
if (s->origPtr < 0)
|
||||
RETURN(BZ_DATA_ERROR);
|
||||
if (s->origPtr > 10 + NSIS_COMPRESS_BZIP2_LEVEL*100000)
|
||||
if (s->origPtr > 10 + NSIS_COMPRESS_BZIP2_LEVEL*100000)
|
||||
RETURN(BZ_DATA_ERROR);
|
||||
|
||||
/*--- Receive the mapping table ---*/
|
||||
for (i = 0; i < 16; i++) {
|
||||
GET_BIT(BZ_X_MAPPING_1, uc);
|
||||
if (uc == 1)
|
||||
s->inUse16[i] = True; else
|
||||
if (uc == 1)
|
||||
s->inUse16[i] = True; else
|
||||
s->inUse16[i] = False;
|
||||
}
|
||||
|
||||
|
@ -274,7 +253,7 @@ Int32 BZ2_decompress ( DState* s )
|
|||
{
|
||||
UChar pos[BZ_N_GROUPS], tmp, v;
|
||||
for (v = 0; v < nGroups; v++) pos[v] = v;
|
||||
|
||||
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
v = s->selectorMtf[i];
|
||||
tmp = pos[v];
|
||||
|
@ -307,10 +286,10 @@ Int32 BZ2_decompress ( DState* s )
|
|||
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
|
||||
if (s->len[t][i] < minLen) minLen = s->len[t][i];
|
||||
}
|
||||
BZ2_hbCreateDecodeTables (
|
||||
&(s->limit[t][0]),
|
||||
&(s->base[t][0]),
|
||||
&(s->perm[t][0]),
|
||||
BZ2_hbCreateDecodeTables (
|
||||
&(s->limit[t][0]),
|
||||
&(s->base[t][0]),
|
||||
&(s->perm[t][0]),
|
||||
&(s->len[t][0]),
|
||||
minLen, maxLen, alphaSize
|
||||
);
|
||||
|
@ -402,23 +381,23 @@ Int32 BZ2_decompress ( DState* s )
|
|||
nn -= 4;
|
||||
}
|
||||
*/
|
||||
while (nn > 0) {
|
||||
s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
|
||||
while (nn > 0) {
|
||||
s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
|
||||
};
|
||||
s->mtfa[pp] = uc;
|
||||
} else {
|
||||
} else {
|
||||
/* general case */
|
||||
lno = nn / MTFL_SIZE;
|
||||
off = nn % MTFL_SIZE;
|
||||
pp = s->mtfbase[lno] + off;
|
||||
uc = s->mtfa[pp];
|
||||
while (pp > s->mtfbase[lno]) {
|
||||
s->mtfa[pp] = s->mtfa[pp-1]; pp--;
|
||||
while (pp > s->mtfbase[lno]) {
|
||||
s->mtfa[pp] = s->mtfa[pp-1]; pp--;
|
||||
};
|
||||
s->mtfbase[lno]++;
|
||||
while (lno > 0) {
|
||||
s->mtfbase[lno]--;
|
||||
s->mtfa[s->mtfbase[lno]]
|
||||
s->mtfa[s->mtfbase[lno]]
|
||||
= s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
|
||||
lno--;
|
||||
}
|
||||
|
@ -440,7 +419,7 @@ Int32 BZ2_decompress ( DState* s )
|
|||
|
||||
s->unzftab[s->seqToUnseq[uc]]++;
|
||||
#ifdef NSIS_COMPRESS_BZIP2_SMALLMODE
|
||||
s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]);
|
||||
s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]);
|
||||
#else
|
||||
s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
|
||||
#endif
|
||||
|
@ -494,7 +473,7 @@ Int32 BZ2_decompress ( DState* s )
|
|||
if (s->blockRandomised) {
|
||||
BZ_RAND_INIT_MASK;
|
||||
BZ_GET_SMALL(s->k0); s->nblock_used++;
|
||||
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
|
||||
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
|
||||
} else {
|
||||
BZ_GET_SMALL(s->k0); s->nblock_used++;
|
||||
}
|
||||
|
@ -514,7 +493,7 @@ Int32 BZ2_decompress ( DState* s )
|
|||
if (s->blockRandomised) {
|
||||
BZ_RAND_INIT_MASK;
|
||||
BZ_GET_FAST(s->k0); s->nblock_used++;
|
||||
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
|
||||
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
|
||||
} else {
|
||||
BZ_GET_FAST(s->k0); s->nblock_used++;
|
||||
}
|
||||
|
@ -529,36 +508,38 @@ Int32 BZ2_decompress ( DState* s )
|
|||
|
||||
save_state_and_return:
|
||||
|
||||
s->save_i = i;
|
||||
s->save_j = j;
|
||||
s->save_t = t;
|
||||
s->save_alphaSize = alphaSize;
|
||||
s->save_nGroups = nGroups;
|
||||
s->save_nSelectors = nSelectors;
|
||||
s->save_EOB = EOB;
|
||||
s->save_groupNo = groupNo;
|
||||
s->save_groupPos = groupPos;
|
||||
s->save_nextSym = nextSym;
|
||||
s->save_nblockMAX = nblockMAX;
|
||||
s->save_nblock = nblock;
|
||||
s->save_es = es;
|
||||
s->save_N = N;
|
||||
s->save_curr = curr;
|
||||
s->save_zt = zt;
|
||||
s->save_zn = zn;
|
||||
s->save_zvec = zvec;
|
||||
s->save_zj = zj;
|
||||
s->save_gSel = gSel;
|
||||
s->save_gMinlen = gMinlen;
|
||||
s->save_gLimit = gLimit;
|
||||
s->save_gBase = gBase;
|
||||
s->save_gPerm = gPerm;
|
||||
mini_memcpy(&(s->save), &sv, sizeof(sv));
|
||||
|
||||
return retVal;
|
||||
#undef i
|
||||
#undef j
|
||||
#undef t
|
||||
#undef alphaSize
|
||||
#undef nGroups
|
||||
#undef nSelectors
|
||||
#undef EOB
|
||||
#undef groupNo
|
||||
#undef groupPos
|
||||
#undef nextSym
|
||||
#undef nblockMAX
|
||||
#undef nblock
|
||||
#undef es
|
||||
#undef N
|
||||
#undef curr
|
||||
#undef zt
|
||||
#undef zn
|
||||
#undef zvec
|
||||
#undef zj
|
||||
#undef gSel
|
||||
#undef gMinlen
|
||||
#undef gLimit
|
||||
#undef gBase
|
||||
#undef gPerm
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end decompress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue