Skip to content

Commit

Permalink
15.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Pavlov authored and kornelski committed May 27, 2016
1 parent 7c8a265 commit e24f7fb
Show file tree
Hide file tree
Showing 70 changed files with 697 additions and 328 deletions.
6 changes: 3 additions & 3 deletions C/7zAlloc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zAlloc.c -- Allocation functions
2015-02-21 : Igor Pavlov : Public domain */
2015-11-09 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -26,7 +26,7 @@ void *SzAlloc(void *p, size_t size)
if (size == 0)
return 0;
#ifdef _SZ_ALLOC_DEBUG
fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount);
fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount);
g_allocCount++;
#endif
return malloc(size);
Expand All @@ -51,7 +51,7 @@ void *SzAllocTemp(void *p, size_t size)
if (size == 0)
return 0;
#ifdef _SZ_ALLOC_DEBUG
fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp);
fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp);
g_allocCountTemp++;
#ifdef _WIN32
return HeapAlloc(GetProcessHeap(), 0, size);
Expand Down
63 changes: 31 additions & 32 deletions C/7zArcIn.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zArcIn.c -- 7z Input functions
2015-09-28 : Igor Pavlov : Public domain */
2015-11-13 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -942,7 +942,6 @@ typedef struct
static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
{
UInt64 type = 0;
UInt32 i;
UInt32 numSubDigests = 0;
UInt32 numFolders = p->NumFolders;
UInt32 numUnpackStreams = numFolders;
Expand All @@ -953,6 +952,7 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
RINOK(ReadID(sd, &type));
if (type == k7zIdNumUnpackStream)
{
UInt32 i;
ssi->sdNumSubStreams.Data = sd->Data;
numUnpackStreams = 0;
numSubDigests = 0;
Expand Down Expand Up @@ -1215,7 +1215,6 @@ static SRes SzReadHeader2(
UInt64 type;
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
UInt32 i;
CSubStreamInfo ssi;
const Byte *emptyStreams = 0;
const Byte *emptyFiles = 0;
Expand Down Expand Up @@ -1397,22 +1396,22 @@ static SRes SzReadHeader2(
}

{
UInt32 i;
UInt32 emptyFileIndex = 0;

UInt32 folderIndex = 0;
UInt32 indexInFolder = 0;
UInt32 remSubStreams = 0;
UInt32 numSubStreams = 0;
UInt64 unpackPos = 0;
const Byte *digestsDefs = 0;
const Byte *digestsVals = 0;
UInt32 digestsValsIndex = 0;
UInt32 digestIndex;
Byte allDigestsDefined = 0;
UInt32 curNumSubStreams = (UInt32)(Int32)-1;
Byte isDirMask = 0;
Byte crcMask = 0;
Byte mask = 0x80;
// size_t unpSizesOffset = 0;
CSzData sdCodersUnpSizes;

sdCodersUnpSizes.Data = p->db.UnpackSizesData;
sdCodersUnpSizes.Size = p->db.UnpackSizesDataSize;

Expand All @@ -1437,6 +1436,7 @@ static SRes SzReadHeader2(
}

digestIndex = 0;

for (i = 0; i < numFiles; i++, mask >>= 1)
{
if (mask == 0)
Expand All @@ -1451,49 +1451,45 @@ static SRes SzReadHeader2(

p->UnpackPositions[i] = unpackPos;
p->CRCs.Vals[i] = 0;
// p->CRCs.Defs[i] = 0;
if (emptyStreams && SzBitArray_Check(emptyStreams , i))

if (emptyStreams && SzBitArray_Check(emptyStreams, i))
{
if (!emptyFiles || !SzBitArray_Check(emptyFiles, emptyFileIndex))
isDirMask |= mask;
emptyFileIndex++;
if (indexInFolder == 0)
if (remSubStreams == 0)
{
p->FileIndexToFolderIndexMap[i] = (UInt32)-1;
continue;
}
}
if (indexInFolder == 0)

if (remSubStreams == 0)
{
/*
v3.13 incorrectly worked with empty folders
v4.07: Loop for skipping empty folders
*/
for (;;)
{
if (folderIndex >= p->db.NumFolders)
return SZ_ERROR_ARCHIVE;
p->FolderStartFileIndex[folderIndex] = i;
if (curNumSubStreams == (UInt32)(Int32)-1);
numSubStreams = 1;
if (ssi.sdNumSubStreams.Data)
{
curNumSubStreams = 1;
if (ssi.sdNumSubStreams.Data != 0)
{
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &curNumSubStreams));
}
RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams));
}
if (curNumSubStreams != 0)
remSubStreams = numSubStreams;
if (numSubStreams != 0)
break;
curNumSubStreams = (UInt32)(Int32)-1;
folderIndex++; // check it
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
folderIndex++;
}
}

p->FileIndexToFolderIndexMap[i] = folderIndex;
if (emptyStreams && SzBitArray_Check(emptyStreams , i))

if (emptyStreams && SzBitArray_Check(emptyStreams, i))
continue;

indexInFolder++;
if (indexInFolder >= curNumSubStreams)
if (--remSubStreams == 0)
{
UInt64 folderUnpackSize = 0;
UInt64 startFolderUnpackPos;
Expand Down Expand Up @@ -1523,7 +1519,7 @@ static SRes SzReadHeader2(
return SZ_ERROR_ARCHIVE;
unpackPos = startFolderUnpackPos + folderUnpackSize;

if (curNumSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i))
if (numSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i))
{
p->CRCs.Vals[i] = p->db.FolderCRCs.Vals[folderIndex];
crcMask |= mask;
Expand All @@ -1534,14 +1530,16 @@ static SRes SzReadHeader2(
digestsValsIndex++;
crcMask |= mask;
}

folderIndex++;
indexInFolder = 0;
}
else
{
UInt64 v;
RINOK(ReadNumber(&ssi.sdSizes, &v));
unpackPos += v;
if (unpackPos < v)
return SZ_ERROR_ARCHIVE;
if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex)))
{
p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4);
Expand All @@ -1550,12 +1548,14 @@ static SRes SzReadHeader2(
}
}
}

