From e1141d9277025018a582b10a26edd89daf4b78ae Mon Sep 17 00:00:00 2001 From: anders_k Date: Wed, 22 Apr 2020 21:14:55 +0000 Subject: [PATCH] Added !define /intfmt git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7173 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsDialogs/nsDialogs.nsh | 19 +++++++++++++++++-- Docs/src/defines.but | 9 ++++++--- Docs/src/history.but | 2 ++ Source/Tests/preprocessor.nsi | 12 ++++++++++++ Source/scriptpp.cpp | 6 ++++++ Source/tokens.cpp | 2 +- 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh index 5fd84c4d..0348bfc1 100644 --- a/Contrib/nsDialogs/nsDialogs.nsh +++ b/Contrib/nsDialogs/nsDialogs.nsh @@ -212,10 +212,16 @@ Header file for creating custom installer pages with nsDialogs !define /ifndef ICC_UPDOWN_CLASS 0x0010 !define /ifndef ICC_HOTKEY_CLASS 0x0040 !define /ifndef ICC_ANIMATE_CLASS 0x0080 +#define /ifndef ICC_WIN95_CLASSES 0x00FF !define /ifndef ICC_DATE_CLASSES 0x0100 !define /ifndef ICC_USEREX_CLASSES 0x0200 +!define /ifndef ICC_USEREX_CLASSES 0x0200 +!define /ifndef ICC_COOL_CLASSES 0x0400 !define /ifndef ICC_INTERNET_CLASSES 0x0800 -!define /ifndef ICC_LINK_CLASS 0x8000 +!define /ifndef ICC_PAGESCROLLER_CLASS 0x1000 +!define /ifndef ICC_NATIVEFNTCTL_CLASS 0x2000 +#define /ifndef ICC_STANDARD_CLASSES 0x4000 ; WinXP+ +!define /ifndef ICC_LINK_CLASS 0x8000 ; WinXP+ !define DEFAULT_STYLES ${WS_CHILD}|${WS_VISIBLE}|${WS_CLIPSIBLINGS} @@ -450,9 +456,18 @@ SendMessage ${hCtl} ${${msg}} ${wp} ${lp} ${VAR} !define NSD_InitCommonControlsEx "!insertmacro __NSD_InitCommonControlsEx " !macro __NSD_InitCommonControlsEx ICC +!pragma warning push +!pragma warning disable 7070 ; Invalid number +!if ${ICC} <> 0 +!define /ReDef /IntFmt NSD_InitCommonControlsEx_TEMP "0x%X" ${ICC} +System::Call 'COMCTL32::InitCommonControlsEx(*l${NSD_InitCommonControlsEx_TEMP}00000008)' +!undef NSD_InitCommonControlsEx_TEMP +!else System::Int64Op ${ICC} << 32 -System::Int64Op 0x08 | +System::Int64Op 8 | System::Call 'COMCTL32::InitCommonControlsEx(*ls)' ; INITCOMMONCONTROLSEX as UINT64 +!endif +!pragma warning pop !macroend diff --git a/Docs/src/defines.but b/Docs/src/defines.but index db48443e..ad380429 100644 --- a/Docs/src/defines.but +++ b/Docs/src/defines.but @@ -10,15 +10,17 @@ Define/conditional compilation related commands: \S1{define} !define -\c [/ifndef | /redef] ([/date|/utcdate] gflag [value]) | (/math gflag val1 OP val2) | (/file gflag filename.txt) +\c [/ifndef | /redef] ([/date|/utcdate] gflag [value]) | (/file gflag filename.txt) | (/intfmt gflag fmtstr value) | (/math gflag val1 OP val2) This command will add \e{gflag} to the global define list. This will have a similar effect as using the /D switch on the command line (the define only becomes effective after the !define command). If \e{/date} or \e{/utcdate} are used, \e{value} will be passed to 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{/file} is used, the entire text file specified (including whitespace and newlines) will be read and placed into \e{gflag}. -If \e{/file} is used, the entire text file specified (including whitespace and newlines) will be read and stuffed into \e{gflag}. +If \e{/intfmt} is used, \e{value} is interpreted as a integer and formated using the same syntax as \R{intfmt}{IntFmt}. + +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! \c !define USE_SOMETHING \c !define VERSION 1.2 @@ -27,6 +29,7 @@ If \e{/file} is used, the entire text file specified (including whitespace and n \c !define /math REST 15 % ${RESULT} \c !define /file BunchaStuff somesourcefile.cpp \c !define /redef USE_SOMETHING ${RESULT} ;redefine USE_SOMETHING +\c !define /intfmt HEX "0x%X" 3133078222 \S1{undef} !undef diff --git a/Docs/src/history.but b/Docs/src/history.but index fec33ade..fe3c4f55 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -22,6 +22,8 @@ Released on ? ?th, 2020 \# Undocumented: \b Added GetShellVarContext, IfAltRegView and GetRegView | Documenting these would require documenting the parameter name to number mapping +\b Added \cw{!define /intfmt} + \b MultiUser: Fixed INSTALLMODE_FUNCTION and added INSTALLMODEPAGE_SHOWUSERNAME \S2{} Translations diff --git a/Source/Tests/preprocessor.nsi b/Source/Tests/preprocessor.nsi index 28989049..01abe8f4 100644 --- a/Source/Tests/preprocessor.nsi +++ b/Source/Tests/preprocessor.nsi @@ -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 diff --git a/Source/scriptpp.cpp b/Source/scriptpp.cpp index 73ffd0ff..8a1d9055 100644 --- a/Source/scriptpp.cpp +++ b/Source/scriptpp.cpp @@ -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) diff --git a/Source/tokens.cpp b/Source/tokens.cpp index a54676d8..722f95c1 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -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},