From 79bef1e23049fdac25f1fefd132e0b6c7d2cc3a1 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 6 Dec 2023 07:58:49 +1100 Subject: 3rdparty/lzma: Updated to version 23.01. --- 3rdparty/lzma/C/Util/7z/7z.dsp | 8 +- 3rdparty/lzma/C/Util/7z/7zMain.c | 85 +++++++-------- 3rdparty/lzma/C/Util/7z/Precomp.h | 10 +- 3rdparty/lzma/C/Util/7z/makefile | 2 +- 3rdparty/lzma/C/Util/7z/makefile.gcc | 4 +- 3rdparty/lzma/C/Util/Lzma/LzmaUtil.c | 145 +++++++++++++++----------- 3rdparty/lzma/C/Util/Lzma/LzmaUtil.dsp | 16 +++ 3rdparty/lzma/C/Util/Lzma/Precomp.h | 14 +++ 3rdparty/lzma/C/Util/LzmaLib/LzmaLib.dsp | 20 ++++ 3rdparty/lzma/C/Util/LzmaLib/LzmaLibExports.c | 13 +-- 3rdparty/lzma/C/Util/LzmaLib/Precomp.c | 4 + 3rdparty/lzma/C/Util/LzmaLib/Precomp.h | 14 +++ 3rdparty/lzma/C/Util/LzmaLib/makefile | 22 +++- 3rdparty/lzma/C/Util/SfxSetup/Precomp.h | 10 +- 3rdparty/lzma/C/Util/SfxSetup/SfxSetup.c | 46 +++++--- 3rdparty/lzma/C/Util/SfxSetup/makefile | 3 + 3rdparty/lzma/C/Util/SfxSetup/makefile_con | 4 +- 17 files changed, 283 insertions(+), 137 deletions(-) create mode 100644 3rdparty/lzma/C/Util/Lzma/Precomp.h create mode 100644 3rdparty/lzma/C/Util/LzmaLib/Precomp.c create mode 100644 3rdparty/lzma/C/Util/LzmaLib/Precomp.h (limited to '3rdparty/lzma/C/Util') diff --git a/3rdparty/lzma/C/Util/7z/7z.dsp b/3rdparty/lzma/C/Util/7z/7z.dsp index be0f0a74376..11e1b03e504 100644 --- a/3rdparty/lzma/C/Util/7z/7z.dsp +++ b/3rdparty/lzma/C/Util/7z/7z.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c +# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "Z7_PPMD_SUPPORT" /FAcs /Yu"Precomp.h" /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c +# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "Z7_PPMD_SUPPORT" /Yu"Precomp.h" /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe @@ -145,6 +145,10 @@ SOURCE=..\..\7zTypes.h # End Source File # Begin Source File +SOURCE=..\..\7zWindows.h +# End Source File +# Begin Source File + SOURCE=..\..\Bcj2.c # End Source File # Begin Source File diff --git a/3rdparty/lzma/C/Util/7z/7zMain.c b/3rdparty/lzma/C/Util/7z/7zMain.c index 9d555098e29..547920ac31f 100644 --- a/3rdparty/lzma/C/Util/7z/7zMain.c +++ b/3rdparty/lzma/C/Util/7z/7zMain.c @@ -1,5 +1,5 @@ /* 7zMain.c - Test application for 7z Decoder -2021-04-29 : Igor Pavlov : Public domain */ +2023-04-04 : Igor Pavlov : Public domain */ #include "Precomp.h" @@ -32,10 +32,10 @@ #endif #endif - #define kInputBufSize ((size_t)1 << 18) static const ISzAlloc g_Alloc = { SzAlloc, SzFree }; +// static const ISzAlloc g_Alloc_temp = { SzAllocTemp, SzFreeTemp }; static void Print(const char *s) @@ -53,19 +53,19 @@ static int Buf_EnsureSize(CBuf *dest, size_t size) } #ifndef _WIN32 -#define _USE_UTF8 +#define MY_USE_UTF8 #endif -/* #define _USE_UTF8 */ +/* #define MY_USE_UTF8 */ -#ifdef _USE_UTF8 +#ifdef MY_USE_UTF8 -#define _UTF8_START(n) (0x100 - (1 << (7 - (n)))) +#define MY_UTF8_START(n) (0x100 - (1 << (7 - (n)))) -#define _UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6)) +#define MY_UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6)) -#define _UTF8_HEAD(n, val) ((Byte)(_UTF8_START(n) + (val >> (6 * (n))))) -#define _UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F))) +#define MY_UTF8_HEAD(n, val) ((Byte)(MY_UTF8_START(n) + (val >> (6 * (n))))) +#define MY_UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F))) static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) { @@ -82,7 +82,7 @@ static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) if (val < 0x80) continue; - if (val < _UTF8_RANGE(1)) + if (val < MY_UTF8_RANGE(1)) { size++; continue; @@ -90,7 +90,7 @@ static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) if (val >= 0xD800 && val < 0xDC00 && src != srcLim) { - UInt32 c2 = *src; + const UInt32 c2 = *src; if (c2 >= 0xDC00 && c2 < 0xE000) { src++; @@ -119,33 +119,33 @@ static Byte *Utf16_To_Utf8(Byte *dest, const UInt16 *src, const UInt16 *srcLim) continue; } - if (val < _UTF8_RANGE(1)) + if (val < MY_UTF8_RANGE(1)) { - dest[0] = _UTF8_HEAD(1, val); - dest[1] = _UTF8_CHAR(0, val); + dest[0] = MY_UTF8_HEAD(1, val); + dest[1] = MY_UTF8_CHAR(0, val); dest += 2; continue; } if (val >= 0xD800 && val < 0xDC00 && src != srcLim) { - UInt32 c2 = *src; + const UInt32 c2 = *src; if (c2 >= 0xDC00 && c2 < 0xE000) { src++; val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; - dest[0] = _UTF8_HEAD(3, val); - dest[1] = _UTF8_CHAR(2, val); - dest[2] = _UTF8_CHAR(1, val); - dest[3] = _UTF8_CHAR(0, val); + dest[0] = MY_UTF8_HEAD(3, val); + dest[1] = MY_UTF8_CHAR(2, val); + dest[2] = MY_UTF8_CHAR(1, val); + dest[3] = MY_UTF8_CHAR(0, val); dest += 4; continue; } } - dest[0] = _UTF8_HEAD(2, val); - dest[1] = _UTF8_CHAR(1, val); - dest[2] = _UTF8_CHAR(0, val); + dest[0] = MY_UTF8_HEAD(2, val); + dest[1] = MY_UTF8_CHAR(1, val); + dest[2] = MY_UTF8_CHAR(0, val); dest += 3; } } @@ -163,7 +163,7 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen) #endif static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s - #ifndef _USE_UTF8 + #ifndef MY_USE_UTF8 , UINT codePage #endif ) @@ -171,7 +171,7 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s unsigned len = 0; for (len = 0; s[len] != 0; len++) {} - #ifndef _USE_UTF8 + #ifndef MY_USE_UTF8 { const unsigned size = len * 3 + 100; if (!Buf_EnsureSize(buf, size)) @@ -216,7 +216,7 @@ static WRes MyCreateDir(const UInt16 *name) CBuf buf; WRes res; Buf_Init(&buf); - RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); + RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)) res = #ifdef _WIN32 @@ -239,7 +239,7 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name) CBuf buf; WRes res; Buf_Init(&buf); - RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); + RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)) res = OutFile_Open(p, (const char *)buf.data); Buf_Free(&buf, &g_Alloc); return res; @@ -253,7 +253,7 @@ static SRes PrintString(const UInt16 *s) SRes res; Buf_Init(&buf); res = Utf16_To_Char(&buf, s - #ifndef _USE_UTF8 + #ifndef MY_USE_UTF8 , CP_OEMCP #endif ); @@ -328,12 +328,12 @@ typedef struct _FILETIME static LONG TIME_GetBias() { - time_t utc = time(NULL); + const time_t utc = time(NULL); struct tm *ptm = localtime(&utc); - int localdaylight = ptm->tm_isdst; /* daylight for local timezone */ + const int localdaylight = ptm->tm_isdst; /* daylight for local timezone */ ptm = gmtime(&utc); ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */ - LONG bias = (int)(mktime(ptm)-utc); + const LONG bias = (int)(mktime(ptm) - utc); return bias; } @@ -352,7 +352,7 @@ static BOOL WINAPI FileTimeToLocalFileTime(const FILETIME *fileTime, FILETIME *l { UInt64 v = GET_TIME_64(fileTime); v = (UInt64)((Int64)v - (Int64)TIME_GetBias() * TICKS_PER_SEC); - SET_FILETIME(localFileTime, v); + SET_FILETIME(localFileTime, v) return TRUE; } @@ -364,7 +364,7 @@ static const UInt64 kUnixTimeOffset = static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft) { - UInt64 winTime = GET_TIME_64(ft); + const UInt64 winTime = GET_TIME_64(ft); return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset; } @@ -384,8 +384,8 @@ static void FILETIME_To_timespec(const FILETIME *ft, struct MY_ST_TIMESPEC *ts) if (sec2 == sec) { ts->tv_sec = sec2; - UInt64 winTime = GET_TIME_64(ft); - ts->tv_nsec = (long)((winTime % 10000000) * 100);; + const UInt64 winTime = GET_TIME_64(ft); + ts->tv_nsec = (long)((winTime % 10000000) * 100); return; } } @@ -407,7 +407,7 @@ static WRes Set_File_FILETIME(const UInt16 *name, const FILETIME *mTime) CBuf buf; int res; Buf_Init(&buf); - RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); + RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)) FILETIME_To_timespec(NULL, ×[0]); FILETIME_To_timespec(mTime, ×[1]); res = utimensat(AT_FDCWD, (const char *)buf.data, times, flags); @@ -461,7 +461,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s) ms[1] = 29; for (mon = 0;; mon++) { - unsigned d = ms[mon]; + const unsigned d = ms[mon]; if (v < d) break; v -= d; @@ -474,7 +474,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s) UIntToStr_2(s, sec); s[2] = 0; } -static void PrintLF() +static void PrintLF(void) { Print("\n"); } @@ -541,7 +541,7 @@ static void GetAttribString(UInt32 wa, BoolInt isDir, char *s) // #define NUM_PARENTS_MAX 128 -int MY_CDECL main(int numargs, char *args[]) +int Z7_CDECL main(int numargs, char *args[]) { ISzAlloc allocImp; ISzAlloc allocTempImp; @@ -581,6 +581,7 @@ int MY_CDECL main(int numargs, char *args[]) allocImp = g_Alloc; allocTempImp = g_Alloc; + // allocTempImp = g_Alloc_temp; { WRes wres = @@ -611,7 +612,7 @@ int MY_CDECL main(int numargs, char *args[]) { lookStream.bufSize = kInputBufSize; lookStream.realStream = &archiveStream.vt; - LookToRead2_Init(&lookStream); + LookToRead2_INIT(&lookStream) } } @@ -767,7 +768,7 @@ int MY_CDECL main(int numargs, char *args[]) } else { - WRes wres = OutFile_OpenUtf16(&outFile, destPath); + const WRes wres = OutFile_OpenUtf16(&outFile, destPath); if (wres != 0) { PrintError_WRes("cannot open output file", wres); @@ -779,7 +780,7 @@ int MY_CDECL main(int numargs, char *args[]) processedSize = outSizeProcessed; { - WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize); + const WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize); if (wres != 0 || processedSize != outSizeProcessed) { PrintError_WRes("cannot write output file", wres); @@ -819,7 +820,7 @@ int MY_CDECL main(int numargs, char *args[]) #endif { - WRes wres = File_Close(&outFile); + const WRes wres = File_Close(&outFile); if (wres != 0) { PrintError_WRes("cannot close output file", wres); diff --git a/3rdparty/lzma/C/Util/7z/Precomp.h b/3rdparty/lzma/C/Util/7z/Precomp.h index 588a66f7eb8..bc8fa219b58 100644 --- a/3rdparty/lzma/C/Util/7z/Precomp.h +++ b/3rdparty/lzma/C/Util/7z/Precomp.h @@ -1,8 +1,12 @@ /* Precomp.h -- StdAfx -2013-06-16 : Igor Pavlov : Public domain */ +2023-03-04 : Igor Pavlov : Public domain */ -#ifndef __7Z_PRECOMP_H -#define __7Z_PRECOMP_H +#ifndef ZIP7_INC_PRECOMP_H +#define ZIP7_INC_PRECOMP_H + +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#pragma warning(disable : 4464) // relative include path contains '..' +#endif #include "../../Compiler.h" #include "../../7zTypes.h" diff --git a/3rdparty/lzma/C/Util/7z/makefile b/3rdparty/lzma/C/Util/7z/makefile index 9a49fd515a6..dfc560e9255 100644 --- a/3rdparty/lzma/C/Util/7z/makefile +++ b/3rdparty/lzma/C/Util/7z/makefile @@ -1,4 +1,4 @@ -CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT +CFLAGS = $(CFLAGS) -DZ7_PPMD_SUPPORT -DZ7_EXTRACT_ONLY PROG = 7zDec.exe diff --git a/3rdparty/lzma/C/Util/7z/makefile.gcc b/3rdparty/lzma/C/Util/7z/makefile.gcc index 4263d67558d..f48d36211d0 100644 --- a/3rdparty/lzma/C/Util/7z/makefile.gcc +++ b/3rdparty/lzma/C/Util/7z/makefile.gcc @@ -1,6 +1,6 @@ PROG = 7zdec -LOCAL_FLAGS = -D_7ZIP_PPMD_SUPPPORT +LOCAL_FLAGS = -DZ7_PPMD_SUPPORT -DZ7_EXTRACT_ONLY include ../../../CPP/7zip/LzmaDec_gcc.mak @@ -19,8 +19,6 @@ OBJS = \ $O/Ppmd7Dec.o \ $O/7zCrc.o \ $O/7zCrcOpt.o \ - $O/Sha256.o \ - $O/Sha256Opt.o \ $O/7zAlloc.o \ $O/7zArcIn.o \ $O/7zBuf.o \ diff --git a/3rdparty/lzma/C/Util/Lzma/LzmaUtil.c b/3rdparty/lzma/C/Util/Lzma/LzmaUtil.c index 62a59079f3f..b9b974bd1bb 100644 --- a/3rdparty/lzma/C/Util/Lzma/LzmaUtil.c +++ b/3rdparty/lzma/C/Util/Lzma/LzmaUtil.c @@ -1,7 +1,7 @@ /* LzmaUtil.c -- Test application for LZMA compression -2021-11-01 : Igor Pavlov : Public domain */ +2023-03-07 : Igor Pavlov : Public domain */ -#include "../../Precomp.h" +#include "Precomp.h" #include #include @@ -21,48 +21,80 @@ static const char * const kCantWriteMessage = "Cannot write output file"; static const char * const kCantAllocateMessage = "Cannot allocate memory"; static const char * const kDataErrorMessage = "Data error"; -static void PrintHelp(char *buffer) +static void Print(const char *s) { - strcat(buffer, - "\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n" - "Usage: lzma inputFile outputFile\n" - " e: encode file\n" - " d: decode file\n"); + fputs(s, stdout); } -static int PrintError(char *buffer, const char *message) +static void PrintHelp(void) { - strcat(buffer, "\nError: "); - strcat(buffer, message); - strcat(buffer, "\n"); + Print( + "\n" "LZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE + "\n" + "\n" "Usage: lzma inputFile outputFile" + "\n" " e: encode file" + "\n" " d: decode file" + "\n"); +} + +static int PrintError(const char *message) +{ + Print("\nError: "); + Print(message); + Print("\n"); return 1; } -static int PrintError_WRes(char *buffer, const char *message, WRes wres) +#define CONVERT_INT_TO_STR(charType, tempSize) \ + unsigned char temp[tempSize]; unsigned i = 0; \ + while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \ + *s++ = (charType)('0' + (unsigned)val); \ + while (i != 0) { i--; *s++ = (charType)temp[i]; } \ + *s = 0; \ + return s; + +static char * Convert_unsigned_To_str(unsigned val, char *s) { - strcat(buffer, "\nError: "); - strcat(buffer, message); - sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres); + CONVERT_INT_TO_STR(char, 32) +} + +static void Print_unsigned(unsigned code) +{ + char str[32]; + Convert_unsigned_To_str(code, str); + Print(str); +} + +static int PrintError_WRes(const char *message, WRes wres) +{ + PrintError(message); + Print("\nSystem error code: "); + Print_unsigned((unsigned)wres); #ifndef _WIN32 { const char *s = strerror(wres); if (s) - sprintf(buffer + strlen(buffer), " : %s", s); + { + Print(" : "); + Print(s); + } } #endif - strcat(buffer, "\n"); + Print("\n"); return 1; } -static int PrintErrorNumber(char *buffer, SRes val) +static int PrintErrorNumber(SRes val) { - sprintf(buffer + strlen(buffer), "\n7-Zip error code: %d\n", (unsigned)val); + Print("\n7-Zip error code: "); + Print_unsigned((unsigned)val); + Print("\n"); return 1; } -static int PrintUserError(char *buffer) +static int PrintUserError(void) { - return PrintError(buffer, "Incorrect command"); + return PrintError("Incorrect command"); } @@ -70,10 +102,10 @@ static int PrintUserError(char *buffer) #define OUT_BUF_SIZE (1 << 16) -static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream, +static SRes Decode2(CLzmaDec *state, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, UInt64 unpackSize) { - int thereIsSize = (unpackSize != (UInt64)(Int64)-1); + const int thereIsSize = (unpackSize != (UInt64)(Int64)-1); Byte inBuf[IN_BUF_SIZE]; Byte outBuf[OUT_BUF_SIZE]; size_t inPos = 0, inSize = 0, outPos = 0; @@ -83,7 +115,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS if (inPos == inSize) { inSize = IN_BUF_SIZE; - RINOK(inStream->Read(inStream, inBuf, &inSize)); + RINOK(inStream->Read(inStream, inBuf, &inSize)) inPos = 0; } { @@ -124,7 +156,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS } -static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) +static SRes Decode(ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream) { UInt64 unpackSize; int i; @@ -137,27 +169,29 @@ static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) /* Read and parse header */ - RINOK(SeqInStream_Read(inStream, header, sizeof(header))); - + { + size_t size = sizeof(header); + RINOK(SeqInStream_ReadMax(inStream, header, &size)) + if (size != sizeof(header)) + return SZ_ERROR_INPUT_EOF; + } unpackSize = 0; for (i = 0; i < 8; i++) unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); - LzmaDec_Construct(&state); - RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)); + LzmaDec_CONSTRUCT(&state) + RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)) res = Decode2(&state, outStream, inStream, unpackSize); LzmaDec_Free(&state, &g_Alloc); return res; } -static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs) +static SRes Encode(ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, UInt64 fileSize) { CLzmaEncHandle enc; SRes res; CLzmaEncProps props; - UNUSED_VAR(rs); - enc = LzmaEnc_Create(&g_Alloc); if (enc == 0) return SZ_ERROR_MEM; @@ -187,7 +221,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file } -static int main2(int numArgs, const char *args[], char *rs) +int Z7_CDECL main(int numArgs, const char *args[]) { CFileSeqInStream inStream; CFileOutStream outStream; @@ -208,29 +242,31 @@ static int main2(int numArgs, const char *args[], char *rs) if (numArgs == 1) { - PrintHelp(rs); + PrintHelp(); return 0; } if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1) - return PrintUserError(rs); + return PrintUserError(); c = args[1][0]; encodeMode = (c == 'e' || c == 'E'); if (!encodeMode && c != 'd' && c != 'D') - return PrintUserError(rs); + return PrintUserError(); + /* { size_t t4 = sizeof(UInt32); size_t t8 = sizeof(UInt64); if (t4 != 4 || t8 != 8) - return PrintError(rs, "Incorrect UInt32 or UInt64"); + return PrintError("Incorrect UInt32 or UInt64"); } + */ { - WRes wres = InFile_Open(&inStream.file, args[2]); + const WRes wres = InFile_Open(&inStream.file, args[2]); if (wres != 0) - return PrintError_WRes(rs, "Cannot open input file", wres); + return PrintError_WRes("Cannot open input file", wres); } if (numArgs > 3) @@ -239,18 +275,18 @@ static int main2(int numArgs, const char *args[], char *rs) useOutFile = True; wres = OutFile_Open(&outStream.file, args[3]); if (wres != 0) - return PrintError_WRes(rs, "Cannot open output file", wres); + return PrintError_WRes("Cannot open output file", wres); } else if (encodeMode) - PrintUserError(rs); + PrintUserError(); if (encodeMode) { UInt64 fileSize; - WRes wres = File_GetLength(&inStream.file, &fileSize); + const WRes wres = File_GetLength(&inStream.file, &fileSize); if (wres != 0) - return PrintError_WRes(rs, "Cannot get file length", wres); - res = Encode(&outStream.vt, &inStream.vt, fileSize, rs); + return PrintError_WRes("Cannot get file length", wres); + res = Encode(&outStream.vt, &inStream.vt, fileSize); } else { @@ -264,23 +300,14 @@ static int main2(int numArgs, const char *args[], char *rs) if (res != SZ_OK) { if (res == SZ_ERROR_MEM) - return PrintError(rs, kCantAllocateMessage); + return PrintError(kCantAllocateMessage); else if (res == SZ_ERROR_DATA) - return PrintError(rs, kDataErrorMessage); + return PrintError(kDataErrorMessage); else if (res == SZ_ERROR_WRITE) - return PrintError_WRes(rs, kCantWriteMessage, outStream.wres); + return PrintError_WRes(kCantWriteMessage, outStream.wres); else if (res == SZ_ERROR_READ) - return PrintError_WRes(rs, kCantReadMessage, inStream.wres); - return PrintErrorNumber(rs, res); + return PrintError_WRes(kCantReadMessage, inStream.wres); + return PrintErrorNumber(res); } return 0; } - - -int MY_CDECL main(int numArgs, const char *args[]) -{ - char rs[1000] = { 0 }; - int res = main2(numArgs, args, rs); - fputs(rs, stdout); - return res; -} diff --git a/3rdparty/lzma/C/Util/Lzma/LzmaUtil.dsp b/3rdparty/lzma/C/Util/Lzma/LzmaUtil.dsp index 4e38e4a65b6..e2e7d428296 100644 --- a/3rdparty/lzma/C/Util/Lzma/LzmaUtil.dsp +++ b/3rdparty/lzma/C/Util/Lzma/LzmaUtil.dsp @@ -106,6 +106,10 @@ SOURCE=..\..\7zVersion.h # End Source File # Begin Source File +SOURCE=..\..\7zWindows.h +# End Source File +# Begin Source File + SOURCE=..\..\Alloc.c # End Source File # Begin Source File @@ -114,6 +118,10 @@ SOURCE=..\..\Alloc.h # End Source File # Begin Source File +SOURCE=..\..\Compiler.h +# End Source File +# Begin Source File + SOURCE=..\..\CpuArch.h # End Source File # Begin Source File @@ -162,6 +170,14 @@ SOURCE=.\LzmaUtil.c # End Source File # Begin Source File +SOURCE=..\..\Precomp.h +# End Source File +# Begin Source File + +SOURCE=.\Precomp.h +# End Source File +# Begin Source File + SOURCE=..\..\Threads.c # End Source File # Begin Source File diff --git a/3rdparty/lzma/C/Util/Lzma/Precomp.h b/3rdparty/lzma/C/Util/Lzma/Precomp.h new file mode 100644 index 00000000000..bc8fa219b58 --- /dev/null +++ b/3rdparty/lzma/C/Util/Lzma/Precomp.h @@ -0,0 +1,14 @@ +/* Precomp.h -- StdAfx +2023-03-04 : Igor Pavlov : Public domain */ + +#ifndef ZIP7_INC_PRECOMP_H +#define ZIP7_INC_PRECOMP_H + +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#pragma warning(disable : 4464) // relative include path contains '..' +#endif + +#include "../../Compiler.h" +#include "../../7zTypes.h" + +#endif diff --git a/3rdparty/lzma/C/Util/LzmaLib/LzmaLib.dsp b/3rdparty/lzma/C/Util/LzmaLib/LzmaLib.dsp index 6ce91dcd2af..bacd9679324 100644 --- a/3rdparty/lzma/C/Util/LzmaLib/LzmaLib.dsp +++ b/3rdparty/lzma/C/Util/LzmaLib/LzmaLib.dsp @@ -101,6 +101,10 @@ SOURCE=.\LzmaLib.def SOURCE=.\LzmaLibExports.c # End Source File +# Begin Source File + +SOURCE=.\Precomp.h +# End Source File # End Group # Begin Source File @@ -108,6 +112,10 @@ SOURCE=..\..\7zTypes.h # End Source File # Begin Source File +SOURCE=..\..\7zWindows.h +# End Source File +# Begin Source File + SOURCE=..\..\Alloc.c # End Source File # Begin Source File @@ -116,6 +124,14 @@ SOURCE=..\..\Alloc.h # End Source File # Begin Source File +SOURCE=..\..\Compiler.h +# End Source File +# Begin Source File + +SOURCE=..\..\CpuArch.h +# End Source File +# Begin Source File + SOURCE=..\..\IStream.h # End Source File # Begin Source File @@ -168,6 +184,10 @@ SOURCE=..\..\LzmaLib.h # End Source File # Begin Source File +SOURCE=..\..\Precomp.h +# End Source File +# Begin Source File + SOURCE=.\resource.rc # End Source File # Begin Source File diff --git a/3rdparty/lzma/C/Util/LzmaLib/LzmaLibExports.c b/3rdparty/lzma/C/Util/LzmaLib/LzmaLibExports.c index 4a28a9a6b34..a46c9a80732 100644 --- a/3rdparty/lzma/C/Util/LzmaLib/LzmaLibExports.c +++ b/3rdparty/lzma/C/Util/LzmaLib/LzmaLibExports.c @@ -1,14 +1,15 @@ /* LzmaLibExports.c -- LZMA library DLL Entry point -2015-11-08 : Igor Pavlov : Public domain */ +2023-03-05 : Igor Pavlov : Public domain */ -#include "../../Precomp.h" +#include "Precomp.h" -#include +#include "../../7zWindows.h" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved); BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { - UNUSED_VAR(hInstance); - UNUSED_VAR(dwReason); - UNUSED_VAR(lpReserved); + UNUSED_VAR(hInstance) + UNUSED_VAR(dwReason) + UNUSED_VAR(lpReserved) return TRUE; } diff --git a/3rdparty/lzma/C/Util/LzmaLib/Precomp.c b/3rdparty/lzma/C/Util/LzmaLib/Precomp.c new file mode 100644 index 00000000000..01605e3c261 --- /dev/null +++ b/3rdparty/lzma/C/Util/LzmaLib/Precomp.c @@ -0,0 +1,4 @@ +/* Precomp.c -- StdAfx +2013-01-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" diff --git a/3rdparty/lzma/C/Util/LzmaLib/Precomp.h b/3rdparty/lzma/C/Util/LzmaLib/Precomp.h new file mode 100644 index 00000000000..bc8fa219b58 --- /dev/null +++ b/3rdparty/lzma/C/Util/LzmaLib/Precomp.h @@ -0,0 +1,14 @@ +/* Precomp.h -- StdAfx +2023-03-04 : Igor Pavlov : Public domain */ + +#ifndef ZIP7_INC_PRECOMP_H +#define ZIP7_INC_PRECOMP_H + +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#pragma warning(disable : 4464) // relative include path contains '..' +#endif + +#include "../../Compiler.h" +#include "../../7zTypes.h" + +#endif diff --git a/3rdparty/lzma/C/Util/LzmaLib/makefile b/3rdparty/lzma/C/Util/LzmaLib/makefile index b36f1de09f9..b8e054efca3 100644 --- a/3rdparty/lzma/C/Util/LzmaLib/makefile +++ b/3rdparty/lzma/C/Util/LzmaLib/makefile @@ -21,6 +21,7 @@ C_OBJS = \ $O\Threads.obj \ OBJS = \ + $O\Precomp.obj \ $(LIB_OBJS) \ $(C_OBJS) \ $O\resource.res @@ -30,7 +31,24 @@ OBJS = \ $(SLIBPATH): $O $(OBJS) lib -out:$(SLIBPATH) $(OBJS) $(LIBS) + +MAK_SINGLE_FILE = 1 + +$O\Precomp.obj: Precomp.c + $(CCOMPL_PCH) + +!IFDEF MAK_SINGLE_FILE + $(LIB_OBJS): $(*B).c - $(COMPL_O2) + $(CCOMPL_USE) $(C_OBJS): ../../$(*B).c - $(COMPL_O2) + $(CCOMPL_USE) + +!ELSE + +{.}.c{$O}.obj:: + $(CCOMPLB_USE) +{../../../C}.c{$O}.obj:: + $(CCOMPLB_USE) + +!ENDIF diff --git a/3rdparty/lzma/C/Util/SfxSetup/Precomp.h b/3rdparty/lzma/C/Util/SfxSetup/Precomp.h index 588a66f7eb8..bc8fa219b58 100644 --- a/3rdparty/lzma/C/Util/SfxSetup/Precomp.h +++ b/3rdparty/lzma/C/Util/SfxSetup/Precomp.h @@ -1,8 +1,12 @@ /* Precomp.h -- StdAfx -2013-06-16 : Igor Pavlov : Public domain */ +2023-03-04 : Igor Pavlov : Public domain */ -#ifndef __7Z_PRECOMP_H -#define __7Z_PRECOMP_H +#ifndef ZIP7_INC_PRECOMP_H +#define ZIP7_INC_PRECOMP_H + +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#pragma warning(disable : 4464) // relative include path contains '..' +#endif #include "../../Compiler.h" #include "../../7zTypes.h" diff --git a/3rdparty/lzma/C/Util/SfxSetup/SfxSetup.c b/3rdparty/lzma/C/Util/SfxSetup/SfxSetup.c index ef19aeac545..7304a0be40d 100644 --- a/3rdparty/lzma/C/Util/SfxSetup/SfxSetup.c +++ b/3rdparty/lzma/C/Util/SfxSetup/SfxSetup.c @@ -26,6 +26,12 @@ #define kInputBufSize ((size_t)1 << 18) + +#define wcscat lstrcatW +#define wcslen (size_t)lstrlenW +#define wcscpy lstrcpyW +// wcsncpy() and lstrcpynW() work differently. We don't use them. + static const char * const kExts[] = { "bat" @@ -64,7 +70,7 @@ static unsigned FindExt(const wchar_t *s, unsigned *extLen) return len; } -#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) +#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) { @@ -72,13 +78,13 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t for (i = 0; i < num; i++) { const char *item = items[i]; - unsigned itemLen = (unsigned)strlen(item); + const unsigned itemLen = (unsigned)strlen(item); unsigned j; if (len != itemLen) continue; for (j = 0; j < len; j++) { - unsigned c = (Byte)item[j]; + const unsigned c = (Byte)item[j]; if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j]) break; } @@ -96,10 +102,20 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType) } #endif + +#ifdef _CONSOLE +static void PrintStr(const char *s) +{ + fputs(s, stdout); +} +#endif + static void PrintErrorMessage(const char *message) { #ifdef _CONSOLE - printf("\n7-Zip Error: %s\n", message); + PrintStr("\n7-Zip Error: "); + PrintStr(message); + PrintStr("\n"); #else #ifdef UNDER_CE WCHAR messageW[256 + 4]; @@ -179,7 +195,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path) WIN32_FIND_DATAW fd; HANDLE handle; WRes res = 0; - size_t len = wcslen(path); + const size_t len = wcslen(path); wcscpy(path + len, L"*"); handle = FindFirstFileW(path, &fd); path[len] = L'\0'; @@ -228,7 +244,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path) } #ifdef _CONSOLE -int MY_CDECL main() +int Z7_CDECL main(void) #else int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef UNDER_CE @@ -290,7 +306,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, BoolInt quoteMode = False; for (;; cmdLineParams++) { - wchar_t c = *cmdLineParams; + const wchar_t c = *cmdLineParams; if (c == L'\"') quoteMode = !quoteMode; else if (c == 0 || (c == L' ' && !quoteMode)) @@ -324,7 +340,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, unsigned k; for (k = 0; k < 8; k++) { - unsigned t = value & 0xF; + const unsigned t = value & 0xF; value >>= 4; s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); } @@ -386,7 +402,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, { lookStream.bufSize = kInputBufSize; lookStream.realStream = &archiveStream.vt; - LookToRead2_Init(&lookStream); + LookToRead2_INIT(&lookStream) } } @@ -455,11 +471,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, unsigned extLen; const WCHAR *name = temp + nameStartPos; unsigned len = (unsigned)wcslen(name); - unsigned nameLen = FindExt(temp + nameStartPos, &extLen); - unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen); - unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen); + const unsigned nameLen = FindExt(temp + nameStartPos, &extLen); + const unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen); + const unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen); - unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12)); + const unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12)); if (minPrice > price) { minPrice = price; @@ -500,7 +516,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #endif { - SRes res2 = File_Close(&outFile); + const SRes res2 = File_Close(&outFile); if (res != SZ_OK) break; if (res2 != SZ_OK) @@ -550,7 +566,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, WCHAR oldCurDir[MAX_PATH + 2]; oldCurDir[0] = 0; { - DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir); + const DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir); if (needLen == 0 || needLen > MAX_PATH) oldCurDir[0] = 0; SetCurrentDirectory(workCurDir); diff --git a/3rdparty/lzma/C/Util/SfxSetup/makefile b/3rdparty/lzma/C/Util/SfxSetup/makefile index 544da67dfb5..bc0cf8bc71c 100644 --- a/3rdparty/lzma/C/Util/SfxSetup/makefile +++ b/3rdparty/lzma/C/Util/SfxSetup/makefile @@ -1,6 +1,9 @@ PROG = 7zS2.sfx MY_FIXED = 1 +CFLAGS = $(CFLAGS) \ + -DZ7_EXTRACT_ONLY \ + C_OBJS = \ $O\7zAlloc.obj \ $O\7zArcIn.obj \ diff --git a/3rdparty/lzma/C/Util/SfxSetup/makefile_con b/3rdparty/lzma/C/Util/SfxSetup/makefile_con index d0f8352541e..9f4b91669ca 100644 --- a/3rdparty/lzma/C/Util/SfxSetup/makefile_con +++ b/3rdparty/lzma/C/Util/SfxSetup/makefile_con @@ -1,6 +1,8 @@ PROG = 7zS2con.sfx MY_FIXED = 1 -CFLAGS = $(CFLAGS) -D_CONSOLE + +CFLAGS = $(CFLAGS) -D_CONSOLE \ + -DZ7_EXTRACT_ONLY \ C_OBJS = \ $O\7zAlloc.obj \ -- cgit v1.2.3-70-g09d2