Skip to content

Commit fba8d2f

Browse files
Igor Pavlovmcmilk
Igor Pavlov
authored andcommitted
7-Zip Version 21.05 and 21.06
7-Zip Version 21.05 - The window "Add to Archive" now allows to set a limit on memory usage (RAM) that will be used for compressing. - New switch -mmemuse={N}g / -mmemuse=p{N} to set a limit on memory usage (RAM) for compressing and decompressing. - Some bugs were fixed. - see: https://sourceforge.net/p/sevenzip/discussion/45797/thread/edcb38bbab/ 7-Zip Version 21.06 - The window "Add to Archive" now allows to set a limit on memory usage (RAM) that will be used for compressing. - New switch -mmemuse={N}g / -mmemuse=p{N} to set a limit on memory usage (RAM) for compressing and decompressing. - Bug in versions 21.00-21.05 was fixed: - 7-Zip didn't set attributes of directories during archive extracting. - Some bugs were fixed. - see: https://sourceforge.net/p/sevenzip/discussion/45797/thread/b463f34259/ 7-Zip Archiv - add .gitignore
1 parent 5cdf6a3 commit fba8d2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1413
-260
lines changed

.gitignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app

C/7zVersion.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#define MY_VER_MAJOR 21
2-
#define MY_VER_MINOR 04
2+
#define MY_VER_MINOR 06
33
#define MY_VER_BUILD 0
4-
#define MY_VERSION_NUMBERS "21.04 beta"
4+
#define MY_VERSION_NUMBERS "21.06"
55
#define MY_VERSION MY_VERSION_NUMBERS
66

77
#ifdef MY_CPU_NAME
@@ -10,7 +10,7 @@
1010
#define MY_VERSION_CPU MY_VERSION
1111
#endif
1212

13-
#define MY_DATE "2021-11-02"
13+
#define MY_DATE "2021-11-24"
1414
#undef MY_COPYRIGHT
1515
#undef MY_VERSION_COPYRIGHT_DATE
1616
#define MY_AUTHOR_NAME "Igor Pavlov"

C/7zip_gcc_c.mak

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ MY_ASM = jwasm
55
MY_ASM = asmc
66

77
PROGPATH = $(O)/$(PROG)
8+
PROGPATH_STATIC = $(O)/$(PROG)s
89

910

1011
# for object file
@@ -53,7 +54,7 @@ endif
5354

5455

5556
PROGPATH = $(O)/$(PROG)$(SHARED_EXT)
56-
57+
PROGPATH_STATIC = $(O)/$(PROG)s$(SHARED_EXT)
5758

5859
ifndef O
5960
O=_o
@@ -82,7 +83,7 @@ MY_MKDIR=mkdir -p
8283
# LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
8384
LIB2 = -lpthread -ldl
8485

85-
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(OBJS)
86+
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)
8687

8788
endif
8889

@@ -108,14 +109,23 @@ CXX_WARN_FLAGS =
108109

109110
CXXFLAGS = $(LOCAL_FLAGS) $(CXXFLAGS_BASE2) $(CFLAGS_BASE) $(CXXFLAGS_EXTRA) $(CC_SHARED) -o $@ $(CXX_WARN_FLAGS)
110111

111-
all: $(O) $(PROGPATH)
112+
STATIC_TARGET=
113+
ifdef COMPL_STATIC
114+
STATIC_TARGET=$(PROGPATH_STATIC)
115+
endif
116+
117+
118+
all: $(O) $(PROGPATH) $(STATIC_TARGET)
112119

113120
$(O):
114121
$(MY_MKDIR) $(O)
115122

123+
LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
116124
$(PROGPATH): $(OBJS)
117-
$(CXX) -s -o $(PROGPATH) $(MY_ARCH_2) $(LDFLAGS) $(OBJS) $(MY_LIBS) $(LIB2)
125+
$(CXX) -o $(PROGPATH) $(LFLAGS_ALL)
118126

127+
$(PROGPATH_STATIC): $(OBJS)
128+
$(CXX) -static -o $(PROGPATH_STATIC) $(LFLAGS_ALL)
119129

120130

121131
ifndef NO_DEFAULT_RES

C/DllSecur.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* DllSecur.c -- DLL loading security
2-
2018-02-21 : Igor Pavlov : Public domain */
2+
2021-11-18 : Igor Pavlov : Public domain */
33

44
#include "Precomp.h"
55

