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