Skip to content

Commit

Permalink
21.06
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Pavlov authored and FnControlOption committed Nov 29, 2021
1 parent 1194dc9 commit ccbf6ad
Show file tree
Hide file tree
Showing 43 changed files with 1,381 additions and 260 deletions.
6 changes: 3 additions & 3 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 21
#define MY_VER_MINOR 04
#define MY_VER_MINOR 06
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "21.04 beta"
#define MY_VERSION_NUMBERS "21.06"
#define MY_VERSION MY_VERSION_NUMBERS

#ifdef MY_CPU_NAME
Expand All @@ -10,7 +10,7 @@
#define MY_VERSION_CPU MY_VERSION
#endif

#define MY_DATE "2021-11-02"
#define MY_DATE "2021-11-24"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
Expand Down
18 changes: 14 additions & 4 deletions C/7zip_gcc_c.mak
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MY_ASM = jwasm
MY_ASM = asmc

PROGPATH = $(O)/$(PROG)
PROGPATH_STATIC = $(O)/$(PROG)s


# for object file
Expand Down Expand Up @@ -53,7 +54,7 @@ endif


PROGPATH = $(O)/$(PROG)$(SHARED_EXT)

PROGPATH_STATIC = $(O)/$(PROG)s$(SHARED_EXT)

ifndef O
O=_o
Expand Down Expand Up @@ -82,7 +83,7 @@ MY_MKDIR=mkdir -p
# LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
LIB2 = -lpthread -ldl

DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(OBJS)
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)

endif

Expand All @@ -108,14 +109,23 @@ CXX_WARN_FLAGS =

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

all: $(O) $(PROGPATH)
STATIC_TARGET=
ifdef COMPL_STATIC
STATIC_TARGET=$(PROGPATH_STATIC)
endif


all: $(O) $(PROGPATH) $(STATIC_TARGET)

$(O):
$(MY_MKDIR) $(O)

LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
$(PROGPATH): $(OBJS)
$(CXX) -s -o $(PROGPATH) $(MY_ARCH_2) $(LDFLAGS) $(OBJS) $(MY_LIBS) $(LIB2)
$(CXX) -o $(PROGPATH) $(LFLAGS_ALL)

$(PROGPATH_STATIC): $(OBJS)
$(CXX) -static -o $(PROGPATH_STATIC) $(LFLAGS_ALL)


ifndef NO_DEFAULT_RES
Expand Down
6 changes: 3 additions & 3 deletions C/DllSecur.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* DllSecur.c -- DLL loading security
2018-02-21 : Igor Pavlov : Public domain */
2021-11-18 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -43,7 +43,7 @@ void My_SetDefaultDllDirectories()
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
{
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
(void(*)())GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
if (setDllDirs)
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
return;
Expand All @@ -66,7 +66,7 @@ void LoadSecurityDlls()
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
{
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
(void(*)())GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
if (setDllDirs)
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
return;
Expand Down
26 changes: 14 additions & 12 deletions C/LzmaEnc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2021-07-10: Igor Pavlov : Public domain */
2021-11-18: Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -668,12 +668,11 @@ static int RangeEnc_Alloc(CRangeEnc *p, ISzAllocPtr alloc)
static void RangeEnc_Free(CRangeEnc *p, ISzAllocPtr alloc)
{
ISzAlloc_Free(alloc, p->bufBase);
p->bufBase = 0;
p->bufBase = NULL;
}

static void RangeEnc_Init(CRangeEnc *p)
{
/* Stream.Init(); */
p->range = 0xFFFFFFFF;
p->cache = 0;
p->low = 0;
Expand All @@ -687,12 +686,12 @@ static void RangeEnc_Init(CRangeEnc *p)

MY_NO_INLINE static void RangeEnc_FlushStream(CRangeEnc *p)
{
size_t num;
if (p->res != SZ_OK)
return;
num = (size_t)(p->buf - p->bufBase);
if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num))
p->res = SZ_ERROR_WRITE;
const size_t num = (size_t)(p->buf - p->bufBase);
if (p->res == SZ_OK)
{
if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num))
p->res = SZ_ERROR_WRITE;
}
p->processed += num;
p->buf = p->bufBase;
}
Expand Down Expand Up @@ -2946,9 +2945,12 @@ static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *data, s
size = p->rem;
p->overflow = True;
}
memcpy(p->data, data, size);
p->rem -= size;
p->data += size;
if (size != 0)
{
memcpy(p->data, data, size);
p->rem -= size;
p->data += size;
}
return size;
}

Expand Down
21 changes: 19 additions & 2 deletions C/Util/7zipUninstall/7zipUninstall.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zipUninstall.c - 7-Zip Uninstaller
2021-02-23 : Igor Pavlov : Public domain */
2021-11-24 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -51,7 +51,7 @@
#endif
#endif

