Added !define /intfmt

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7173 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2020-04-22 21:14:55 +00:00
parent dd117d4ba7
commit e1141d9277
6 changed files with 44 additions and 6 deletions

View file

@ -186,6 +186,9 @@ ${ASSERT} '${OUT1} = 0x80000000'
!define /redef /math OUT1 0x80000000 ^ 0x40000000
${ASSERT} '${OUT1} = 0xC0000000'
!define /redef /intfmt OUT1 "0x%.3X" 42
${ASSERT} '${OUT1} = 0x02A'
; end math functions
@ -292,6 +295,15 @@ PageExEnd
!warning "You can't see me" ; "disable all" is still in effect
!pragma warning pop
!if ! 1 <> 0
!error "1 is not 0"
!endif
!pragma warning push
!pragma warning disable 7070 ; Invalid number
!if Hello <> 0
!error "Hello is not a number"
!endif
!pragma warning pop
# test !searchparse
!searchparse "AbcDef" "Abc" OUT1

View file

@ -992,6 +992,12 @@ int CEXEBuild::pp_define(LineParser&line)
if (tc + onlyval1 != 6) goto badmathsyntax;
}
else if (!_tcsicmp(define, _T("/intfmt")))
{
if (line.getnumtokens() != 5) PRINTHELPEX(cmdnam)
define = line.gettoken_str(2);
_stprintf(value = mathbuf, line.gettoken_str(3), line.gettoken_int(4));
}
else
{
if (line.getnumtokens() >= 4) PRINTHELPEX(cmdnam)

View file

@ -282,7 +282,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) | (/intfmt gflag fmtstr value) | (/math symbol val1 OP val2)\n OP=(+ - * / % << >> >>> & | ^ ~ ! && ||)"),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},