This commit is contained in:
Igor Pavlov
2016-05-20 00:00:00 +00:00
committed by Kornel Lesiński
parent 66ac98bb02
commit bec3b479dc
88 changed files with 972 additions and 753 deletions

View File

@@ -1,5 +1,5 @@
/* 7zArcIn.c -- 7z Input functions
2016-03-31 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -1100,13 +1100,11 @@ static SRes SzReadHeader2(
ISzAlloc *allocTemp
)
{
UInt64 type;
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
CSubStreamInfo ssi;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;
{
UInt64 type;
SzData_Clear(&ssi.sdSizes);
SzData_Clear(&ssi.sdCRCs);
SzData_Clear(&ssi.sdNumSubStreams);
@@ -1120,9 +1118,9 @@ static SRes SzReadHeader2(
{
for (;;)
{
UInt64 type;
RINOK(ReadID(sd, &type));
if (type == k7zIdEnd)
UInt64 type2;
RINOK(ReadID(sd, &type2));
if (type2 == k7zIdEnd)
break;
RINOK(SkipData(sd));
}
@@ -1160,6 +1158,13 @@ static SRes SzReadHeader2(
if (type != k7zIdFilesInfo)
return SZ_ERROR_ARCHIVE;
}
{
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;
RINOK(SzReadNumber32(sd, &numFiles));
p->NumFiles = numFiles;
@@ -1458,7 +1463,7 @@ static SRes SzReadHeader2(
if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0)
return SZ_ERROR_ARCHIVE;
}
}
return SZ_OK;
}

View File

@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 16
#define MY_VER_MINOR 00
#define MY_VER_MINOR 01
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "16.00"
#define MY_VERSION "16.00"
#define MY_DATE "2016-05-10"
#define MY_VERSION_NUMBERS "16.01"
#define MY_VERSION "16.01"
#define MY_DATE "2016-05-19"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"

View File

@@ -1,5 +1,5 @@
/* HuffEnc.c -- functions for Huffman encoding
2009-09-02 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -121,8 +121,8 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
i = 0;
for (len = maxLen; len != 0; len--)
{
UInt32 num;
for (num = lenCounters[len]; num != 0; num--)
UInt32 k;
for (k = lenCounters[len]; k != 0; k--)
lens[p[i++] & MASK] = (Byte)len;
}
}
@@ -138,9 +138,9 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
/* if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1; */
{
UInt32 i;
for (i = 0; i < numSymbols; i++)
p[i] = nextCodes[lens[i]]++;
UInt32 k;
for (k = 0; k < numSymbols; k++)
p[k] = nextCodes[lens[k]]++;
}
}
}

View File

