Add option --prefer-ucl.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-09-28 11:57:15 +02:00
parent f1d713ebf6
commit b4870f62c9
3 changed files with 16 additions and 10 deletions

View File

@ -109,7 +109,7 @@ int upx_compress ( const upx_bytep src, unsigned src_len,
cb, method, level, cconf, cresult);
#endif
#if (WITH_NRV)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
else if ((M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) && !opt->prefer_ucl)
r = upx_nrv_compress(src, src_len, dst, dst_len,
cb, method, level, cconf, cresult);
#endif
@ -154,7 +154,7 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
r = upx_lzma_decompress(src, src_len, dst, dst_len, method, cresult);
#endif
#if (WITH_NRV)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
else if ((M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) && !opt->prefer_ucl)
r = upx_nrv_decompress(src, src_len, dst, dst_len, method, cresult);
#endif
#if (WITH_UCL)
@ -201,7 +201,7 @@ int upx_test_overlap ( const upx_bytep buf,
r = upx_lzma_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
#endif
#if (WITH_NRV)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
else if ((M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) && !opt->prefer_ucl)
r = upx_nrv_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
#endif
#if (WITH_UCL)

View File

@ -332,14 +332,9 @@ static bool set_method(int m, int l)
{
if (!Packer::isValidCompressionMethod(m))
return false;
#if 1
// something like "--brute --lzma" should not disable "--brute"
if (!opt->all_methods)
#endif
{
opt->method = m;
opt->all_methods = false;
}
}
if (l > 0)
opt->level = l;
@ -587,6 +582,12 @@ static int do_option(int optc, const char *arg)
if (M_IS_LZMA(opt->method))
opt->method = -1;
break;
case 723:
opt->prefer_ucl = false;
break;
case 724:
opt->prefer_ucl = true;
break;
// compression level
case '1':
@ -983,7 +984,9 @@ static const struct mfx_option longopts[] =
{"nrv2d", 0x10, 0, 704}, // --nrv2d
{"nrv2e", 0x10, 0, 705}, // --nrv2e
{"lzma", 0x10, 0, 721}, // --lzma
{"no-lzma", 0x10, 0, 722}, // (disable all_methods_use_lzma)
{"no-lzma", 0x10, 0, 722}, // disable all_methods_use_lzma
{"prefer-nrv", 0x10, 0, 723},
{"prefer-ucl", 0x10, 0, 724},
// compression settings
{"all-filters", 0x10, 0, 523},
{"all-methods", 0x10, 0, 524},
@ -1142,7 +1145,9 @@ static const struct mfx_option longopts[] =
{"nrv2d", 0x10, 0, 704}, // --nrv2d
{"nrv2e", 0x10, 0, 705}, // --nrv2e
{"lzma", 0x10, 0, 721}, // --lzma
{"no-lzma", 0x10, 0, 722}, // (disable all_methods_use_lzma)
{"no-lzma", 0x10, 0, 722}, // disable all_methods_use_lzma
{"prefer-nrv", 0x10, 0, 723},
{"prefer-ucl", 0x10, 0, 724},
// compression settings
// compression runtime parameters

View File

@ -63,6 +63,7 @@ struct options_t {
bool all_methods_use_lzma;
bool all_filters; // try all available filters ?
bool no_filter; // force no filter
bool prefer_ucl; // prefer UCL
bool exact; // user requires byte-identical decompression
// other options