Minor cleanups.

This commit is contained in:
Markus F.X.J. Oberhumer
2006-12-01 00:57:03 +01:00
parent fa95c3c4a2
commit 83052eafae
5 changed files with 17 additions and 15 deletions
+9 -9
View File
@@ -100,8 +100,8 @@ struct PackerNames
Entry names[32]; Entry names[32];
size_t names_count; size_t names_count;
const options_t *o; const options_t *o;
PackerNames() { names_count = 0; o = NULL; } PackerNames() : names_count(0), o(NULL) { }
void add(Packer *p) void add(const Packer *p)
{ {
p->assertPacker(); p->assertPacker();
assert(names_count < 32); assert(names_count < 32);
@@ -161,7 +161,7 @@ static void show_all_packers(FILE *f, int verbose)
// //
**************************************************************************/ **************************************************************************/
void show_help(int x/*verbose*/) void show_help(int verbose)
{ {
FILE *f = con_term; FILE *f = con_term;
int fg; int fg;
@@ -178,8 +178,8 @@ void show_help(int x/*verbose*/)
" -d decompress -l list compressed file\n" " -d decompress -l list compressed file\n"
" -t test compressed file -V display version number\n" " -t test compressed file -V display version number\n"
" -h give %s help -L display software license\n%s", " -h give %s help -L display software license\n%s",
x == 0 ? "" : " --best compress best (can be slow for big files)\n", verbose == 0 ? "" : " --best compress best (can be slow for big files)\n",
x == 0 ? "more" : "this", x == 0 ? "" : "\n"); verbose == 0 ? "more" : "this", verbose == 0 ? "" : "\n");
fg = con_fg(f,FG_YELLOW); fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options:\n"); con_fprintf(f,"Options:\n");
@@ -191,15 +191,15 @@ void show_help(int x/*verbose*/)
//" -f force overwrite of output files and compression of suspicious files\n" //" -f force overwrite of output files and compression of suspicious files\n"
" -f force compression of suspicious files\n" " -f force compression of suspicious files\n"
"%s%s" "%s%s"
, (x == 0) ? " -k keep backup files\n" : "" , (verbose == 0) ? " -k keep backup files\n" : ""
#if 1 #if 1
, (x > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : "" , (verbose > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : ""
#else #else
, "" , ""
#endif #endif
); );
if (x > 0) if (verbose > 0)
{ {
fg = con_fg(f,FG_YELLOW); fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"\nBackup options:\n"); con_fprintf(f,"\nBackup options:\n");
@@ -318,7 +318,7 @@ void show_help(int x/*verbose*/)
fg = con_fg(f,FG_YELLOW); fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"This version supports:\n"); con_fprintf(f,"This version supports:\n");
fg = con_fg(f,fg); fg = con_fg(f,fg);
show_all_packers(f, x); show_all_packers(f, verbose);
con_fprintf(f,"\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n" con_fprintf(f,"\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n"
// "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type `upx -L'.\n" // "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type `upx -L'.\n"
""); "");
+5 -3
View File
@@ -173,14 +173,14 @@ void ElfLinker::init(const void *pdata_v, int plen)
output = new upx_byte[inputlen]; output = new upx_byte[inputlen];
outputlen = 0; outputlen = 0;
int pos = find(input, inputlen, "Sections:", 9); int pos = find(input, inputlen, "Sections:\n", 10);
assert(pos != -1); assert(pos != -1);
char *psections = (char *) input + pos; char *psections = (char *) input + pos;
char *psymbols = strstr(psections, "SYMBOL TABLE:"); char *psymbols = strstr(psections, "SYMBOL TABLE:\n");
assert(psymbols != NULL); assert(psymbols != NULL);
char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR"); char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR ");
assert(prelocs != NULL); assert(prelocs != NULL);
preprocessSections(psections, psymbols); preprocessSections(psections, psymbols);
@@ -369,11 +369,13 @@ ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned of
return rel; return rel;
} }
#if 0
void ElfLinker::setLoaderAlignOffset(int phase) void ElfLinker::setLoaderAlignOffset(int phase)
{ {
//assert(phase & 0); //assert(phase & 0);
printf("\nFIXME: ElfLinker::setLoaderAlignOffset %d\n", phase); printf("\nFIXME: ElfLinker::setLoaderAlignOffset %d\n", phase);
} }
#endif
int ElfLinker::addLoader(const char *sname) int ElfLinker::addLoader(const char *sname)
{ {
+1 -1
View File
@@ -81,7 +81,7 @@ public:
virtual ~ElfLinker(); virtual ~ElfLinker();
virtual void init(const void *pdata, int plen); virtual void init(const void *pdata, int plen);
virtual void setLoaderAlignOffset(int phase); //virtual void setLoaderAlignOffset(int phase);
virtual int addLoader(const char *sname); virtual int addLoader(const char *sname);
virtual Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align); virtual Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align);
virtual int getSection(const char *sname, int *slen=NULL) const; virtual int getSection(const char *sname, int *slen=NULL) const;
+1 -1
View File
@@ -60,7 +60,7 @@ Packer::~Packer()
// for PackMaster // for PackMaster
void Packer::assertPacker() void Packer::assertPacker() const
{ {
assert(getFormat() > 0); assert(getFormat() > 0);
assert(getFormat() <= 255); assert(getFormat() <= 255);
+1 -1
View File
@@ -119,7 +119,7 @@ protected:
Packer(InputFile *f); Packer(InputFile *f);
public: public:
virtual ~Packer(); virtual ~Packer();
virtual void assertPacker(); virtual void assertPacker() const;
virtual int getVersion() const = 0; virtual int getVersion() const = 0;
// A unique integer ID for this executable format. See conf.h. // A unique integer ID for this executable format. See conf.h.