Fixed bug #1203, -CMDHELP should be printed to stdout

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6982 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-02-04 21:19:55 +00:00
parent 696a317eca
commit 8f9cc7ff35
4 changed files with 15 additions and 7 deletions

View file

@ -325,22 +325,30 @@ const TCHAR* CEXEBuild::get_commandtoken_name(int tok)
return 0;
}
void CEXEBuild::print_help(const TCHAR *commandname)
bool CEXEBuild::print_cmdhelp(const TCHAR *commandname, bool cmdhelp)
{
// Print function chosen at run time because of bug #1203, -CMDHELP to stdout.
void (CEXEBuild::*printer)(const TCHAR *s, ...) const = cmdhelp ? &CEXEBuild::INFO_MSG : &CEXEBuild::ERROR_MSG;
UINT x;
for (x = 0; x < TOK__LAST; ++x)
{
if (!commandname || !_tcsicmp(tokenlist[x].name,commandname))
{
ERROR_MSG(_T("%") NPRIs _T("%") NPRIs _T(" %") NPRIs _T("\n"),commandname?_T("Usage: "):_T(""),tokenlist[x].name,tokenlist[x].usage_str);
(this->*printer)(_T("%") NPRIs _T("%") NPRIs _T(" %") NPRIs _T("\n"),commandname?_T("Usage: "):_T(""),tokenlist[x].name,tokenlist[x].usage_str);
if (commandname) break;
}
}
if (x == TOK__LAST && commandname)
{
ERROR_MSG(_T("Invalid command \"%") NPRIs _T("\"\n"),commandname);
return false;
}
return true;
}
void CEXEBuild::print_help(const TCHAR *commandname)
{
print_cmdhelp(commandname);
}
bool CEXEBuild::is_ppbranch_token(const TCHAR *s)