if (mask != 0x80)
{
UInt32 byteIndex = (i - 1) >> 3;
p->IsDirs[byteIndex] = isDirMask;
p->CRCs.Defs[byteIndex] = crcMask;
}

p->UnpackPositions[i] = unpackPos;
p->FolderStartFileIndex[folderIndex] = i;
p->db.FoSizesOffsets[folderIndex] = sdCodersUnpSizes.Data - p->db.UnpackSizesData;
Expand All @@ -1567,9 +1567,8 @@ static SRes SzReadHeader(
CSzArEx *p,
CSzData *sd,
ILookInStream *inStream,
ISzAlloc *allocMain
,ISzAlloc *allocTemp
)
ISzAlloc *allocMain,
ISzAlloc *allocTemp)
{
// Byte *emptyStreamVector = 0;
// Byte *emptyFileVector = 0;
Expand Down
8 changes: 4 additions & 4 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 15
#define MY_VER_MINOR 10
#define MY_VER_MINOR 11
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "15.10"
#define MY_VERSION "15.10 beta"
#define MY_DATE "2015-11-01"
#define MY_VERSION_NUMBERS "15.11"
#define MY_VERSION "15.11 beta"
#define MY_DATE "2015-11-14"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
Expand Down
1 change: 0 additions & 1 deletion C/BwtSort.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,3 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
#endif
return Groups[0];
}

10 changes: 5 additions & 5 deletions C/Lzma2Dec.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Lzma2Dec.c -- LZMA2 Decoder
2014-10-29 : Igor Pavlov : Public domain */
2015-11-09 : Igor Pavlov : Public domain */

/* #define SHOW_DEBUG_INFO */

