void unReduce(void) /* expand probablisticly reduced data */ { int lchar; int lout; int I; factor = cmethod - 1; if ((factor < 1) || (factor > 4)) { skip_csize(); return; } ExState = 0; LoadFollowers(); lchar = 0; while ((!zipeof) && (outpos < cusize)) { if (Slen[lchar] == 0) ReadBits(8,&lout); else { ReadBits(1,&lout); if (lout != 0) ReadBits(8,&lout); else { ReadBits(reduce_B(Slen[lchar]),&I); lout = followers[lchar][I]; } } Expand(lout); lchar = lout; } }
void CZipArchive::unReduce() /* expand probabilistically reduced data */ { int lchar; int nchar; int ExState; int V; int Len; factor = lrec.compression_method - 1; ExState = 0; lchar = 0; LoadFollowers(); while (((outpos + outcnt) < ucsize) && (!zipeof)) { if (Slen[lchar] == 0) READBIT(8, nchar) /* ; */ else { READBIT(1, nchar); if (nchar != 0) READBIT(8, nchar) /* ; */ else { int follower; int bitsneeded = B_table[Slen[lchar]]; READBIT(bitsneeded, follower); nchar = followers[lchar][follower]; } } /* expand the resulting byte */ switch (ExState) { case 0: if (nchar != DLE) OUTB(nchar); else ExState = 1; break; case 1: if (nchar != 0) { V = nchar; Len = V & L_table[factor]; if (Len == L_table[factor]) ExState = 2; else ExState = 3; } else { OUTB(DLE); ExState = 0; } break; case 2:{ Len += nchar; ExState = 3; } break; case 3:{ int i = Len + 3; int offset = (((V >> D_shift[factor]) & D_mask[factor]) << 8) + nchar + 1; long int op = (outpos + outcnt) - offset; /* special case- before start of file */ while ((op < 0L) && (i > 0)) { OUTB(0); op++; i--; } /* normal copy of data from output buffer */ { register int ix = (int) (op % OUTBUFSIZ); /* do a block memory copy if possible */ if (((ix + i) < OUTBUFSIZ) && ((outcnt + i) < OUTBUFSIZ)) { memcpy(outptr, &outbuf[ix], i); outptr += i; outcnt += i; } /* otherwise copy byte by byte */ else while (i--) { OUTB(outbuf[ix]); if (++ix >= OUTBUFSIZ) ix = 0; } } ExState = 0; } break; } /* store character for next iteration */ lchar = nchar; } }