Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/C
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2015-09-22 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:55 +0300
commitf6444c32568553e0261ca0105083658f12be6284 (patch)
tree8f4eb80f6accd2a9d0759e2564fd6a2b00836e02 /C
parentcba375916fb18db8b9101aedf4fa079e019311b3 (diff)
15.0715.07
Diffstat (limited to 'C')
-rw-r--r--C/7zVersion.h8
-rw-r--r--C/Lzma2Enc.c39
-rw-r--r--C/Ppmd7.c2
-rw-r--r--C/Ppmd8.c2
-rw-r--r--C/Util/7zipInstall/resource.h4
-rw-r--r--C/Util/7zipUninstall/resource.h4
-rw-r--r--C/XzEnc.c65
7 files changed, 84 insertions, 40 deletions
diff --git a/C/7zVersion.h b/C/7zVersion.h
index 170f7aee..6ddcfcac 100644
--- a/C/7zVersion.h
+++ b/C/7zVersion.h
@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 15
-#define MY_VER_MINOR 06
+#define MY_VER_MINOR 07
#define MY_VER_BUILD 00
-#define MY_VERSION_NUMBERS "15.06"
-#define MY_VERSION "15.06 beta"
-#define MY_DATE "2015-08-09"
+#define MY_VERSION_NUMBERS "15.07"
+#define MY_VERSION "15.07 beta"
+#define MY_DATE "2015-09-17"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
diff --git a/C/Lzma2Enc.c b/C/Lzma2Enc.c
index 07535559..7a0fd7d3 100644
--- a/C/Lzma2Enc.c
+++ b/C/Lzma2Enc.c
@@ -1,5 +1,5 @@
/* Lzma2Enc.c -- LZMA2 Encoder
-2012-06-19 : Igor Pavlov : Public domain */
+2015-09-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -109,6 +109,7 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
{
size_t destPos = 0;
PRF(printf("################# COPY "));
+
while (unpackSize > 0)
{
UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE;
@@ -121,6 +122,7 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
unpackSize -= u;
destPos += u;
p->srcPos += u;
+
if (outStream)
{
*packSizeRes += destPos;
@@ -132,9 +134,11 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
*packSizeRes = destPos;
/* needInitState = True; */
}
+
LzmaEnc_RestoreState(p->enc);
return SZ_OK;
}
+
{
size_t destPos = 0;
UInt32 u = unpackSize - 1;
@@ -160,11 +164,13 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
if (outStream)
if (outStream->Write(outStream, outBuf, destPos) != destPos)
return SZ_ERROR_WRITE;
+
*packSizeRes = destPos;
return SZ_OK;
}
}
+
/* ---------- Lzma2 Props ---------- */
void Lzma2EncProps_Init(CLzma2EncProps *p)
@@ -221,6 +227,8 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
LzmaEncProps_Normalize(&p->lzmaProps);
+ t1 = p->lzmaProps.numThreads;
+
if (p->blockSize == 0)
{
UInt32 dictSize = p->lzmaProps.dictSize;
@@ -232,7 +240,8 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
if (blockSize < dictSize) blockSize = dictSize;
p->blockSize = (size_t)blockSize;
}
- if (t2 > 1)
+
+ if (t2 > 1 && p->lzmaProps.reduceSize != (UInt64)(Int64)-1)
{
UInt64 temp = p->lzmaProps.reduceSize + p->blockSize - 1;
if (temp > p->lzmaProps.reduceSize)
@@ -241,19 +250,24 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
if (numBlocks < (unsigned)t2)
{
t2 = (unsigned)numBlocks;
+ if (t2 == 0)
+ t2 = 1;
t3 = t1 * t2;
}
}
}
+
p->numBlockThreads = t2;
p->numTotalThreads = t3;
}
+
static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
{
return (p && p->Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK;
}
+
/* ---------- Lzma2 ---------- */
typedef struct
@@ -283,15 +297,17 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
UInt64 packTotal = 0;
SRes res = SZ_OK;
- if (mainEncoder->outBuf == 0)
+ if (!mainEncoder->outBuf)
{
mainEncoder->outBuf = (Byte *)IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
- if (mainEncoder->outBuf == 0)
+ if (!mainEncoder->outBuf)
return SZ_ERROR_MEM;
}
+
RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
RINOK(LzmaEnc_PrepareForLzma2(p->enc, inStream, LZMA2_KEEP_WINDOW_SIZE,
mainEncoder->alloc, mainEncoder->allocBig));
+
for (;;)
{
size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;
@@ -305,16 +321,20 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
if (packSize == 0)
break;
}
+
LzmaEnc_Finish(p->enc);
+
if (res == SZ_OK)
{
Byte b = 0;
if (outStream->Write(outStream, &b, 1) != 1)
return SZ_ERROR_WRITE;
}
+
return res;
}
+
#ifndef _7ZIP_ST
typedef struct
@@ -362,10 +382,12 @@ static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *des
break;
}
}
+
LzmaEnc_Finish(p->enc);
if (res != SZ_OK)
return res;
}
+
if (finished)
{
if (*destSize == destLim)
@@ -378,12 +400,13 @@ static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *des
#endif
+
/* ---------- Lzma2Enc ---------- */
CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig)
{
CLzma2Enc *p = (CLzma2Enc *)alloc->Alloc(alloc, sizeof(CLzma2Enc));
- if (p == 0)
+ if (!p)
return NULL;
Lzma2EncProps_Init(&p->props);
Lzma2EncProps_Normalize(&p->props);
@@ -395,6 +418,7 @@ CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig)
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
p->coders[i].enc = 0;
}
+
#ifndef _7ZIP_ST
MtCoder_Construct(&p->mtCoder);
#endif
@@ -456,10 +480,10 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
for (i = 0; i < p->props.numBlockThreads; i++)
{
CLzma2EncInt *t = &p->coders[i];
- if (t->enc == NULL)
+ if (!t->enc)
{
t->enc = LzmaEnc_Create(p->alloc);
- if (t->enc == NULL)
+ if (!t->enc)
return SZ_ERROR_MEM;
}
}
@@ -470,7 +494,6 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
#ifndef _7ZIP_ST
-
{
CMtCallbackImp mtCallback;
diff --git a/C/Ppmd7.c b/C/Ppmd7.c
index bb5d175e..2a37ec3c 100644
--- a/C/Ppmd7.c
+++ b/C/Ppmd7.c
@@ -4,7 +4,7 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#include "Precomp.h"
-#include <memory.h>
+#include <string.h>
#include "Ppmd7.h"
diff --git a/C/Ppmd8.c b/C/Ppmd8.c
index ac8a8354..e8bf65f5 100644
--- a/C/Ppmd8.c
+++ b/C/Ppmd8.c
@@ -4,7 +4,7 @@ This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
#include "Precomp.h"
-#include <memory.h>
+#include <string.h>
#include "Ppmd8.h"
diff --git a/C/Util/7zipInstall/resource.h b/C/Util/7zipInstall/resource.h
index d78be84c..63c6b4c2 100644
--- a/C/Util/7zipInstall/resource.h
+++ b/C/Util/7zipInstall/resource.h
@@ -1,6 +1,6 @@
-#define IDD_INSTALL 100
+#define IDD_INSTALL 100
-#define IDT_EXTRACT_EXTRACT_TO 110
+#define IDT_EXTRACT_EXTRACT_TO 110
#define IDE_EXTRACT_PATH 111
#define IDB_EXTRACT_SET_PATH 112
#define IDT_CUR_FILE 113
diff --git a/C/Util/7zipUninstall/resource.h b/C/Util/7zipUninstall/resource.h
index 701babdb..b5c33ff1 100644
--- a/C/Util/7zipUninstall/resource.h
+++ b/C/Util/7zipUninstall/resource.h
@@ -1,6 +1,6 @@
-#define IDD_INSTALL 100
+#define IDD_INSTALL 100
-#define IDT_EXTRACT_EXTRACT_TO 110
+#define IDT_EXTRACT_EXTRACT_TO 110
#define IDE_EXTRACT_PATH 111
#define IDT_CUR_FILE 113
diff --git a/C/XzEnc.c b/C/XzEnc.c
index 4dd3f9e4..ccac7a8e 100644
--- a/C/XzEnc.c
+++ b/C/XzEnc.c
@@ -1,5 +1,5 @@
/* XzEnc.c -- Xz Encode
-2015-05-01 : Igor Pavlov : Public domain */
+2015-09-16 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -10,6 +10,7 @@
#include "Alloc.h"
#include "Bra.h"
#include "CpuArch.h"
+
#ifdef USE_SUBBLOCK
#include "Bcj3Enc.c"
#include "SbFind.c"
@@ -34,7 +35,7 @@ static SRes WriteBytesAndCrc(ISeqOutStream *s, const void *buf, UInt32 size, UIn
return WriteBytes(s, buf, size);
}
-SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s)
+static SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s)
{
UInt32 crc;
Byte header[XZ_STREAM_HEADER_SIZE];
@@ -46,7 +47,8 @@ SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s)
return WriteBytes(s, header, XZ_STREAM_HEADER_SIZE);
}
-SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s)
+
+static SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s)
{
Byte header[XZ_BLOCK_HEADER_SIZE_MAX];
@@ -75,7 +77,8 @@ SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s)
return WriteBytes(s, header, pos + 4);
}
-SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)
+
+static SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)
{
Byte buf[32];
UInt64 globalPos;
@@ -87,6 +90,7 @@ SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)
globalPos = pos;
buf[0] = 0;
RINOK(WriteBytesAndCrc(s, buf, pos, &crc));
+
for (i = 0; i < p->numBlocks; i++)
{
const CXzBlockSizes *block = &p->blocks[i];
@@ -95,7 +99,9 @@ SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)
globalPos += pos;
RINOK(WriteBytesAndCrc(s, buf, pos, &crc));
}
+
pos = ((unsigned)globalPos & 3);
+
if (pos != 0)
{
buf[0] = buf[1] = buf[2] = 0;
@@ -120,34 +126,36 @@ SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)
}
}
-SRes Xz_AddIndexRecord(CXzStream *p, UInt64 unpackSize, UInt64 totalSize, ISzAlloc *alloc)
+
+static SRes Xz_AddIndexRecord(CXzStream *p, UInt64 unpackSize, UInt64 totalSize, ISzAlloc *alloc)
{
- if (p->blocks == 0 || p->numBlocksAllocated == p->numBlocks)
+ if (!p->blocks || p->numBlocksAllocated == p->numBlocks)
{
- size_t num = (p->numBlocks + 1) * 2;
+ size_t num = p->numBlocks * 2 + 1;
size_t newSize = sizeof(CXzBlockSizes) * num;
CXzBlockSizes *blocks;
if (newSize / sizeof(CXzBlockSizes) != num)
return SZ_ERROR_MEM;
blocks = (CXzBlockSizes *)alloc->Alloc(alloc, newSize);
- if (blocks == 0)
+ if (!blocks)
return SZ_ERROR_MEM;
if (p->numBlocks != 0)
{
memcpy(blocks, p->blocks, p->numBlocks * sizeof(CXzBlockSizes));
- Xz_Free(p, alloc);
+ alloc->Free(alloc, p->blocks);
}
p->blocks = blocks;
p->numBlocksAllocated = num;
}
{
CXzBlockSizes *block = &p->blocks[p->numBlocks++];
- block->totalSize = totalSize;
block->unpackSize = unpackSize;
+ block->totalSize = totalSize;
}
return SZ_OK;
}
+
/* ---------- CSeqCheckInStream ---------- */
typedef struct
@@ -178,6 +186,7 @@ static SRes SeqCheckInStream_Read(void *pp, void *data, size_t *size)
return res;
}
+
/* ---------- CSeqSizeOutStream ---------- */
typedef struct
@@ -195,6 +204,7 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
return size;
}
+
/* ---------- CSeqInFilter ---------- */
#define FILTER_BUF_SIZE (1 << 20)
@@ -217,6 +227,7 @@ static SRes SeqInFilter_Read(void *pp, void *data, size_t *size)
if (sizeOriginal == 0)
return SZ_OK;
*size = 0;
+
for (;;)
{
if (!p->srcWasFinished && p->curPos == p->endPos)
@@ -274,6 +285,7 @@ static SRes SeqInFilter_Init(CSeqInFilter *p, const CXzFilter *props)
return SZ_OK;
}
+
/* ---------- CSbEncInStream ---------- */
#ifdef USE_SUBBLOCK
@@ -291,6 +303,7 @@ static SRes SbEncInStream_Read(void *pp, void *data, size_t *size)
size_t sizeOriginal = *size;
if (sizeOriginal == 0)
return S_OK;
+
for (;;)
{
if (p->enc.needRead && !p->enc.readWasFinished)
@@ -305,6 +318,7 @@ static SRes SbEncInStream_Read(void *pp, void *data, size_t *size)
}
p->enc.needRead = False;
}
+
*size = sizeOriginal;
RINOK(SbEnc_Read(&p->enc, data, size));
if (*size != 0 || !p->enc.needRead)
@@ -357,7 +371,7 @@ static void Lzma2WithFilters_Construct(CLzma2WithFilters *p, ISzAlloc *alloc, IS
static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p)
{
p->lzma2 = Lzma2Enc_Create(p->alloc, p->bigAlloc);
- if (p->lzma2 == 0)
+ if (!p->lzma2)
return SZ_ERROR_MEM;
return SZ_OK;
}
@@ -375,10 +389,11 @@ static void Lzma2WithFilters_Free(CLzma2WithFilters *p)
}
}
+
void XzProps_Init(CXzProps *p)
{
- p->lzma2Props = 0;
- p->filterProps = 0;
+ p->lzma2Props = NULL;
+ p->filterProps = NULL;
p->checkId = XZ_CHECK_CRC32;
}
@@ -386,10 +401,11 @@ void XzFilterProps_Init(CXzFilterProps *p)
{
p->id = 0;
p->delta = 0;
- p->ip= 0;
+ p->ip = 0;
p->ipDefined = False;
}
+
static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
ISeqOutStream *outStream, ISeqInStream *inStream,
const CXzProps *props, ICompressProgress *progress)
@@ -415,6 +431,7 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
filter = &block.filters[filterIndex++];
filter->id = fp->id;
filter->propsSize = 0;
+
if (fp->id == XZ_ID_Delta)
{
filter->props[0] = (Byte)(fp->delta - 1);
@@ -462,14 +479,16 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
{
UInt64 packPos = seqSizeOutStream.processed;
+
SRes res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p,
- fp ?
- #ifdef USE_SUBBLOCK
- (fp->id == XZ_ID_Subblock) ? &lzmaf->sb.p:
- #endif
- &lzmaf->filter.p:
- &checkInStream.p,
- progress);
+ fp ?
+ #ifdef USE_SUBBLOCK
+ (fp->id == XZ_ID_Subblock) ? &lzmaf->sb.p:
+ #endif
+ &lzmaf->filter.p:
+ &checkInStream.p,
+ progress);
+
RINOK(res);
block.unpackSize = checkInStream.processed;
block.packSize = seqSizeOutStream.processed - packPos;
@@ -478,7 +497,7 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
{
unsigned padSize = 0;
Byte buf[128];
- while((((unsigned)block.packSize + padSize) & 3) != 0)
+ while ((((unsigned)block.packSize + padSize) & 3) != 0)
buf[padSize++] = 0;
SeqCheckInStream_GetDigest(&checkInStream, buf + padSize);
RINOK(WriteBytes(&seqSizeOutStream.p, buf, padSize + XzFlags_GetCheckSize(xz->flags)));
@@ -488,6 +507,7 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
return Xz_WriteFooter(xz, outStream);
}
+
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
const CXzProps *props, ICompressProgress *progress)
{
@@ -504,6 +524,7 @@ SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
return res;
}
+
SRes Xz_EncodeEmpty(ISeqOutStream *outStream)
{
SRes res;