@@ -43,7 +43,7 @@ void My_SetDefaultDllDirectories()
4343
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
4444
{
4545
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
46-
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
46+
(void(*)())GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
4747
if (setDllDirs)
4848
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
4949
return;
@@ -66,7 +66,7 @@ void LoadSecurityDlls()
6666
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
6767
{
6868
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
69-
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
69+
(void(*)())GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
7070
if (setDllDirs)
7171
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
7272
return;

C/LzmaEnc.c

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* LzmaEnc.c -- LZMA Encoder
2-
2021-07-10: Igor Pavlov : Public domain */
2+
2021-11-18: Igor Pavlov : Public domain */
33

44
#include "Precomp.h"
55

@@ -668,12 +668,11 @@ static int RangeEnc_Alloc(CRangeEnc *p, ISzAllocPtr alloc)
668668
static void RangeEnc_Free(CRangeEnc *p, ISzAllocPtr alloc)
669669
{
670670
ISzAlloc_Free(alloc, p->bufBase);
671-
p->bufBase = 0;
671+
p->bufBase = NULL;
672672
}
673673

674674
static void RangeEnc_Init(CRangeEnc *p)
675675
{
676-
/* Stream.Init(); */
677676
p->range = 0xFFFFFFFF;
678677
p->cache = 0;
679678
p->low = 0;
@@ -687,12 +686,12 @@ static void RangeEnc_Init(CRangeEnc *p)
687686

688687
MY_NO_INLINE static void RangeEnc_FlushStream(CRangeEnc *p)
689688
{
690-
size_t num;
691-
if (p->res != SZ_OK)
692-
return;
693-
num = (size_t)(p->buf - p->bufBase);
694-
if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num))
695-
p->res = SZ_ERROR_WRITE;
689+
const size_t num = (size_t)(p->buf - p->bufBase);
690+
if (p->res == SZ_OK)
691+
{
692+
if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num))
693+
p->res = SZ_ERROR_WRITE;
694+
}
696695
p->processed += num;
697696
p->buf = p->bufBase;
698697
}
@@ -2946,9 +2945,12 @@ static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *data, s
29462945
size = p->rem;
29472946
p->overflow = True;
29482947
}
2949-
memcpy(p->data, data, size);
2950-
p->rem -= size;
2951-
p->data += size;
2948+
if (size != 0)
2949+
{
2950+
memcpy(p->data, data, size);
2951+
p->rem -= size;
2952+
p->data += size;
2953+
}
29522954
return size;
29532955
}
29542956

C/Util/7zipUninstall/7zipUninstall.c

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 7zipUninstall.c - 7-Zip Uninstaller
2-
2021-02-23 : Igor Pavlov : Public domain */
2+
2021-11-24 : Igor Pavlov : Public domain */
33

44
#include "Precomp.h"
55

@@ -51,7 +51,7 @@
5151
#endif
5252
#endif
5353

54-
#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix
54+
#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix
5555

5656
static LPCWSTR const k_7zip_with_Ver_Uninstall = k_7zip_with_Ver L" Uninstall";
5757

@@ -404,6 +404,17 @@ static LPCWSTR const k_AppPaths_7zFm = L"Software\\Microsoft\\Windows\\CurrentVe
404404
static LPCWSTR const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip";
405405

406406

407+
static void RemoveQuotes(wchar_t *s)
408+
{
409+
const size_t len = wcslen(s);
410+
size_t i;
411+
if (len == 0 || s[0] != '\"' || s[len - 1] != '\"')
412+
return;
413+
for (i = 0; i < len; i++)
414+
s[i] = s[i + 1];
415+
s[len - 2] = 0;
416+
}
417+
407418
static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name)
408419
{
409420
if (!IsString1PrefixedByString2_NoCase(s, prefix))
@@ -490,12 +501,18 @@ static void WriteCLSID()
490501

491502

492503
if (MyRegistry_QueryString2(HKEY_LOCAL_MACHINE, k_AppPaths_7zFm, NULL, s))
504+
{
505+
// RemoveQuotes(s);
493506
if (AreEqual_Path_PrefixName(s, path, L"7zFM.exe"))
494507
MyRegistry_DeleteKey(HKEY_LOCAL_MACHINE, k_AppPaths_7zFm);
508+
}
495509

496510
if (MyRegistry_QueryString2(HKEY_LOCAL_MACHINE, k_Uninstall_7zip, L"UninstallString", s))
511+
{
512+
RemoveQuotes(s);
497513
if (AreEqual_Path_PrefixName(s, path, kUninstallExe))
498514
MyRegistry_DeleteKey(HKEY_LOCAL_MACHINE, k_Uninstall_7zip);
515+
}
499516
}
500517

