applied patch #1372048 - added /NONFATAL switch to !include statement

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4437 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2005-12-03 09:45:17 +00:00
parent 90a7765cd6
commit b1be974447
4 changed files with 38 additions and 6 deletions

View file

@ -6,14 +6,15 @@ These commands are similar to the C preprocessor in terms of purpose and functio
\S1{include} !include \S1{include} !include
\c file \c [/NONFATAL] file
This command will include 'file' as if it was part of the original script. Note that if a file is included in another directory, the current directory is still where the script was compiled from (not where the included file resides). If the compiler can't find the file it will look for it in every include directory. See \R{addincludedir}{!addincludedir} for more information. This command will include 'file' as if it was part of the original script. Note that if a file is included in another directory, the current directory is still where the script was compiled from (not where the included file resides). If the compiler can't find the file it will look for it in every include directory. See \R{addincludedir}{!addincludedir} for more information. If the /nonfatal switch is used and no files are found, a warning will be issued instead of an error.
\c !include WinMessages.nsh \c !include WinMessages.nsh
\c !include Library.nsh \c !include Library.nsh
\c !include MyConfig.nsh \c !include C:\MyConfig.nsi
\c !include ..\MyConfig.nsh \c !include ..\MyConfig.nsh
\c !include /NONFATAL file_that_may_exist_or_not.nsh
\S1{addincludedir} !addincludedir \S1{addincludedir} !addincludedir

View file

@ -1,3 +1,6 @@
!ifndef file_is_included
!define file_is_included
Name preprocessor Name preprocessor
OutFile preprocessor.exe OutFile preprocessor.exe
@ -48,5 +51,16 @@ d\
i\ i\
f f
# this should just give a warning, not an error
!include /NONFATAL file_that_doesnt_exist.nsh
# this should include this file just one time.
!include preprocessor.nsi
Section Section
SectionEnd SectionEnd
!else
# this should just give a warning, not an error
!include /NONFATAL another_file_that_doesnt_exist.nsh
!endif

View file

@ -2745,7 +2745,20 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
case TOK_P_INCLUDE: case TOK_P_INCLUDE:
{ {
bool required = true;
char *f = line.gettoken_str(1); char *f = line.gettoken_str(1);
if(!stricmp(f,"/nonfatal")) {
if (line.getnumtokens()!=3)
PRINTHELP();
f = line.gettoken_str(2);
required = false;
} else if (line.getnumtokens()!=2) {
PRINTHELP();
}
#ifdef _WIN32 #ifdef _WIN32
char *fc = f; char *fc = f;
#else #else
@ -2820,8 +2833,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
// nothing found // nothing found
if (!included) if (!included)
{ {
ERROR_MSG("!include: could not find: \"%s\"\n",f); if(required) {
return PS_ERROR; ERROR_MSG("!include: could not find: \"%s\"\n",f);
return PS_ERROR;
} else {
warning_fl("!include: could not find: \"%s\"",f);
}
} }
} }
return PS_OK; return PS_OK;

View file

@ -222,7 +222,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_P_SYSTEMEXEC,"!system",1,2,"command [<|>|<>|=) retval]",TP_ALL}, {TOK_P_SYSTEMEXEC,"!system",1,2,"command [<|>|<>|=) retval]",TP_ALL},
{TOK_P_EXECUTE,"!execute",1,0,"command",TP_ALL}, {TOK_P_EXECUTE,"!execute",1,0,"command",TP_ALL},
{TOK_P_ADDINCLUDEDIR,"!AddIncludeDir",1,0,"dir",TP_ALL}, {TOK_P_ADDINCLUDEDIR,"!AddIncludeDir",1,0,"dir",TP_ALL},
{TOK_P_INCLUDE,"!include",1,0,"filename.nsi",TP_ALL}, {TOK_P_INCLUDE,"!include",1,1,"[/NONFATAL] filename.nsh",TP_ALL},
{TOK_P_CD,"!cd",1,0,"absolute_or_relative_new_directory",TP_ALL}, {TOK_P_CD,"!cd",1,0,"absolute_or_relative_new_directory",TP_ALL},
{TOK_P_IFDEF,"!ifdef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL}, {TOK_P_IFDEF,"!ifdef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL},
{TOK_P_IFNDEF,"!ifndef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL}, {TOK_P_IFNDEF,"!ifndef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL},