!undef now issues warnings instead of errors

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7039 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-11-02 19:51:54 +00:00
parent 931b06c782
commit 1afaca0e41
5 changed files with 23 additions and 6 deletions

View file

@ -30,7 +30,7 @@ If \e{/file} is used, the entire text file specified (including whitespace and n
\S1{undef} !undef \S1{undef} !undef
\c gflag \c [/noerrors] gflag [...]
Removes an item from the global define list. Note that $\{SYMBOL\} where SYMBOL is undefined will be translated to "$\{SYMBOL\}". Removes an item from the global define list. Note that $\{SYMBOL\} where SYMBOL is undefined will be translated to "$\{SYMBOL\}".

View file

@ -24,6 +24,8 @@ Released on ??? ??th, 20??
\b Fixed !macroundef of last defined macro bug \b Fixed !macroundef of last defined macro bug
\b !undef issues warnings instead of errors
\b MakeNSIS prints -CMDHELP to stdout (\W{http://sf.net/p/nsis/bugs/1203}{bug #1203}) \b MakeNSIS prints -CMDHELP to stdout (\W{http://sf.net/p/nsis/bugs/1203}{bug #1203})
\S2{} Translations \S2{} Translations

View file

@ -95,6 +95,7 @@ typedef enum {
DW_PP_DELFILE_NOMATCH = DW_PP_DELFILE_DELERROR, DW_PP_DELFILE_NOMATCH = DW_PP_DELFILE_DELERROR,
DW_PP_VERBOSE_POP_EMPTY_STACK = 6150, DW_PP_VERBOSE_POP_EMPTY_STACK = 6150,
//DW_PP_VERBOSE_BAD_LEVEL = 6151?, // 2.x failed to issue a warning. 3.x currently aborts with hard error. //DW_PP_VERBOSE_BAD_LEVEL = 6151?, // 2.x failed to issue a warning. 3.x currently aborts with hard error.
DW_PP_UNDEF_UNDEFINED = 6155,
DW_INCLUDE_NONFATAL_NOT_FOUND = 7000, // reserved ..7009 DW_INCLUDE_NONFATAL_NOT_FOUND = 7000, // reserved ..7009
DW_FILE_NONFATAL_NOT_FOUND = 7010, // reserved ..7019 DW_FILE_NONFATAL_NOT_FOUND = 7010, // reserved ..7019
DW_LANGSTRING_OVERLONGLENGTH = 7020, // reserved ..7024 DW_LANGSTRING_OVERLONGLENGTH = 7020, // reserved ..7024

View file

@ -1010,12 +1010,26 @@ int CEXEBuild::pp_define(LineParser&line)
int CEXEBuild::pp_undef(LineParser&line) int CEXEBuild::pp_undef(LineParser&line)
{ {
if (definedlist.del(line.gettoken_str(1))) UINT noerr = false, stopswitch = false, ti = 1, handled = 0;
for (; ti < line.getnumtokens(); ++ti)
{ {
ERROR_MSG(_T("!undef: \"%") NPRIs _T("\" not defined!\n"), line.gettoken_str(1)); const TCHAR *name = line.gettoken_str(ti);
return PS_ERROR; // Should this be a warning? if (!stopswitch && !_tcsicmp(name, _T("/noerrors")))
{
++noerr;
continue;
}
stopswitch = ++handled;
if (definedlist.del(name) && !noerr)
warning_fl(DW_PP_UNDEF_UNDEFINED, _T("!undef: \"%") NPRIs _T("\" not defined!"), name);
else
SCRIPT_MSG(_T("!undef: \"%") NPRIs _T("\"\n"), name);
}
if (!handled)
{
PRINTHELP();
return PS_ERROR;
} }
SCRIPT_MSG(_T("!undef: \"%") NPRIs _T("\"\n"), line.gettoken_str(1));
return PS_OK; return PS_OK;
} }

View file

@ -271,7 +271,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_P_IFNDEF,_T("!ifndef"),1,-1,_T("symbol [| symbol2 [& symbol3 [...]]]"),TP_ALL}, {TOK_P_IFNDEF,_T("!ifndef"),1,-1,_T("symbol [| symbol2 [& symbol3 [...]]]"),TP_ALL},
{TOK_P_ENDIF,_T("!endif"),0,0,_T(""),TP_ALL}, {TOK_P_ENDIF,_T("!endif"),0,0,_T(""),TP_ALL},
{TOK_P_DEFINE,_T("!define"),1,5,_T("[/ifndef | /redef] ([/date|/utcdate] symbol [value]) | (/file symbol filename) | (/math symbol val1 OP val2)\n OP=(+ - * / % << >> >>> & | ^ ~ ! && ||)"),TP_ALL}, {TOK_P_DEFINE,_T("!define"),1,5,_T("[/ifndef | /redef] ([/date|/utcdate] symbol [value]) | (/file symbol filename) | (/math symbol val1 OP val2)\n OP=(+ - * / % << >> >>> & | ^ ~ ! && ||)"),TP_ALL},
{TOK_P_UNDEF,_T("!undef"),1,0,_T("symbol"),TP_ALL}, {TOK_P_UNDEF,_T("!undef"),1,-1,_T("[/noerrors] symbol"),TP_ALL},
{TOK_P_ELSE,_T("!else"),0,-1,_T("[if[macro][n][def] ...]"),TP_ALL}, {TOK_P_ELSE,_T("!else"),0,-1,_T("[if[macro][n][def] ...]"),TP_ALL},
{TOK_P_ECHO,_T("!echo"),1,0,_T("message"),TP_ALL}, {TOK_P_ECHO,_T("!echo"),1,0,_T("message"),TP_ALL},
{TOK_P_WARNING,_T("!warning"),0,1,_T("[warning_message]"),TP_ALL}, {TOK_P_WARNING,_T("!warning"),0,1,_T("[warning_message]"),TP_ALL},