From 695fddbc32f9a6665280c0bae91c365e81610ca4 Mon Sep 17 00:00:00 2001 From: kichik Date: Tue, 27 Feb 2007 21:04:12 +0000 Subject: [PATCH] implemented RFE #1669513 - bitwise operators for !define /math git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4959 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/defines.but | 2 +- Source/script.cpp | 6 ++++++ Source/tokens.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Docs/src/defines.but b/Docs/src/defines.but index 2351d0e0..8d8ed4e4 100644 --- a/Docs/src/defines.but +++ b/Docs/src/defines.but @@ -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! \c !define USE_SOMETHING \c !define VERSION 1.2 diff --git a/Source/script.cpp b/Source/script.cpp index 6728d148..0cbbb9cc 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -2795,6 +2795,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) sprintf(value,"%d",value1-value2); } else if (!strcmp(mathop,"*")) { sprintf(value,"%d",value1*value2); + } else if (!strcmp(mathop,"&")) { + sprintf(value,"%d",value1&value2); + } else if (!strcmp(mathop,"|")) { + sprintf(value,"%d",value1|value2); + } else if (!strcmp(mathop,"^")) { + sprintf(value,"%d",value1^value2); } else if (!strcmp(mathop,"/")) { if (value2==0) { ERROR_MSG("!define /math: division by zero! (\"%i / %i\")\n",value1,value2); diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 09951c08..398497bf 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -237,7 +237,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_P_IFDEF,"!ifdef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL}, {TOK_P_IFNDEF,"!ifndef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL}, {TOK_P_ENDIF,"!endif",0,0,"",TP_ALL}, -{TOK_P_DEFINE,"!define",1,4,"([/date|/utcdate] symbol [value]) | (/math symbol val1 OP val2)\n OP=(+ - * / %)",TP_ALL}, +{TOK_P_DEFINE,"!define",1,4,"([/date|/utcdate] symbol [value]) | (/math symbol val1 OP val2)\n OP=(+ - * / % & | ^)",TP_ALL}, {TOK_P_UNDEF,"!undef",1,1,"symbol [value]",TP_ALL}, {TOK_P_ELSE,"!else",0,-1,"[if[macro][n][def] ...]",TP_ALL}, {TOK_P_ECHO,"!echo",1,0,"message",TP_ALL},