diff --git a/Docs/src/defines.but b/Docs/src/defines.but index a63b2f55..db48443e 100644 --- a/Docs/src/defines.but +++ b/Docs/src/defines.but @@ -30,7 +30,7 @@ If \e{/file} is used, the entire text file specified (including whitespace and n \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\}". diff --git a/Docs/src/history.but b/Docs/src/history.but index 632e1ae6..c728fc25 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -24,6 +24,8 @@ Released on ??? ??th, 20?? \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}) \S2{} Translations diff --git a/Source/build.h b/Source/build.h index 42a5850b..d745c0c7 100644 --- a/Source/build.h +++ b/Source/build.h @@ -95,6 +95,7 @@ typedef enum { DW_PP_DELFILE_NOMATCH = DW_PP_DELFILE_DELERROR, 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_UNDEF_UNDEFINED = 6155, DW_INCLUDE_NONFATAL_NOT_FOUND = 7000, // reserved ..7009 DW_FILE_NONFATAL_NOT_FOUND = 7010, // reserved ..7019 DW_LANGSTRING_OVERLONGLENGTH = 7020, // reserved ..7024 diff --git a/Source/scriptpp.cpp b/Source/scriptpp.cpp index bc81c7a0..17513a8d 100644 --- a/Source/scriptpp.cpp +++ b/Source/scriptpp.cpp @@ -1010,12 +1010,26 @@ int CEXEBuild::pp_define(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)); - return PS_ERROR; // Should this be a warning? + const TCHAR *name = line.gettoken_str(ti); + 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; } diff --git a/Source/tokens.cpp b/Source/tokens.cpp index c10491e3..1b1cb580 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -271,7 +271,7 @@ static tokenType tokenlist[TOK__LAST] = {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_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_ECHO,_T("!echo"),1,0,_T("message"),TP_ALL}, {TOK_P_WARNING,_T("!warning"),0,1,_T("[warning_message]"),TP_ALL},