501518

CPP/7zip/7zip_gcc.mak

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ MY_ASM = jwasm
1010
MY_ASM = asmc
1111

1212
PROGPATH = $(O)/$(PROG)
13+
PROGPATH_STATIC = $(O)/$(PROG)s
1314

1415

1516
ifneq ($(CC), xlc)
@@ -88,7 +89,7 @@ endif
8889

8990

9091
PROGPATH = $(O)/$(PROG)$(SHARED_EXT)
91-
92+
PROGPATH_STATIC = $(O)/$(PROG)s$(SHARED_EXT)
9293

9394
ifdef IS_MINGW
9495

@@ -114,7 +115,7 @@ LIB2 = -lpthread -ldl
114115

115116

116117

117-
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(OBJS)
118+
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)
118119

119120
endif
120121

@@ -150,13 +151,23 @@ CXX_WARN_FLAGS =
150151

151152
CXXFLAGS = $(MY_ARCH_2) $(LOCAL_FLAGS) $(CXXFLAGS_BASE2) $(CFLAGS_BASE) $(CXXFLAGS_EXTRA) $(CC_SHARED) -o $@ $(CXX_WARN_FLAGS)
152153

153-
all: $(O) $(PROGPATH)
154+
STATIC_TARGET=
155+
ifdef COMPL_STATIC
156+
STATIC_TARGET=$(PROGPATH_STATIC)
157+
endif
158+
159+
160+
all: $(O) $(PROGPATH) $(STATIC_TARGET)
154161

155162
$(O):
156163
$(MY_MKDIR) $(O)
157164

165+
LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
158166
$(PROGPATH): $(OBJS)
159-
$(CXX) -o $(PROGPATH) -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
167+
$(CXX) -o $(PROGPATH) $(LFLAGS_ALL)
168+
169+
$(PROGPATH_STATIC): $(OBJS)
170+
$(CXX) -static -o $(PROGPATH_STATIC) $(LFLAGS_ALL)
160171

161172
# -s strips debug sections from executable in GCC
162173

CPP/7zip/Archive/Common/HandlerOut.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,30 @@ bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsB
2727
else if (prop.vt != VT_EMPTY)
2828
return false;
2929

30+
bool percentMode = false;
31+
{
32+
const wchar_t c = *s;
33+
if (MyCharLower_Ascii(c) == 'p')
34+
{
35+
percentMode = true;
36+
s++;
37+
}
38+
}
39+
3040
const wchar_t *end;
31-
UInt64 v = ConvertStringToUInt64(s, &end);
41+
const UInt64 v = ConvertStringToUInt64(s, &end);
3242
if (s == end)
3343
return false;
34-
wchar_t c = *end;
44+
const wchar_t c = *end;
45+
46+
if (percentMode)
47+
{
48+
if (c != 0)
49+
return false;
50+
res = Calc_From_Val_Percents(percentsBase, v);
51+
return true;
52+
}
53+
3554
if (c == 0)
3655
{
3756
res = v;
@@ -42,7 +61,7 @@ bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsB
4261

4362
if (c == '%')
4463
{
45-
res = percentsBase / 100 * v;
64+
res = Calc_From_Val_Percents(percentsBase, v);
4665
return true;
4766
}
4867

@@ -56,7 +75,7 @@ bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsB
5675
case 't': numBits = 40; break;
5776
default: return false;
5877
}
59-
UInt64 val2 = v << numBits;
78+
const UInt64 val2 = v << numBits;
6079
if ((val2 >> numBits) != v)
6180
return false;
6281
res = val2;

CPP/7zip/Archive/Common/HandlerOut.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ class CCommonMethodProps
3636
if (memAvail > limit2)
3737
memAvail = limit2;
3838
}
39-
_memUsage_Compress = memAvail / 32 * 28;
39+
// 80% - is auto usage limit in handlers
40+
// _memUsage_Compress = memAvail * 4 / 5;
41+
// _memUsage_Compress = Calc_From_Val_Percents(memAvail, 80);
42+
_memUsage_Compress = Calc_From_Val_Percents_Less100(memAvail, 80);
4043
_memUsage_Decompress = memAvail / 32 * 17;
4144
}
4245
}

0 commit comments

Comments
 (0)