mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Split options_t::crp into multiple structs.
This commit is contained in:
parent
ba065ec1d8
commit
7e1d9bc768
|
@ -14,6 +14,7 @@ syntax: glob
|
||||||
*.lib
|
*.lib
|
||||||
*.map
|
*.map
|
||||||
*.o
|
*.o
|
||||||
|
*.obj
|
||||||
*.out
|
*.out
|
||||||
*.py[cdo]
|
*.py[cdo]
|
||||||
*.so
|
*.so
|
||||||
|
@ -28,6 +29,7 @@ doc/*.man
|
||||||
doc/*.ps
|
doc/*.ps
|
||||||
doc/*.tex
|
doc/*.tex
|
||||||
|
|
||||||
|
src/GNUmakefile
|
||||||
src/MMakefile
|
src/MMakefile
|
||||||
src/compress_nrv*
|
src/compress_nrv*
|
||||||
src/*.rc
|
src/*.rc
|
||||||
|
|
|
@ -217,8 +217,9 @@ struct lzma_compress_config_t
|
||||||
unsigned dict_size;
|
unsigned dict_size;
|
||||||
unsigned mf_passes;
|
unsigned mf_passes;
|
||||||
#else
|
#else
|
||||||
unsigned dummy;
|
int dummy;
|
||||||
#endif
|
#endif
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define upx_compress_config_p upx_compress_config_t *
|
#define upx_compress_config_p upx_compress_config_t *
|
||||||
|
@ -226,6 +227,10 @@ struct upx_compress_config_t
|
||||||
{
|
{
|
||||||
lzma_compress_config_t conf_lzma;
|
lzma_compress_config_t conf_lzma;
|
||||||
ucl_compress_config_t conf_ucl;
|
ucl_compress_config_t conf_ucl;
|
||||||
|
void reset() {
|
||||||
|
conf_lzma.reset();
|
||||||
|
memset(&conf_ucl, 0xff, sizeof(conf_ucl));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -45,7 +45,7 @@ int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK;
|
||||||
void init_options(struct options_t *o)
|
void init_options(struct options_t *o)
|
||||||
{
|
{
|
||||||
memset(o, 0, sizeof(*o));
|
memset(o, 0, sizeof(*o));
|
||||||
memset(&o->crp, 0xff, sizeof(o->crp));
|
o->crp.reset();
|
||||||
|
|
||||||
o->cmd = CMD_NONE;
|
o->cmd = CMD_NONE;
|
||||||
o->method = -1;
|
o->method = -1;
|
||||||
|
@ -537,7 +537,7 @@ static int do_option(int optc, const char *arg)
|
||||||
opt->method = -1;
|
opt->method = -1;
|
||||||
opt->all_filters = true;
|
opt->all_filters = true;
|
||||||
opt->filter = -1;
|
opt->filter = -1;
|
||||||
opt->crp.m_size = 999999;
|
opt->crp.crp_ucl.m_size = 999999;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case 900: // --best
|
case 900: // --best
|
||||||
if (!set_method(-1, 10))
|
if (!set_method(-1, 10))
|
||||||
|
@ -600,27 +600,27 @@ static int do_option(int optc, const char *arg)
|
||||||
opt->all_methods = true;
|
opt->all_methods = true;
|
||||||
opt->method = -1;
|
opt->method = -1;
|
||||||
break;
|
break;
|
||||||
// compression parms
|
// compression runtime parameters
|
||||||
case 531:
|
case 531:
|
||||||
getoptvar(&opt->crp.c_flags, 0, 3);
|
getoptvar(&opt->crp.crp_ucl.c_flags, 0, 3);
|
||||||
break;
|
break;
|
||||||
case 532:
|
case 532:
|
||||||
getoptvar(&opt->crp.s_level, 0, 2);
|
getoptvar(&opt->crp.crp_ucl.s_level, 0, 2);
|
||||||
break;
|
break;
|
||||||
case 533:
|
case 533:
|
||||||
getoptvar(&opt->crp.h_level, 0, 1);
|
getoptvar(&opt->crp.crp_ucl.h_level, 0, 1);
|
||||||
break;
|
break;
|
||||||
case 534:
|
case 534:
|
||||||
getoptvar(&opt->crp.p_level, 0, 7);
|
getoptvar(&opt->crp.crp_ucl.p_level, 0, 7);
|
||||||
break;
|
break;
|
||||||
case 535:
|
case 535:
|
||||||
getoptvar(&opt->crp.max_offset, 256u, ~0u);
|
getoptvar(&opt->crp.crp_ucl.max_offset, 256u, ~0u);
|
||||||
break;
|
break;
|
||||||
case 536:
|
case 536:
|
||||||
getoptvar(&opt->crp.max_match, 16u, ~0u);
|
getoptvar(&opt->crp.crp_ucl.max_match, 16u, ~0u);
|
||||||
break;
|
break;
|
||||||
case 537:
|
case 537:
|
||||||
if (getoptvar(&opt->crp.m_size, 10000u, 999999u) != 0)
|
if (getoptvar(&opt->crp.crp_ucl.m_size, 10000u, 999999u) != 0)
|
||||||
e_optval("--crp-ms=");
|
e_optval("--crp-ms=");
|
||||||
break;
|
break;
|
||||||
// backup
|
// backup
|
||||||
|
|
|
@ -84,7 +84,11 @@ struct options_t {
|
||||||
int overlay;
|
int overlay;
|
||||||
|
|
||||||
// compression runtime parameters - see struct ucl_compress_config_t
|
// compression runtime parameters - see struct ucl_compress_config_t
|
||||||
struct {
|
struct crp_lzma_t {
|
||||||
|
int dummy;
|
||||||
|
void reset() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
struct crp_ucl_t {
|
||||||
unsigned max_offset;
|
unsigned max_offset;
|
||||||
unsigned max_match;
|
unsigned max_match;
|
||||||
int s_level;
|
int s_level;
|
||||||
|
@ -92,7 +96,14 @@ struct options_t {
|
||||||
int p_level;
|
int p_level;
|
||||||
int c_flags;
|
int c_flags;
|
||||||
unsigned m_size;
|
unsigned m_size;
|
||||||
} crp;
|
void reset() { memset(this, 0xff, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
struct crp_t {
|
||||||
|
crp_lzma_t crp_lzma;
|
||||||
|
crp_ucl_t crp_ucl;
|
||||||
|
void reset() { crp_lzma.reset(); crp_ucl.reset(); }
|
||||||
|
};
|
||||||
|
crp_t crp;
|
||||||
|
|
||||||
// CPU
|
// CPU
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -171,23 +171,23 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
||||||
|
|
||||||
// set compression paramters
|
// set compression paramters
|
||||||
upx_compress_config_t conf;
|
upx_compress_config_t conf;
|
||||||
memset(&conf.conf_ucl, 0xff, sizeof(conf.conf_ucl));
|
conf.reset();
|
||||||
// arguments
|
// arguments
|
||||||
if (max_offset != 0)
|
if (max_offset != 0)
|
||||||
conf.conf_ucl.max_offset = max_offset;
|
conf.conf_ucl.max_offset = max_offset;
|
||||||
if (max_match != 0)
|
if (max_match != 0)
|
||||||
conf.conf_ucl.max_match = max_match;
|
conf.conf_ucl.max_match = max_match;
|
||||||
// options
|
// options
|
||||||
if (opt->crp.c_flags != -1)
|
if (opt->crp.crp_ucl.c_flags != -1)
|
||||||
conf.conf_ucl.c_flags = opt->crp.c_flags;
|
conf.conf_ucl.c_flags = opt->crp.crp_ucl.c_flags;
|
||||||
if (opt->crp.p_level != -1)
|
if (opt->crp.crp_ucl.p_level != -1)
|
||||||
conf.conf_ucl.p_level = opt->crp.p_level;
|
conf.conf_ucl.p_level = opt->crp.crp_ucl.p_level;
|
||||||
if (opt->crp.h_level != -1)
|
if (opt->crp.crp_ucl.h_level != -1)
|
||||||
conf.conf_ucl.h_level = opt->crp.h_level;
|
conf.conf_ucl.h_level = opt->crp.crp_ucl.h_level;
|
||||||
if (opt->crp.max_offset != UINT_MAX && opt->crp.max_offset < conf.conf_ucl.max_offset)
|
if (opt->crp.crp_ucl.max_offset != UINT_MAX && opt->crp.crp_ucl.max_offset < conf.conf_ucl.max_offset)
|
||||||
conf.conf_ucl.max_offset = opt->crp.max_offset;
|
conf.conf_ucl.max_offset = opt->crp.crp_ucl.max_offset;
|
||||||
if (opt->crp.max_match != UINT_MAX && opt->crp.max_match < conf.conf_ucl.max_match)
|
if (opt->crp.crp_ucl.max_match != UINT_MAX && opt->crp.crp_ucl.max_match < conf.conf_ucl.max_match)
|
||||||
conf.conf_ucl.max_match = opt->crp.max_match;
|
conf.conf_ucl.max_match = opt->crp.crp_ucl.max_match;
|
||||||
|
|
||||||
// Avoid too many progress bar updates. 64 is s->bar_len in ui.cpp.
|
// Avoid too many progress bar updates. 64 is s->bar_len in ui.cpp.
|
||||||
unsigned step = (ph.u_len < 64*1024) ? 0 : ph.u_len / 64;
|
unsigned step = (ph.u_len < 64*1024) ? 0 : ph.u_len / 64;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user