1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Swapped the parameters in Packer::checkCompressionRatio() - all functions

now have the uncompressed size before the compressed size in the
parameter list.

committer: mfx <mfx> 974917952 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2000-11-22 18:32:32 +00:00
parent 7a5b0a09e0
commit 2e6c03690f
6 changed files with 17 additions and 11 deletions

View File

@ -2,10 +2,10 @@
#
# usage:
# `make target=linux' # linux
# `make target=djggp2' # djggp2
# `make target=cygwin' # cygwin
# `make target=djggp2' # djggp2 2.03
# `make target=cygwin' # cygwin 1.1.x
# `make target=mingw32' # mingw32
# `make target=no-cygwin' # mingw32 as included in cygwin
# `make target=no-cygwin' # mingw32 as included in cygwin 1.1.x
# `make target=vc6' # Visual C++ 6.0
#
@ -44,7 +44,7 @@ ifneq ($(strip $(wildcard /platform/sun4?/kernel/unix)),)
target = sparc
endif
ifeq ($(target),msc)
target = vc6
override target = vc6
endif
@ -201,6 +201,7 @@ endif # djgpp2
ifeq ($(target),cygwin)
CFLAGS_M += -mno-schedule-prologue
CFLAGS_M += -march=i386 -mcpu=pentium
CFLAGS_WERROR = -Werror
endif
ifeq ($(target),mingw32)
@ -213,6 +214,7 @@ ifeq ($(target),no-cygwin)
CC = gcc -mno-cygwin
CFLAGS_M += -mno-schedule-prologue
CFLAGS_M += -march=i386 -mcpu=pentium
CFLAGS_WERROR = -Werror
endif

View File

@ -361,7 +361,7 @@ void PackLinuxI386elf::pack(OutputFile *fo)
updateLoader(fo);
// finally check compression ratio
if (!super::checkCompressionRatio(fo->getBytesWritten(), ph.u_len))
if (!super::checkCompressionRatio(ph.u_len, fo->getBytesWritten()))
throwNotCompressible();
}

View File

@ -197,7 +197,7 @@ void PackUnix::pack(OutputFile *fo)
updateLoader(fo);
// finally check compression ratio
if (!Packer::checkCompressionRatio(fo->getBytesWritten(), ph.u_len))
if (!Packer::checkCompressionRatio(ph.u_len, fo->getBytesWritten()))
throwNotCompressible();
}

View File

@ -1915,7 +1915,7 @@ void PackW32Pe::pack(OutputFile *fo)
copyOverlay(fo, overlay, &obuf);
// finally check compresion ratio
if (!checkCompressionRatio(fo->getBytesWritten(), file_size))
if (!checkCompressionRatio(file_size, fo->getBytesWritten()))
throwNotCompressible();
}

View File

@ -222,7 +222,7 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
uip->endCallback();
//printf("Packer::compress: %d/%d: %7d -> %7d\n", ph.method, ph.level, ph.u_len, ph.c_len);
if (!checkCompressionRatio(ph.c_len, ph.u_len))
if (!checkCompressionRatio(ph.u_len, ph.c_len))
return false;
// return in any case if not compressible
if (ph.c_len >= ph.u_len)
@ -249,8 +249,12 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
}
bool Packer::checkCompressionRatio(unsigned c_len, unsigned u_len) const
bool Packer::checkCompressionRatio(unsigned u_len, unsigned c_len) const
{
assert((int)u_len > 0);
assert((int)c_len > 0);
assert((off_t)u_len < file_size);
#if 1
if (c_len >= u_len - u_len / 8) // min. 12.5% gain
return false;
@ -1133,7 +1137,7 @@ void Packer::compressWithFilters(Filter *parm_ft, unsigned *parm_overlapoh,
// finally check compression ratio
if (best_ph.c_len + best_ph_lsize >= best_ph.u_len)
throwNotCompressible();
if (!checkCompressionRatio(best_ph.c_len, best_ph.u_len))
if (!checkCompressionRatio(best_ph.u_len, best_ph.c_len))
throwNotCompressible();
// convenience

View File

@ -148,7 +148,7 @@ protected:
unsigned max_offset = 0, unsigned max_match = 0);
virtual void decompress(const upx_bytep in,
upx_bytep out, bool verify_checksum=true);
virtual bool checkCompressionRatio(unsigned c_len, unsigned u_len) const;
virtual bool checkCompressionRatio(unsigned u_len, unsigned c_len) const;
// high-level compression drivers
void compressWithFilters(Filter *ft, unsigned *overlapoh,