#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix
#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix

static LPCWSTR const k_7zip_with_Ver_Uninstall = k_7zip_with_Ver L" Uninstall";

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


static void RemoveQuotes(wchar_t *s)
{
const size_t len = wcslen(s);
size_t i;
if (len == 0 || s[0] != '\"' || s[len - 1] != '\"')
return;
for (i = 0; i < len; i++)
s[i] = s[i + 1];
s[len - 2] = 0;
}

static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name)
{
if (!IsString1PrefixedByString2_NoCase(s, prefix))
Expand Down Expand Up @@ -490,12 +501,18 @@ static void WriteCLSID()


if (MyRegistry_QueryString2(HKEY_LOCAL_MACHINE, k_AppPaths_7zFm, NULL, s))
{
// RemoveQuotes(s);
if (AreEqual_Path_PrefixName(s, path, L"7zFM.exe"))
MyRegistry_DeleteKey(HKEY_LOCAL_MACHINE, k_AppPaths_7zFm);
}

if (MyRegistry_QueryString2(HKEY_LOCAL_MACHINE, k_Uninstall_7zip, L"UninstallString", s))
{
RemoveQuotes(s);
if (AreEqual_Path_PrefixName(s, path, kUninstallExe))
MyRegistry_DeleteKey(HKEY_LOCAL_MACHINE, k_Uninstall_7zip);
}
}


Expand Down
19 changes: 15 additions & 4 deletions CPP/7zip/7zip_gcc.mak
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ MY_ASM = jwasm
MY_ASM = asmc

PROGPATH = $(O)/$(PROG)
PROGPATH_STATIC = $(O)/$(PROG)s


ifneq ($(CC), xlc)
Expand Down Expand Up @@ -88,7 +89,7 @@ endif


PROGPATH = $(O)/$(PROG)$(SHARED_EXT)

PROGPATH_STATIC = $(O)/$(PROG)s$(SHARED_EXT)

ifdef IS_MINGW

Expand All @@ -114,7 +115,7 @@ LIB2 = -lpthread -ldl



DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(OBJS)
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)

endif

Expand Down Expand Up @@ -150,13 +151,23 @@ CXX_WARN_FLAGS =

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

all: $(O) $(PROGPATH)
STATIC_TARGET=
ifdef COMPL_STATIC
STATIC_TARGET=$(PROGPATH_STATIC)
endif


all: $(O) $(PROGPATH) $(STATIC_TARGET)

$(O):
$(MY_MKDIR) $(O)

LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
$(PROGPATH): $(OBJS)
$(CXX) -o $(PROGPATH) -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
$(CXX) -o $(PROGPATH) $(LFLAGS_ALL)

$(PROGPATH_STATIC): $(OBJS)
$(CXX) -static -o $(PROGPATH_STATIC) $(LFLAGS_ALL)

# -s strips debug sections from executable in GCC

Expand Down
27 changes: 23 additions & 4 deletions CPP/7zip/Archive/Common/HandlerOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,30 @@ bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsB
else if (prop.vt != VT_EMPTY)
return false;

bool percentMode = false;
{
const wchar_t c = *s;
if (MyCharLower_Ascii(c) == 'p')
{
percentMode = true;
s++;
}
}

const wchar_t *end;
UInt64 v = ConvertStringToUInt64(s, &end);
const UInt64 v = ConvertStringToUInt64(s, &end);
if (s == end)
return false;
wchar_t c = *end;
const wchar_t c = *end;

if (percentMode)
{
if (c != 0)
return false;
res = Calc_From_Val_Percents(percentsBase, v);
return true;
}

if (c == 0)
{
res = v;
Expand All @@ -42,7 +61,7 @@ bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsB

if (c == '%')
{
res = percentsBase / 100 * v;
res = Calc_From_Val_Percents(percentsBase, v);
return true;
}

Expand All @@ -56,7 +75,7 @@ bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsB
case 't': numBits = 40; break;
default: return false;
}
UInt64 val2 = v << numBits;
const UInt64 val2 = v << numBits;
if ((val2 >> numBits) != v)
return false;
res = val2;
Expand Down
5 changes: 4 additions & 1 deletion CPP/7zip/Archive/Common/HandlerOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class CCommonMethodProps
if (memAvail > limit2)
memAvail = limit2;
}
_memUsage_Compress = memAvail / 32 * 28;
// 80% - is auto usage limit in handlers
// _memUsage_Compress = memAvail * 4 / 5;
// _memUsage_Compress = Calc_From_Val_Percents(memAvail, 80);
_memUsage_Compress = Calc_From_Val_Percents_Less100(memAvail, 80);
_memUsage_Decompress = memAvail / 32 * 17;
}
}
Expand Down
Loading

0 comments on commit ccbf6ad

Please sign in to comment.