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

@ -8,6 +8,8 @@ Released on ??? ??th, 20??
\S2{} Minor Changes \S2{} Minor Changes
\b MakeNSIS prints -CMDHELP to stdout (\W{http://sf.net/p/nsis/bugs/1203}{bug #1203})
\H{v3.03} 3.03 \H{v3.03} 3.03
Released on January 29th, 2018 Released on January 29th, 2018

View file

@ -254,6 +254,7 @@ class CEXEBuild {
int write_output(void); int write_output(void);
void print_help(const TCHAR *commandname=NULL); void print_help(const TCHAR *commandname=NULL);
bool print_cmdhelp(const TCHAR *commandname, bool cmdhelp=false);
DefineList definedlist; // List of identifiers marked as "defined" like DefineList definedlist; // List of identifiers marked as "defined" like
// C++ macro definitions such as _UNICODE. // C++ macro definitions such as _UNICODE.

View file

@ -479,11 +479,8 @@ static inline int makensismain(int argc, TCHAR **argv)
} }
else if (!_tcsicmp(swname,_T("CMDHELP"))) else if (!_tcsicmp(swname,_T("CMDHELP")))
{ {
if (argpos < argc-1) if (build.print_cmdhelp(argpos < argc-1 ? argv[++argpos] : NULL, true))
build.print_help(argv[++argpos]); performed |= ++nousage;
else
build.print_help(NULL);
performed |= ++nousage;
} }
else if (!_tcsicmp(swname,_T("HDRINFO"))) else if (!_tcsicmp(swname,_T("HDRINFO")))
{ {

View file

@ -325,22 +325,30 @@ const TCHAR* CEXEBuild::get_commandtoken_name(int tok)
return 0; 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; UINT x;
for (x = 0; x < TOK__LAST; ++x) for (x = 0; x < TOK__LAST; ++x)
{ {
if (!commandname || !_tcsicmp(tokenlist[x].name,commandname)) 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 (commandname) break;
} }
} }
if (x == TOK__LAST && commandname) if (x == TOK__LAST && commandname)
{ {
ERROR_MSG(_T("Invalid command \"%") NPRIs _T("\"\n"),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) bool CEXEBuild::is_ppbranch_token(const TCHAR *s)