Imported Upstream version 4.57~dfsg.1

parent 0263273e
......@@ -5,8 +5,6 @@
#include "../../Types.h"
#define HUFFMAN_TEMP_SIZE(num) (num * 2)
/*
Conditions:
num <= 1024 = 2 ^ NUM_BITS
......
......@@ -142,18 +142,11 @@ void MtSync_Init(CMtSync *p) { p->needStart = True; }
#define kMtMaxValForNormalize 0xFFFFFFFF
/*
Notes:
instead of "size_t pos" we can use "UInt32 pos".
But MSVC++ compilers have BUG:
sometimes they use signed extending: (size_t)pos was compiled to "movsxd r10, edx"
*/
#define DEF_GetHeads(name, v) \
static void GetHeads ## name(const Byte *p, size_t pos, \
static void GetHeads ## name(const Byte *p, UInt32 pos, \
UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads) { \
for (; numHeads != 0; numHeads--) { \
const UInt32 value = (v); p++; *heads++ = (UInt32)pos - hash[value]; hash[value] = (UInt32)(pos++); } }
const UInt32 value = (v); p++; *heads++ = pos - hash[value]; hash[value] = pos++; } }
DEF_GetHeads(2, (p[0] | ((UInt32)p[1] << 8)) & hashMask)
DEF_GetHeads(3, (g_CrcTable[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask)
......
......@@ -38,7 +38,7 @@ typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distance
/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
#define kMtCacheLineDummy 128
typedef void (*Mf_GetHeads)(const Byte *buffer, size_t pos,
typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads);
typedef struct _CMatchFinderMt
......
// Thresds.h
// Threads.h
#ifndef __7Z_THRESDS_H
#define __7Z_THRESDS_H
......
......@@ -61,8 +61,6 @@ typedef UInt64 CFileSize;
#define SZ_RESULT int
#include <errno.h>
typedef int HRes;
#define RES_OK (0)
......@@ -71,14 +69,8 @@ typedef int HRes;
#define SZE_CRC_ERROR (3)
#define SZE_ARCHIVE_ERROR (6)
#include <errno.h>
#define SZE_OUTOFMEMORY (ENOMEM)
/*
#define SZE_OUTOFMEMORY (0x8007000EL)
#define SZE_NOTIMPL (0x80004001L)
#define SZE_FAIL (0x80004005L)
#define SZE_INVALIDARG (0x80070057L)
*/
#ifndef RINOK
#define RINOK(x) { HRes __result_ = (x); if(__result_ != 0) return __result_; }
......
......@@ -195,7 +195,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
0,
#endif
startIndex,
&efi.ExtractStatuses, extractCallback, testMode);
&efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0);
RINOK(result);
......
......@@ -113,13 +113,14 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value)
{
*value = 0;
if (subStream < Sizes.Size())
int subStreamIndex = (int)subStream;
if (subStreamIndex < 0 || subStream > Sizes.Size())
return E_FAIL;
if (subStreamIndex < Sizes.Size())
{
*value= Sizes[(int)(ptrdiff_t)subStream];
*value= Sizes[subStreamIndex];
return S_OK;
}
if (subStream > Sizes.Size())
return E_FAIL;
if (!_currentSizeIsDefined)
return S_FALSE;
*value = _currentSize;
......
......@@ -19,7 +19,8 @@ HRESULT CFolderOutStream::Init(
UInt32 startIndex,
const CBoolVector *extractStatuses,
IArchiveExtractCallback *extractCallback,
bool testMode)
bool testMode,
bool checkCrc)
{
_archiveDatabase = archiveDatabase;
_ref2Offset = ref2Offset;
......@@ -29,6 +30,8 @@ HRESULT CFolderOutStream::Init(
_extractCallback = extractCallback;
_testMode = testMode;
_checkCrc = checkCrc;
_currentIndex = 0;
_fileIsOpen = false;
return WriteEmptyFiles();
......@@ -49,7 +52,7 @@ HRESULT CFolderOutStream::OpenFile()
RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
_outStreamWithHashSpec->SetStream(realOutStream);
_outStreamWithHashSpec->Init();
_outStreamWithHashSpec->Init(_checkCrc);
if (askMode == NArchive::NExtract::NAskMode::kExtract &&
(!realOutStream))
{
......@@ -100,7 +103,7 @@ STDMETHODIMP CFolderOutStream::Write(const void *data,
if (_filePos == fileSize)
{
bool digestsAreEqual;
if (fileInfo.IsFileCRCDefined)
if (fileInfo.IsFileCRCDefined && _checkCrc)
digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC();
else
digestsAreEqual = true;
......
......@@ -36,6 +36,8 @@ private:
bool _testMode;
bool _fileIsOpen;
bool _checkCrc;
UInt64 _filePos;
HRESULT OpenFile();
......@@ -47,7 +49,8 @@ public:
UInt32 startIndex,
const CBoolVector *extractStatuses,
IArchiveExtractCallback *extractCallback,
bool testMode);
bool testMode,
bool checkCrc);
HRESULT FlushCorrupted(Int32 resultEOperationResult);
HRESULT WasWritingFinished();
};
......
......@@ -33,6 +33,8 @@ namespace N7z {
CHandler::CHandler()
{
_crcSize = 4;
#ifdef EXTRACT_ONLY
#ifdef COMPRESS_MT
_numThreads = NWindows::NSystem::GetNumberOfProcessors();
......
......@@ -110,7 +110,9 @@ private:
#ifdef COMPRESS_MT
UInt32 _numThreads;
#endif
UInt32 _crcSize;
#else
CRecordVector<CBind> _binds;
......
......@@ -759,9 +759,23 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
li.ResetInterval = ReadUInt32();
li.WindowSize = ReadUInt32();
li.CacheSize = ReadUInt32();
if (li.ResetInterval != 2 && li.ResetInterval != 4)
if (
li.ResetInterval != 1 &&
li.ResetInterval != 2 &&
li.ResetInterval != 4 &&
li.ResetInterval != 8 &&
li.ResetInterval != 16 &&
li.ResetInterval != 32 &&
li.ResetInterval != 64)
return S_FALSE;
if (li.WindowSize != 2 && li.WindowSize != 4)
if (
li.WindowSize != 1 &&
li.WindowSize != 2 &&
li.WindowSize != 4 &&
li.WindowSize != 8 &&
li.WindowSize != 16 &&
li.WindowSize != 32 &&
li.WindowSize != 64)
return S_FALSE;
numDWORDS -= 5;
while (numDWORDS-- != 0)
......
......@@ -468,6 +468,7 @@ void COutHandler::Init()
_level = 5;
_autoFilter = true;
_volumeMode = false;
_crcSize = 4;
InitSolid();
}
......@@ -481,6 +482,7 @@ void COutHandler::BeforeSetProperty()
mainDicSize = 0xFFFFFFFF;
mainDicMethodIndex = 0xFFFFFFFF;
minNumber = 0;
_crcSize = 4;
}
HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
......@@ -507,6 +509,13 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
return SetSolidSettings(name);
}
if (name == L"CRC")
{
_crcSize = 4;
name.Delete(0, 3);
return ParsePropValue(name, value, _crcSize);
}
UInt32 number;
int index = ParseStringToUInt32(name, number);
UString realName = name.Mid(index);
......
......@@ -26,6 +26,8 @@ public:
UInt32 _numThreads;
#endif
UInt32 _crcSize;
CObjectVector<COneMethodInfo> _methods;
bool _removeSfxBlock;
......
......@@ -109,6 +109,7 @@ namespace NFileHeader
*/
const UInt32 kDataDescriptorSize = 16;
// const UInt32 kDataDescriptor64Size = 16 + 8;
/*
struct CDataDescriptor
{
......
......@@ -437,8 +437,21 @@ HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
if (ReadUInt32() != NSignature::kDataDescriptor)
return S_FALSE;
UInt32 crc = ReadUInt32();
UInt32 packSize = ReadUInt32();
UInt32 unpackSize = ReadUInt32();
UInt64 packSize, unpackSize;
/*
if (IsZip64)
{
packSize = ReadUInt64();
unpackSize = ReadUInt64();
}
else
*/
{
packSize = ReadUInt32();
unpackSize = ReadUInt32();
}
if (crc != item.FileCRC || item.PackSize != packSize || item.UnPackSize != unpackSize)
return S_FALSE;
}
......@@ -681,6 +694,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
// kEndOfCentralDirSignature
// m_Position points to next byte after signature
IsZip64 = false;
items.Clear();
if (progress != 0)
{
......@@ -722,7 +736,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base;
if(m_Signature == NSignature::kZip64EndOfCentralDir)
{
isZip64 = true;
IsZip64 = isZip64 = true;
UInt64 recordSize = ReadUInt64();
/* UInt16 versionMade = */ ReadUInt16();
/* UInt16 versionNeedExtract = */ ReadUInt16();
......
......@@ -95,6 +95,7 @@ class CInArchive
HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset);
public:
CInArchiveInfo m_ArchiveInfo;
bool IsZip64;
HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
......
......@@ -18,6 +18,11 @@ public:
UInt64 GetLocalFullSize() const
{ return FileHeaderWithNameSize + LocalExtraSize + PackSize +
(HasDescriptor() ? NFileHeader::kDataDescriptorSize : 0); };
/*
UInt64 GetLocalFullSize(bool isZip64) const
{ return FileHeaderWithNameSize + LocalExtraSize + PackSize +
(HasDescriptor() ? (isZip64 ? NFileHeader::kDataDescriptor64Size : NFileHeader::kDataDescriptorSize) : 0); };
*/
UInt64 GetLocalExtraPosition() const
{ return LocalHeaderPosition + FileHeaderWithNameSize; };
UInt64 GetDataPosition() const
......
......@@ -30,8 +30,13 @@ using namespace NSynchronization;
namespace NArchive {
namespace NZip {
#ifdef _WIN32
static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
#else
static const Byte kMadeByHostOS = NFileHeader::NHostOS::kUnix;
static const Byte kExtractHostOS = NFileHeader::NHostOS::kUnix;
#endif
static const Byte kMethodForDirectory = NFileHeader::NCompressionMethod::kStored;
static const Byte kExtractVersionForDirectory = NFileHeader::NCompressionMethod::kStoreExtractVersion;
......@@ -267,6 +272,7 @@ void CMtProgressMixer2::Create(IProgress *progress, bool inSizeIsMain)
void CMtProgressMixer2::SetProgressOffset(UInt64 progressOffset)
{
CriticalSection.Enter();
InSizes[1] = OutSizes[1] = 0;
ProgressOffset = progressOffset;
CriticalSection.Leave();
}
......@@ -323,7 +329,9 @@ STDMETHODIMP CMtProgressMixer::SetRatioInfo(const UInt64 *inSize, const UInt64 *
static HRESULT UpdateItemOldData(COutArchive &archive,
IInStream *inStream,
const CUpdateItem &updateItem, CItemEx &item, ICompressProgressInfo *progress,
const CUpdateItem &updateItem, CItemEx &item,
/* bool izZip64, */
ICompressProgressInfo *progress,
UInt64 &complexity)
{
if (updateItem.NewProperties)
......
This diff is collapsed.
This diff is collapsed.
......@@ -46,6 +46,7 @@ ALLFLAGS=-fprofile-arcs -ftest-coverage \
-I../../../../C \
-I../../../../C/Compress/Huffman \
-I../../../../C/Compress/Lz \
-I../../../../C/Crypto/ \
-I../../Compress/LZMA_Alone \
-I../../../../C/Compress/Branch \
-I../../../myWindows \
......@@ -264,10 +265,12 @@ all : copy 7za.exe
$(CXX) -c *.cpp
$(CC) -c *.c
$(CXX) *.o -o 7za.exe -lpthread
ld -r *.o -o 7za.ld
nm -u -C 7za.ld > 7za.undefined
copy:
rm -f *.cpp *.c
cp -p $(SRCS) $(SRCS_C) .
clean:
rm -f 7za.exe *.cpp *.c *.gcov *.gcda *.gcno *.o core
rm -f 7za.exe 7za.ld 7za.undefined *.cpp *.c *.gcov *.gcda *.gcno *.o core
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -139,6 +139,11 @@ STDMETHODIMP CInFileStream::GetSize(UInt64 *size)
//////////////////////////
// COutFileStream
HRESULT COutFileStream::Close()
{
return ConvertBoolToHRESULT(File.Close());
}
STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
#ifdef USE_WIN_FILE
......
......@@ -97,6 +97,8 @@ public:
}
#endif
#endif
HRESULT Close();
UInt64 ProcessedSize;
......
......@@ -40,11 +40,11 @@ static const UInt32 kMatchArrayLimit = kMatchArraySize - kMatchMaxLen * 4 * size
static const UInt32 kBlockUncompressedSizeThreshold = kMaxUncompressedBlockSize -
kMatchMaxLen - kNumOpts;
static const int kMaxCodeBitLength = 15;
static const int kMaxCodeBitLength = 12;
static const int kMaxLevelBitLength = 7;
static Byte kNoLiteralStatPrice = 13;
static Byte kNoLenStatPrice = 13;
static Byte kNoLiteralStatPrice = 12;
static Byte kNoLenStatPrice = 12;
static Byte kNoPosStatPrice = 6;
static Byte g_LenSlots[kNumLenSymbolsMax];
......@@ -282,10 +282,10 @@ NO_INLINE void CCoder::GetMatches()
{
UInt32 numAvail = Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) + 1;
const Byte *pby = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) - 1;
UInt32 distance = distanceTmp[numPairs - 1] + 1;
const Byte *pby2 = pby - (distanceTmp[numPairs - 1] + 1);
if (numAvail > m_MatchMaxLen)
numAvail = m_MatchMaxLen;
for (; len < numAvail && pby[len] == pby[(ptrdiff_t)len - distance]; len++);
for (; len < numAvail && pby[len] == pby2[len]; len++);
m_MatchDistances[i - 1] = (UInt16)len;
}
}
......
......@@ -610,15 +610,14 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
for(i = 0; i < kNumRepDistances; i++)
{
reps[i] = _repDistances[i];
UInt32 backOffset = reps[i] + 1;
if (data[0] != data[(ptrdiff_t)0 - backOffset] || data[1] != data[(ptrdiff_t)1 - backOffset])
const Byte *data2 = data - (reps[i] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
{
repLens[i] = 0;
continue;
}
UInt32 lenTest;
for (lenTest = 2; lenTest < numAvailableBytes &&
data[lenTest] == data[(ptrdiff_t)lenTest - backOffset]; lenTest++);
for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++);
repLens[i] = lenTest;
if (lenTest > repLens[repMaxIndex])
repMaxIndex = i;
......@@ -639,7 +638,7 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
return lenMain;
}
Byte currentByte = *data;
Byte matchByte = data[(ptrdiff_t)0 - reps[0] - 1];
Byte matchByte = *(data - (reps[0] + 1));
if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
{
......@@ -821,13 +820,13 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
UInt32 curPrice = curOptimum.Price;
const Byte *data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
const Byte currentByte = *data;
const Byte matchByte = data[(ptrdiff_t)0 - reps[0] - 1];
const Byte matchByte = *(data - (reps[0] + 1));
UInt32 posState = (position & _posStateMask);
UInt32 curAnd1Price = curPrice +
_isMatch[state.Index][posState].GetPrice0() +
_literalEncoder.GetSubCoder(position, data[(ptrdiff_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);
_literalEncoder.GetSubCoder(position, *(data - 1))->GetPrice(!state.IsCharState(), matchByte, currentByte);
COptimal &nextOptimum = _optimum[cur + 1];
......@@ -870,11 +869,10 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
if (!nextIsChar && matchByte != currentByte) // speed optimization
{
// try Literal + rep0
UInt32 backOffset = reps[0] + 1;
const Byte *data2 = data - (reps[0] + 1);
UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);
UInt32 temp;
for (temp = 1; temp < limit &&
data[temp] == data[(ptrdiff_t)temp - backOffset]; temp++);
for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);
UInt32 lenTest2 = temp - 1;
if (lenTest2 >= 2)
{
......@@ -908,13 +906,11 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)
{
// UInt32 repLen = _matchFinder.GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
UInt32 backOffset = reps[repIndex] + 1;
if (data[0] != data[(ptrdiff_t)0 - backOffset] ||
data[1] != data[(ptrdiff_t)1 - backOffset])
const Byte *data2 = data - (reps[repIndex] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
continue;
UInt32 lenTest;
for (lenTest = 2; lenTest < numAvailableBytes &&
data[lenTest] == data[(ptrdiff_t)lenTest - backOffset]; lenTest++);
for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++);
while(lenEnd < cur + lenTest)
_optimum[++lenEnd].Price = kIfinityPrice;
UInt32 lenTestTemp = lenTest;
......@@ -941,8 +937,7 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
{
UInt32 lenTest2 = lenTest + 1;
UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
for (; lenTest2 < limit &&
data[lenTest2] == data[(ptrdiff_t)lenTest2 - backOffset]; lenTest2++);
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
......@@ -952,8 +947,8 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
UInt32 curAndLenCharPrice =
price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) +
_isMatch[state2.Index][posStateNext].GetPrice0() +
_literalEncoder.GetSubCoder(position + lenTest, data[(ptrdiff_t)lenTest - 1])->GetPrice(
true, data[(ptrdiff_t)lenTest - backOffset], data[lenTest]);
_literalEncoder.GetSubCoder(position + lenTest, data[lenTest - 1])->GetPrice(
true, data2[lenTest], data[lenTest]);
state2.UpdateChar();
posStateNext = (position + lenTest + 1) & _posStateMask;
UInt32 nextRepMatchPrice = curAndLenCharPrice +
......@@ -1025,11 +1020,10 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
if (/*_maxMode && */lenTest == matchDistances[offs])
{
// Try Match + Literal + Rep0
UInt32 backOffset = curBack + 1;
const Byte *data2 = data - (curBack + 1);
UInt32 lenTest2 = lenTest + 1;
UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
for (; lenTest2 < limit &&
data[lenTest2] == data[(ptrdiff_t)lenTest2 - backOffset]; lenTest2++);
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
......@@ -1038,8 +1032,8 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
UInt32 posStateNext = (position + lenTest) & _posStateMask;
UInt32 curAndLenCharPrice = curAndLenPrice +
_isMatch[state2.Index][posStateNext].GetPrice0() +
_literalEncoder.GetSubCoder(position + lenTest, data[(ptrdiff_t)lenTest - 1])->GetPrice(
true, data[(ptrdiff_t)lenTest - backOffset], data[lenTest]);
_literalEncoder.GetSubCoder(position + lenTest, data[lenTest - 1])->GetPrice(
true, data2[lenTest], data[lenTest]);
state2.UpdateChar();
posStateNext = (posStateNext + 1) & _posStateMask;
UInt32 nextRepMatchPrice = curAndLenCharPrice +
......@@ -1105,7 +1099,9 @@ UInt32 CEncoder::ReadMatchDistances(UInt32 &numDistancePairs)
UInt32 distance = _matchDistances[numDistancePairs - 1] + 1;
if (numAvail > kMatchMaxLen)
numAvail = kMatchMaxLen;
for (; lenRes < numAvail && pby[lenRes] == pby[(ptrdiff_t)lenRes - distance]; lenRes++);
const Byte *pby2 = pby - distance;
for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
}
}
_additionalOffset++;
......@@ -1141,14 +1137,14 @@ UInt32 CEncoder::GetOptimumFast(UInt32 &backRes)
for(UInt32 i = 0; i < kNumRepDistances; i++)
{
UInt32 backOffset = _repDistances[i] + 1;
if (data[0] != data[(ptrdiff_t)0 - backOffset] || data[1] != data[(ptrdiff_t)1 - backOffset])
const Byte *data2 = data - (_repDistances[i] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
{
repLens[i] = 0;
continue;
}
UInt32 len;
for (len = 2; len < numAvailableBytes && data[len] == data[(ptrdiff_t)len - backOffset]; len++);
for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++);
if(len >= _numFastBytes)
{
backRes = i;
......@@ -1216,14 +1212,14 @@ UInt32 CEncoder::GetOptimumFast(UInt32 &backRes)
data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
for(UInt32 i = 0; i < kNumRepDistances; i++)
{
UInt32 backOffset = _repDistances[i] + 1;
if (data[1] != data[(ptrdiff_t)1 - backOffset] || data[2] != data[(ptrdiff_t)2 - backOffset])
const Byte *data2 = data - (_repDistances[i] + 1);
if (data[1] != data2[1] || data[2] != data2[2])
{
repLens[i] = 0;
continue;
}
UInt32 len;
for (len = 2; len < numAvailableBytes && data[len] == data[(ptrdiff_t)len - backOffset]; len++);
for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++);
if (len + 1 >= lenMain)
{
_longestMatchWasFound = true;
......
......@@ -159,7 +159,7 @@ int main2(int n, const char *args[])
g_IsNT = IsItWindowsNT();
#endif
fprintf(stderr, "\nLZMA 4.54 Copyright (c) 1999-2007 Igor Pavlov 2007-09-04\n");
fprintf(stderr, "\nLZMA 4.56 Copyright (c) 1999-2007 Igor Pavlov 2007-10-19\n");
if (n == 1)
{
......@@ -276,6 +276,7 @@ int main2(int n, const char *args[])
}
CMyComPtr<ISequentialOutStream> outStream;
COutFileStream *outStreamSpec = NULL;
if (stdOutMode)
{
outStream = new CStdOutFileStream;
......@@ -286,7 +287,7 @@ int main2(int n, const char *args[])
if (paramIndex >= nonSwitchStrings.Size())
IncorrectCommand();
const UString &outputName = nonSwitchStrings[paramIndex++];
COutFileStream *outStreamSpec = new COutFileStream;
outStreamSpec = new COutFileStream;
outStream = outStreamSpec;
if (!outStreamSpec->Create(GetSystemString(outputName), true))
{
......@@ -368,8 +369,7 @@ int main2(int n, const char *args[])
UInt64 fileSize;
if (encodeMode)
{
NCompress::NLZMA::CEncoder *encoderSpec =
new NCompress::NLZMA::CEncoder;
NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
CMyComPtr<ICompressCoder> encoder = encoderSpec;
if (!dictionaryIsDefined)
......@@ -483,8 +483,7 @@ int main2(int n, const char *args[])
}
else
{
NCompress::NLZMA::CDecoder *decoderSpec =
new NCompress::NLZMA::CDecoder;
NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
CMyComPtr<ICompressCoder> decoder = decoderSpec;
const UInt32 kPropertiesSize = 5;
Byte properties[kPropertiesSize];
......@@ -526,6 +525,14 @@ int main2(int n, const char *args[])
return 1;
}
}
if (outStreamSpec != NULL)
{
if (outStreamSpec->Close() != S_OK)
{
fprintf(stderr, "File closing error");
return 1;
}
}
return 0;
}
......
......@@ -133,12 +133,15 @@ clean:
test: $(PROG)
cp LzmaAlone.cpp testfile
./$(PROG) e testfile testfile.ppmd
./$(PROG) d testfile.ppmd testfile.ppmd.d
diff -s testfile testfile.ppmd.d
./$(PROG) e -si -so < testfile > testfile.ppmd.2
./$(PROG) d -si -so < testfile.ppmd.2 > testfile.ppmd.2.d
diff -s testfile testfile.ppmd.2.d
./$(PROG) e testfile testfile.lzma
./$(PROG) d testfile.lzma testfile.lzma.d
diff -s testfile testfile.lzma.d
./$(PROG) e testfile testfile.lzma
./$(PROG) d testfile.lzma testfile.lzma.d
diff -s testfile testfile.lzma.d
./$(PROG) e -si -so < testfile > testfile.lzma.2
./$(PROG) d -si -so < testfile.lzma.2 > testfile.lzma.2.d
diff -s testfile testfile.lzma.2.d
@echo =========
@echo All Done
@echo =========
......
#define MY_VER_MAJOR 4
#define MY_VER_MINOR 55
#define MY_VER_MINOR 57
#define MY_VER_BUILD 0
#define MY_VERSION "4.55 beta"
#define MY_7ZIP_VERSION "7-Zip 4.55 beta"
#define MY_DATE "2007-09-05"
#define MY_VERSION "4.57"
#define MY_7ZIP_VERSION "7-Zip 4.57"
#define MY_DATE "2007-12-06"
#define MY_COPYRIGHT "Copyright (c) 1999-2007 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE