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

Clean up help and avoid using backticks as quoting chars.

This commit is contained in:
Markus F.X.J. Oberhumer 2006-12-06 08:11:55 +01:00
parent 770c153c76
commit ae945ed315
15 changed files with 66 additions and 49 deletions

View File

@ -131,7 +131,7 @@ public:
off_t getBytesWritten() const { return bytes_written; }
// FIXME - these won't work when using the `--stdout' option
// FIXME - these won't work when using the '--stdout' option
virtual void seek(off_t off, int whence)
{
assert(!opt->to_stdout);

View File

@ -136,7 +136,7 @@ static void show_all_packers(FILE *f, int verbose)
const char *sn = pn.names[i].sname;
if (verbose)
{
con_fprintf(f, " %-30s %s\n", fn, sn);
con_fprintf(f, " %-32s %s\n", fn, sn);
}
else
{
@ -187,7 +187,7 @@ void show_help(int verbose)
con_fprintf(f,
" -q be quiet -v be verbose\n"
" -oFILE write output to `FILE'\n"
" -oFILE write output to 'FILE'\n"
//" -f force overwrite of output files and compression of suspicious files\n"
" -f force compression of suspicious files\n"
"%s%s"
@ -202,7 +202,14 @@ void show_help(int verbose)
if (verbose > 0)
{
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"\nBackup options:\n");
con_fprintf(f,"\nCompression tuning options:\n");
fg = con_fg(f,fg);
con_fprintf(f,
" --brute try all available compression methods & filters\n"
" --ultra-brute try even more compression variants\n"
"\n");
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Backup options:\n");
fg = con_fg(f,fg);
con_fprintf(f,
" -k, --backup keep backup files\n"
@ -312,15 +319,22 @@ void show_help(int verbose)
"\n");
}
con_fprintf(f,
"file.. executables to (de)compress\n"
"\n");
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"This version supports:\n");
fg = con_fg(f,fg);
show_all_packers(f, verbose);
con_fprintf(f, "file.. executables to (de)compress\n");
if (verbose > 0)
{
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"\nThis version supports:\n");
fg = con_fg(f,fg);
show_all_packers(f, verbose);
}
else
{
con_fprintf(f,"\nType '%s --help' for more detailed help.\n", progname);
}
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"
"");
#if defined(DEBUG) || defined(TESTING)
@ -423,7 +437,7 @@ void show_version(int x)
#if defined(WITH_LZMA)
fprintf(fp, "Copyright (C) 1999-2006 Igor Pavlov\n");
#endif
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
}

View File

@ -183,7 +183,7 @@ static void e_method(int m, int l)
static void e_optarg(const char *n)
{
fflush(con_term);
fprintf(stderr,"%s: invalid argument in option `%s'\n", argv0, n);
fprintf(stderr,"%s: invalid argument in option '%s'\n", argv0, n);
e_exit(EXIT_USAGE);
}
@ -191,7 +191,7 @@ static void e_optarg(const char *n)
static void e_optval(const char *n)
{
fflush(con_term);
fprintf(stderr,"%s: invalid value for option `%s'\n", argv0, n);
fprintf(stderr,"%s: invalid value for option '%s'\n", argv0, n);
e_exit(EXIT_USAGE);
}
@ -201,10 +201,10 @@ void e_envopt(const char *n)
{
fflush(con_term);
if (n)
fprintf(stderr,"%s: invalid string `%s' in environment variable `%s'\n",
fprintf(stderr,"%s: invalid string '%s' in environment variable '%s'\n",
argv0, n, OPTIONS_VAR);
else
fprintf(stderr,"%s: illegal option in environment variable `%s'\n",
fprintf(stderr,"%s: illegal option in environment variable '%s'\n",
argv0, OPTIONS_VAR);
e_exit(EXIT_USAGE);
}
@ -227,7 +227,7 @@ void check_not_both(bool e1, bool e2, const char *c1, const char *c2)
if (e1 && e2)
{
fprintf(stderr,"%s: ",argv0);
fprintf(stderr,"cannot use both `%s' and `%s'\n", c1, c2);
fprintf(stderr,"cannot use both '%s' and '%s'\n", c1, c2);
e_usage();
}
}
@ -264,14 +264,14 @@ void check_options(int i, int argc)
check_not_both(opt->to_stdout, opt->output_name != NULL, "--stdout", "-o");
if (opt->to_stdout && opt->cmd == CMD_COMPRESS)
{
fprintf(stderr,"%s: cannot use `--stdout' when compressing\n", argv0);
fprintf(stderr,"%s: cannot use '--stdout' when compressing\n", argv0);
e_usage();
}
if (opt->to_stdout || opt->output_name)
{
if (i + 1 != argc)
{
fprintf(stderr,"%s: need exactly one argument when using `%s'\n",
fprintf(stderr,"%s: need exactly one argument when using '%s'\n",
argv0, opt->to_stdout ? "--stdout" : "-o");
e_usage();
}
@ -333,7 +333,7 @@ static void set_output_name(const char *n, bool allow_m)
#if 1
if (done_output_name > 0)
{
fprintf(stderr,"%s: option `-o' more than once given\n",argv0);
fprintf(stderr,"%s: option '-o' more than once given\n",argv0);
e_usage();
}
#endif
@ -356,7 +356,7 @@ static void set_script_name(const char *n, bool allow_m)
#if 1
if (done_script_name > 0)
{
fprintf(stderr,"%s: option `--script' more than once given\n",argv0);
fprintf(stderr,"%s: option '--script' more than once given\n",argv0);
e_usage();
}
#endif
@ -508,10 +508,13 @@ static int do_option(int optc, const char *arg)
set_cmd(CMD_HELP);
break;
case 'h'+256:
#if 0
/* according to GNU standards */
set_term(stdout);
opt->console = CON_FILE;
#if 1
if (!acc_isatty(STDOUT_FILENO))
{
/* according to GNU standards */
set_term(stdout);
opt->console = CON_FILE;
}
#endif
show_help(1);
e_exit(EXIT_OK);
@ -716,7 +719,7 @@ static int do_option(int optc, const char *arg)
opt->backup = 1;
break;
case 541:
if (opt->backup != 1) // do not overide `--backup'
if (opt->backup != 1) // do not overide '--backup'
opt->backup = 0;
break;
// overlay

View File

@ -554,7 +554,7 @@ void PackArmPe::pack(OutputFile *fo)
if (ih.entry && ih.entry < rvamin)
throwCantPack("run a virus scanner on this file!");
if (!opt->force && ih.subsystem == 1)
throwCantPack("subsystem `native' is not supported (try --force)");
throwCantPack("subsystem 'native' is not supported (try --force)");
if (ih.filealign < 0x200)
throwCantPack("filealign < 0x200 is not yet supported");

View File

@ -192,7 +192,7 @@ struct Shdr
SHF_EXECINSTR = (1 << 2), /* Executable */
SHF_MERGE = (1 << 4), /* Might be merged */
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
SHF_INFO_LINK = (1 << 6), /* `sh_info' contains SHT index */
SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
SHF_LINK_ORDER = (1 << 7), /* Preserve order after combining */
};
}

View File

@ -776,12 +776,12 @@ bool PackLinuxElf32::canPack()
// additional requirements for linux/elf386
if (get_native16(&ehdr->e_ehsize) != sizeof(*ehdr)) {
throwCantPack("invalid Ehdr e_ehsize; try `--force-execve'");
throwCantPack("invalid Ehdr e_ehsize; try '--force-execve'");
return false;
}
unsigned const e_phoff = get_native32(&ehdr->e_phoff);
if (e_phoff != sizeof(*ehdr)) {// Phdrs not contiguous with Ehdr
throwCantPack("non-contiguous Ehdr/Phdr; try `--force-execve'");
throwCantPack("non-contiguous Ehdr/Phdr; try '--force-execve'");
return false;
}
@ -794,7 +794,7 @@ bool PackLinuxElf32::canPack()
return false;
if (1!=exetype && phdr->PT_LOAD32 == get_native32(&phdr->p_type)) {
if (phdr->p_offset != 0) {
throwCantPack("invalid Phdr p_offset; try `--force-execve'");
throwCantPack("invalid Phdr p_offset; try '--force-execve'");
return false;
}
exetype = 1;
@ -901,12 +901,12 @@ PackLinuxElf64amd::canPack()
// additional requirements for linux/elf386
if (get_native16(&ehdr->e_ehsize) != sizeof(*ehdr)) {
throwCantPack("invalid Ehdr e_ehsize; try `--force-execve'");
throwCantPack("invalid Ehdr e_ehsize; try '--force-execve'");
return false;
}
acc_uint64l_t const e_phoff = get_native64(&ehdr->e_phoff);
if (e_phoff != sizeof(*ehdr)) {// Phdrs not contiguous with Ehdr
throwCantPack("non-contiguous Ehdr/Phdr; try `--force-execve'");
throwCantPack("non-contiguous Ehdr/Phdr; try '--force-execve'");
return false;
}
@ -919,7 +919,7 @@ PackLinuxElf64amd::canPack()
if (phdr->PT_LOAD64 == get_native32(&phdr->p_type)) {
// Just avoid the "rewind" when unpacking?
//if (phdr->p_offset != 0) {
// throwCantPack("invalid Phdr p_offset; try `--force-execve'");
// throwCantPack("invalid Phdr p_offset; try '--force-execve'");
// return false;
//}
exetype = 1;

View File

@ -168,7 +168,7 @@ int PackTmt::readFileHeader()
fi->seek(adam_offset,SEEK_SET);
fi->readx(&ih,sizeof(ih));
// FIXME: should add some checks for the values in `ih'
// FIXME: should add some checks for the values in 'ih'
return UPX_F_TMT_ADAM;
#undef H4

View File

@ -307,19 +307,19 @@ bool PackTos::checkFileHeader()
if ((f & F_PROTMODE) != F_PROT_P)
{
if (opt->force < 1)
throwCantPack("no private memory protection; use option `-f' to force packing");
throwCantPack("no private memory protection; use option '-f' to force packing");
}
if (f & F_SHTEXT)
{
if (opt->force < 1)
throwCantPack("shared text segment; use option `-f' to force packing");
throwCantPack("shared text segment; use option '-f' to force packing");
}
#if 0
// fh_reserved seems to be unused
if (ih.fh_reserved != 0)
{
if (opt->force < 1)
throwCantPack("reserved header field set; use option `-f' to force packing");
throwCantPack("reserved header field set; use option '-f' to force packing");
}
#endif
return true;

View File

@ -62,7 +62,7 @@ bool PackUnix::canPack()
#if defined(__unix__)
// must be executable by owner
if ((fi->st.st_mode & S_IXUSR) == 0)
throwCantPack("file not executable; try `chmod +x'");
throwCantPack("file not executable; try 'chmod +x'");
#endif
if (file_size < 4096)
throwCantPack("file is too small");

View File

@ -208,7 +208,7 @@ int PackVmlinuzI386::decompressKernel()
if (fd_pos != file_size)
{
//printf("fd_pos: %ld, file_size: %ld\n", (long)fd_pos, (long)file_size);
throwCantPack("trailing bytes after kernel image; use option `-f' to force packing");
throwCantPack("trailing bytes after kernel image; use option '-f' to force packing");
}
@ -227,7 +227,7 @@ int PackVmlinuzI386::decompressKernel()
&& 0x0F==ibuf[19] && 0xA2==ibuf[20] // cpuid
) goto head_ok;
throwCantPack("unrecognized kernel architecture; use option `-f' to force packing");
throwCantPack("unrecognized kernel architecture; use option '-f' to force packing");
head_ok:
// FIXME: more checks for special magic bytes in ibuf ???

View File

@ -649,7 +649,7 @@ void PackW32Pe::pack(OutputFile *fo)
if (ih.entry && ih.entry < rvamin)
throwCantPack("run a virus scanner on this file!");
if (!opt->force && ih.subsystem == 1)
throwCantPack("subsystem `native' is not supported (try --force)");
throwCantPack("subsystem 'native' is not supported (try --force)");
if (ih.filealign < 0x200)
throwCantPack("filealign < 0x200 is not yet supported");

View File

@ -538,7 +538,7 @@ void Packer::checkOverlay(unsigned overlay)
return;
info("Found overlay: %d bytes", overlay);
if (opt->overlay == opt->SKIP_OVERLAY)
throw OverlayException("file has overlay -- skipped; try `--overlay=copy'");
throw OverlayException("file has overlay -- skipped; try '--overlay=copy'");
}
@ -732,7 +732,7 @@ void Packer::checkAlreadyPacked(const void *b, int blen)
//if (!tmp.fillPackHeader((unsigned char *)b + boff, blen - boff))
// return;
//
// This also would require that the buffer in `b' holds
// This also would require that the buffer in 'b' holds
// the full PackHeader, and not only the 4 magic bytes.
throwAlreadyPacked();

View File

@ -333,7 +333,7 @@ static double my_modf(double x0, double *iptr)
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
LDOUBLE fvalue, int min, int max, int flags)
{
/* avoid warnings with `gcc -Wshadow' */
/* avoid warnings with 'gcc -Wshadow' */
#undef index
#define index iindex
int signvalue = 0;

View File

@ -241,7 +241,7 @@ void UiPacker::startCallback(unsigned u_len, unsigned step,
s->bar_len = 64;
s->pos = -2;
s->spin_counter = 0;
s->bar_pos = 1; // because of the leading `\r'
s->bar_pos = 1; // because of the leading '\r'
s->pass_digits = 0;
cb.reset();
@ -481,7 +481,7 @@ void UiPacker::doCallback(unsigned isize, unsigned osize)
#if 0
s->screen->putString(s->screen,msg,s->b_cx,s->b_cy);
#else
// FIXME: this doesn't honor `--mono' etc.
// FIXME: this doesn't honor '--mono' etc.
int attr = FG_CYAN | s->s_bg;
s->screen->putStringAttr(s->screen,msg,attr,s->b_cx,s->b_cy);
#endif

View File

@ -108,7 +108,7 @@ void do_one_file(const char *iname, char *oname)
if (opt->to_stdout)
{
if (!fo.openStdout(1, opt->force ? true : false))
throwIOException("data not written to a terminal; Use `-f' to force.");
throwIOException("data not written to a terminal; Use '-f' to force.");
}
else
{