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:
eccles 2002-09-27 23:27:36 +00:00
parent b663923ebc
commit d02c47ebd5
3 changed files with 180 additions and 194 deletions

View file

@ -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