From 8f9cc7ff3564b68e22b6cf5a601d08b7d89e7628 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sun, 4 Feb 2018 21:19:55 +0000 Subject: [PATCH] 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 --- Docs/src/history.but | 2 ++ Source/build.h | 1 + Source/makenssi.cpp | 7 ++----- Source/tokens.cpp | 12 ++++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Docs/src/history.but b/Docs/src/history.but index 23766830..d740c61a 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -8,6 +8,8 @@ Released on ??? ??th, 20?? \S2{} Minor Changes +\b MakeNSIS prints -CMDHELP to stdout (\W{http://sf.net/p/nsis/bugs/1203}{bug #1203}) + \H{v3.03} 3.03 Released on January 29th, 2018 diff --git a/Source/build.h b/Source/build.h index c38769de..7afa510b 100644 --- a/Source/build.h +++ b/Source/build.h @@ -254,6 +254,7 @@ class CEXEBuild { int write_output(void); 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 // C++ macro definitions such as _UNICODE. diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index aedd57ed..ced16be0 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -479,11 +479,8 @@ static inline int makensismain(int argc, TCHAR **argv) } else if (!_tcsicmp(swname,_T("CMDHELP"))) { - if (argpos < argc-1) - build.print_help(argv[++argpos]); - else - build.print_help(NULL); - performed |= ++nousage; + if (build.print_cmdhelp(argpos < argc-1 ? argv[++argpos] : NULL, true)) + performed |= ++nousage; } else if (!_tcsicmp(swname,_T("HDRINFO"))) { diff --git a/Source/tokens.cpp b/Source/tokens.cpp index a00caa6a..6256201d 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -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)