Added <<, >> and >>> !define /math operations

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6199 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2011-12-06 21:04:47 +00:00
parent 67d0b165b1
commit dca62fbbc7
3 changed files with 8 additions and 2 deletions

View file

@ -16,7 +16,7 @@ This command will add \e{gflag} to the global define list. This will have a simi
If \e{/date} or \e{/utcdate} are used, \e{value} will be passed into strftime and the result will be used as the value of \e{gflag}. strftime converts special symbols into certain parts of the current time or date. For example, %H will be converted into the current hour in 24-hour format. For a complete list of available symbols, search for strftime on \W{http://msdn.microsoft.com/}{MSDN}. On POSIX, you can get the list by using \c{man strftime}.
If \e{/math} is used, the result of 'val1 OP val2', where OP may be +,-,*,&,|,^,/ or % , will be used as the value of \e{gflag}. Note that val1 AND val2 MUST be integer values!
If \e{/math} is used, the result of 'val1 OP val2', where OP may be +,-,*,&,|,^,/,<<,>>,>>> or % , will be used as the value of \e{gflag}. Note that val1 AND val2 MUST be integer values!
If \e{/file} is used, the entire text file specified (including whitespace and newlines) will be read and stuffed into \e{gflag}.

View file

@ -3062,6 +3062,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
_stprintf(value,_T("%d"),value1|value2);
} else if (!_tcscmp(mathop,_T("^"))) {
_stprintf(value,_T("%d"),value1^value2);
} else if (!_tcscmp(mathop,_T("<<")) || !_tcscmp(mathop,_T("<<<")) ) {
_stprintf(value,_T("%d"),value1<<value2);
} else if (!_tcscmp(mathop,_T(">>"))) {
_stprintf(value,_T("%d"),(signed)value1>>(signed)value2);
} else if (!_tcscmp(mathop,_T(">>>"))) {
_stprintf(value,_T("%d"),(unsigned)value1>>(unsigned)value2);
} else if (!_tcscmp(mathop,_T("/"))) {
if (value2==0) {
ERROR_MSG(_T("!define /math: division by zero! (\"%i / %i\")\n"),value1,value2);

View file

@ -251,7 +251,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_P_IFDEF,_T("!ifdef"),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_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_ELSE,_T("!else"),0,-1,_T("[if[macro][n][def] ...]"),TP_ALL},
{TOK_P_ECHO,_T("!echo"),1,0,_T("message"),TP_ALL},