Refactor and document !pragma warning error and warning states

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6980 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-01-31 15:31:49 +00:00
parent ee4e6039ae
commit 0b01a969e4
4 changed files with 13 additions and 25 deletions

View file

@ -184,7 +184,7 @@ This command will issue a warning to the script compiler. You can also add a mes
\S1{pragma} !pragma
\c warning <enable|disable|default> code
\c warning <enable|disable|default|error|warning> <code|all>
\c warning <push|pop>
The pragma commands allows you to change compiler features and behavior.

View file

@ -38,6 +38,8 @@ Released on January 29th, 2018
\b MakeNSIS exits with code 0 for various information commands (\W{http://sf.net/p/nsis/bugs/1193}{bug #1193})
\b Added error and warning states to !pragma warning
\b Removed unused NSD_LB_Clear macro parameter
\S2{} Translations

View file

@ -3447,34 +3447,20 @@ int CEXEBuild::parse_pragma(LineParser &line)
if (!diagstate.pop())
ret = rvWarn, warning_fl(DW_PP_PRAGMA_INVALID, _T("Unexpected"));
}
else // warning: error/warning/disable/enable/default
else // warning: error/warning/disable/enable/default <%code%|all> [..]
{
for (int ti = 3; ti < line.getnumtokens(); ++ti)
{
DIAGCODE code = static_cast<DIAGCODE>(line.gettoken_int(ti));
bool all = 0 == line.gettoken_enum(ti, _T("all\0"));
if (diagstate.is_valid_code(code))
bool all = line.gettoken_enum(ti, _T("all\0")) == 0, isCode = diagstate.is_valid_code(code);
switch((isCode||all) ? warnOp : invalidwop)
{
switch(warnOp)
{
case woperr: diagstate.error(code); break;
case wopwar: diagstate.warning(code); break;
case wopdis: diagstate.disable(code); break;
case wopena: diagstate.enable(code); break;
case wopdef: diagstate.def(code); break;
default: assert(0);
}
}
else
{
switch(all ? warnOp : invalidwop)
{
case woperr: diagstate.set_all(diagstate.werror); break;
case wopdis: diagstate.set_all(DiagState::wdisabled); break;
case wopena: diagstate.set_all(DiagState::wenabled); break;
case wopdef: diagstate.set_all(DiagState::get_default_state()); break;
default: ret = rvWarn, warning_fl(DW_PP_PRAGMA_INVALID, _T("Invalid number: \"%") NPRIs _T("\""), line.gettoken_str(ti));
}
case woperr: all ? diagstate.set_all(DiagState::werror) : diagstate.error(code); break;
case wopwar: all ? diagstate.set_all(DiagState::wwarning) : diagstate.warning(code); break;
case wopdis: all ? diagstate.set_all(DiagState::wdisabled) : diagstate.disable(code); break;
case wopena: all ? diagstate.set_all(DiagState::wenabled) : diagstate.enable(code); break;
case wopdef: all ? diagstate.set_all(DiagState::get_default_state()) : diagstate.def(code); break;
default: ret = rvWarn, warning_fl(DW_PP_PRAGMA_INVALID, _T("Invalid number: \"%") NPRIs _T("\""), line.gettoken_str(ti));
}
}
}

View file

@ -276,7 +276,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_P_ERROR,_T("!error"),0,1,_T("[error_message]"),TP_ALL},
{TOK_P_VERBOSE,_T("!verbose"),1,-1,_T("verbose_level | push | pop [...]"),TP_ALL},
{TOK_P_PRAGMA,_T("!pragma"),2,-1,_T("warning <enable|disable|default> number | warning <push|pop>"),TP_ALL},
{TOK_P_PRAGMA,_T("!pragma"),1,-1,_T("warning <enable|disable|default|error|warning> <code|all> | warning <push|pop>"),TP_ALL},
{TOK_P_MACRO,_T("!macro"),1,-1,_T("macroname [parms ...]"),TP_ALL},
{TOK_P_MACROEND,_T("!macroend"),0,0,_T(""),TP_ALL},