Expand Down Expand Up @@ -103,8 +103,8 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
{
case LZMA2_STATE_CONTROL:
p->control = b;
PRF(printf("\n %4X ", p->decoder.dicPos));
PRF(printf(" %2X", b));
PRF(printf("\n %4X ", (unsigned)p->decoder.dicPos));
PRF(printf(" %2X", (unsigned)b));
if (p->control == 0)
return LZMA2_STATE_FINISHED;
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
Expand All @@ -124,7 +124,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
case LZMA2_STATE_UNPACK1:
p->unpackSize |= (UInt32)b;
p->unpackSize++;
PRF(printf(" %8d", p->unpackSize));
PRF(printf(" %8u", (unsigned)p->unpackSize));
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;

case LZMA2_STATE_PACK0:
Expand All @@ -134,7 +134,7 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
case LZMA2_STATE_PACK1:
p->packSize |= (UInt32)b;
p->packSize++;
PRF(printf(" %8d", p->packSize));
PRF(printf(" %8u", (unsigned)p->packSize));
return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:
(p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);

Expand Down
8 changes: 5 additions & 3 deletions C/Lzma86Dec.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2009-08-14 : Igor Pavlov : Public domain */
2015-11-08 : Igor Pavlov : Public domain */

#include "Precomp.h"

#include "Lzma86.h"

#include "Alloc.h"
#include "Bra.h"
#include "LzmaDec.h"

static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
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)
{
Expand Down
8 changes: 5 additions & 3 deletions C/Lzma86Enc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
2009-08-14 : Igor Pavlov : Public domain */
2015-11-08 : Igor Pavlov : Public domain */

#include "Precomp.h"

#include <string.h>

Expand All @@ -11,8 +13,8 @@

#define SZE_OUT_OVERFLOW SZE_DATA_ERROR

static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
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)
Expand Down
18 changes: 9 additions & 9 deletions C/LzmaEnc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2015-10-15 Igor Pavlov : Public domain */
2015-11-08 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -854,7 +854,7 @@ static void MovePos(CLzmaEnc *p, UInt32 num)
{
#ifdef SHOW_STAT
g_STAT_OFFSET += num;
printf("\n MovePos %d", num);
printf("\n MovePos %u", num);
#endif

if (num != 0)
Expand All @@ -871,12 +871,12 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);

#ifdef SHOW_STAT
printf("\n i = %d numPairs = %d ", g_STAT_OFFSET, numPairs / 2);
printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2);
g_STAT_OFFSET++;
{
UInt32 i;
for (i = 0; i < numPairs; i += 2)
printf("%2d %6d | ", p->matches[i], p->matches[i + 1]);
printf("%2u %6u | ", p->matches[i], p->matches[i + 1]);
}
#endif

Expand Down Expand Up @@ -1167,12 +1167,12 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
cur = 0;

#ifdef SHOW_STAT2
if (position >= 0)
/* if (position >= 0) */
{
unsigned i;
printf("\n pos = %4X", position);
for (i = cur; i <= lenEnd; i++)
printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price);
printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price);
}
#endif

Expand Down Expand Up @@ -1397,13 +1397,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
{
UInt32 lenTest2 = lenTest + 1;
UInt32 limit = lenTest2 + p->numFastBytes;
UInt32 nextRepMatchPrice;
if (limit > numAvailFull)
limit = numAvailFull;
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
UInt32 nextRepMatchPrice;
UInt32 state2 = kRepNextStates[state];
UInt32 posStateNext = (position + lenTest) & p->pbMask;
UInt32 curAndLenCharPrice =
Expand Down Expand Up @@ -1487,13 +1487,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
const Byte *data2 = data - curBack - 1;
UInt32 lenTest2 = lenTest + 1;
UInt32 limit = lenTest2 + p->numFastBytes;
UInt32 nextRepMatchPrice;
if (limit > numAvailFull)
limit = numAvailFull;
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
UInt32 nextRepMatchPrice;
UInt32 state2 = kMatchNextStates[state];
UInt32 posStateNext = (position + lenTest) & p->pbMask;
UInt32 curAndLenCharPrice = curAndLenPrice +
Expand Down Expand Up @@ -1829,7 +1829,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
len = GetOptimum(p, nowPos32, &pos);

#ifdef SHOW_STAT2
printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos);
printf("\n pos = %4X, len = %u pos = %u", nowPos32, len, pos);
#endif

posState = nowPos32 & p->pbMask;
Expand Down
Loading

0 comments on commit e24f7fb

Please sign in to comment.