@@ -1,5 +1,5 @@
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -9,9 +9,6 @@
#include "Bra.h"
#include "LzmaDec.h"
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
{
unsigned i;
@@ -25,7 +22,6 @@ SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
SRes res;
int useFilter;
SizeT inSizePure;

View File

@@ -1,5 +1,5 @@
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -13,13 +13,9 @@
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
size_t outSize2 = *destLen;
Byte *filteredStream;
Bool useFilter;

View File

@@ -1,5 +1,5 @@
/* LzmaDec.c -- LZMA Decoder
2015-06-23 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -294,14 +294,14 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
#ifdef _LZMA_SIZE_OPT
{
unsigned limit, offset;
unsigned lim, offset;
CLzmaProb *probLen = prob + LenChoice;
IF_BIT_0(probLen)
{
UPDATE_0(probLen);
probLen = prob + LenLow + (posState << kLenNumLowBits);
offset = 0;
limit = (1 << kLenNumLowBits);
lim = (1 << kLenNumLowBits);
}
else
{
@@ -312,17 +312,17 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
UPDATE_0(probLen);
probLen = prob + LenMid + (posState << kLenNumMidBits);
offset = kLenNumLowSymbols;
limit = (1 << kLenNumMidBits);
lim = (1 << kLenNumMidBits);
}
else
{
UPDATE_1(probLen);
probLen = prob + LenHigh;
offset = kLenNumLowSymbols + kLenNumMidSymbols;
limit = (1 << kLenNumHighBits);
lim = (1 << kLenNumHighBits);
}
}
TREE_DECODE(probLen, limit, len);
TREE_DECODE(probLen, lim, len);
len += offset;
}
#else

View File

@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -108,7 +108,7 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
#define kDicLogSizeMaxCompress 32
#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
#define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); res = (zz + zz) + ((pos >> (zz - 1)) & 1); }
static UInt32 GetPosSlot1(UInt32 pos)
{
@@ -145,19 +145,19 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos)
/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */
/*
#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \
(0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
res = p->g_FastPos[pos >> zz] + (zz * 2); }
*/
/*
#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \
(0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
res = p->g_FastPos[pos >> zz] + (zz * 2); }
*/
#define BSR2_RET(pos, res) { UInt32 i = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \
res = p->g_FastPos[pos >> i] + (i * 2); }
#define BSR2_RET(pos, res) { UInt32 zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \
res = p->g_FastPos[pos >> zz] + (zz * 2); }
/*
#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
@@ -983,12 +983,17 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
{
UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
UInt32 matchPrice, repMatchPrice, normalMatchPrice;
UInt32 lenEnd, cur;
UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
UInt32 *matches;
{
UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, len;
UInt32 matchPrice, repMatchPrice, normalMatchPrice;
const Byte *data;
Byte curByte, matchByte;
if (p->optimumEndIndex != p->optimumCurrentIndex)
{
const COptimal *opt = &p->opt[p->optimumCurrentIndex];
@@ -1176,8 +1181,11 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
#endif
}
for (;;)
{
UInt32 numAvail;
UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
Bool nextIsChar;
@@ -1465,6 +1473,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
for (lenTest = /*2*/ startLen; ; lenTest++)
{
UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
{
UInt32 lenToPosState = GetLenToPosState(lenTest);
COptimal *opt;
if (curBack < kNumFullDistances)
@@ -1480,6 +1489,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->backPrev = curBack + LZMA_NUM_REPS;
opt->prev1IsChar = False;
}
}
if (/*_maxMode && */lenTest == matches[offs])
{
@@ -1509,15 +1519,15 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
UInt32 offset = cur + lenTest + 1 + lenTest2;
UInt32 curAndLenPrice;
UInt32 curAndLenPrice2;
COptimal *opt;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
curAndLenPrice2 = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
opt = &p->opt[offset];
if (curAndLenPrice < opt->price)
if (curAndLenPrice2 < opt->price)
{
opt->price = curAndLenPrice;
opt->price = curAndLenPrice2;
opt->posPrev = cur + lenTest + 1;
opt->backPrev = 0;
opt->prev1IsChar = True;
@@ -1718,7 +1728,6 @@ static void FillDistancesPrices(CLzmaEnc *p)
{
UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
UInt32 i;
for (i = 0; i < kStartPosModelIndex; i++)
distancesPrices[i] = posSlotPrices[i];
for (; i < kNumFullDistances; i++)

View File

@@ -1,5 +1,5 @@
/* Ppmd.h -- PPMD codec common code
2013-01-18 : Igor Pavlov : Public domain
2016-05-16 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#ifndef __PPMD_H
@@ -77,8 +77,8 @@ typedef
CPpmd_Byte_Ref;
#define PPMD_SetAllBitsIn256Bytes(p) \
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
{ unsigned z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \
p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }}
EXTERN_C_END

View File

@@ -1,5 +1,5 @@
/* Ppmd8.c -- PPMdI codec
2015-09-28 : Igor Pavlov : Public domain
2016-05-16 : Igor Pavlov : Public domain
This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
#include "Precomp.h"
@@ -240,8 +240,8 @@ static void *AllocUnits(CPpmd8 *p, unsigned indx)
}
#define MyMem12Cpy(dest, src, num) \
{ UInt32 *d = (UInt32 *)dest; const UInt32 *s = (const UInt32 *)src; UInt32 n = num; \
do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while (--n); }
{ UInt32 *d = (UInt32 *)dest; const UInt32 *z = (const UInt32 *)src; UInt32 n = num; \
do { d[0] = z[0]; d[1] = z[1]; d[2] = z[2]; z += 3; d += 3; } while (--n); }
static void *ShrinkUnits(CPpmd8 *p, void *oldPtr, unsigned oldNU, unsigned newNU)
{
@@ -772,7 +772,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
if (SUCCESSOR(s) <= upBranch)
{
CTX_PTR successor;
CPpmd_State *s1 = p->FoundState;
CPpmd_State *s2 = p->FoundState;
p->FoundState = s;
successor = CreateSuccessors(p, False, NULL, c);
@@ -780,7 +780,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
SetSuccessor(s, 0);
else
SetSuccessor(s, REF(successor));
p->FoundState = s1;
p->FoundState = s2;
}
if (p->OrderFall == 1 && c1 == p->MaxContext)
@@ -924,19 +924,19 @@ static void UpdateModel(CPpmd8 *p)
}
else
{
CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0);
if (!s)
CPpmd_State *s2 = (CPpmd_State*)AllocUnits(p, 0);
if (!s2)
{
RESTORE_MODEL(c, CTX(fSuccessor));
return;
}
*s = *ONE_STATE(c);
c->Stats = REF(s);
if (s->Freq < MAX_FREQ / 4 - 1)
s->Freq <<= 1;
*s2 = *ONE_STATE(c);
c->Stats = REF(s2);
if (s2->Freq < MAX_FREQ / 4 - 1)
s2->Freq <<= 1;
else
s->Freq = MAX_FREQ - 4;
c->SummFreq = (UInt16)(s->Freq + p->InitEsc + (ns > 2));
s2->Freq = MAX_FREQ - 4;
c->SummFreq = (UInt16)(s2->Freq + p->InitEsc + (ns > 2));
}
cf = 2 * fFreq * (c->SummFreq + 6);
sf = (UInt32)s0 + c->SummFreq;
@@ -951,10 +951,10 @@ static void UpdateModel(CPpmd8 *p)
c->SummFreq = (UInt16)(c->SummFreq + cf);
}
{
CPpmd_State *s = STATS(c) + ns1 + 1;
SetSuccessor(s, successor);
s->Symbol = fSymbol;
s->Freq = (Byte)cf;
CPpmd_State *s2 = STATS(c) + ns1 + 1;
SetSuccessor(s2, successor);
s2->Symbol = fSymbol;
s2->Freq = (Byte)cf;
c->Flags |= flag;
c->NumStats = (Byte)(ns1 + 1);
}

View File

@@ -1,5 +1,5 @@
/* 7zMain.c - Test application for 7z Decoder
2015-08-02 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -310,10 +310,10 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)
ms[1] = 29;
for (mon = 0;; mon++)
{
unsigned s = ms[mon];
if (v < s)
unsigned d = ms[mon];
if (v < d)
break;
v -= s;
v -= d;
}
s = UIntToStr(s, year, 4); *s++ = '-';
UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3;

View File

@@ -1,5 +1,5 @@
/* 7zipUninstall.c - 7-Zip Uninstaller
2015-12-26 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -362,9 +362,11 @@ static void WriteCLSID()
{
if (AreEqual_Path_PrefixName(s, path, L"7-zip.dll"))
{
LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
if (res == ERROR_SUCCESS)
MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip);
{
LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
if (res == ERROR_SUCCESS)
MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip);
}
{
unsigned i;
@@ -397,9 +399,11 @@ static void WriteCLSID()
{
if (AreEqual_Path_PrefixName(s, path, L"7-zip32.dll"))
{
LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
if (res == ERROR_SUCCESS)
MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip);
{
LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
if (res == ERROR_SUCCESS)
MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip);
}
{
unsigned i;

View File

@@ -1,5 +1,5 @@
/* SfxSetup.c - 7z SFX Setup
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -396,11 +396,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
{
size_t offset = 0;
size_t outSizeProcessed = 0;
size_t len;
WCHAR *temp;
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
if (len >= MAX_PATH)
if (SzArEx_GetFileNameUtf16(&db, i, NULL) >= MAX_PATH)
{
res = SZ_ERROR_FAIL;
break;