diff --git a/Include/LogicLib.nsh b/Include/LogicLib.nsh index 2bf3b321..55666760 100644 --- a/Include/LogicLib.nsh +++ b/Include/LogicLib.nsh @@ -78,6 +78,7 @@ !define LOGICLIB !define | "'" !define || "' '" + !define LOGICLIB_COUNTER 0 !include Sections.nsh @@ -88,8 +89,16 @@ !endif !macroend + !macro _IncreaseCounter + !define _LOGICLIB_COUNTER ${LOGICLIB_COUNTER} + !undef LOGICLIB_COUNTER + !define /math LOGICLIB_COUNTER ${_LOGICLIB_COUNTER} + 1 + !undef _LOGICLIB_COUNTER + !macroend + !macro _PushLogic - !insertmacro _PushScope Logic _LogicLib_Label_${__LINE__} + !insertmacro _PushScope Logic _LogicLib_Label_${LOGICLIB_COUNTER} + !insertmacro _IncreaseCounter !macroend !macro _PopLogic @@ -269,7 +278,8 @@ !macro _Cmd _a _b _t _f !define _t=${_t} !ifdef _t= ; If no true label then make one - !define __t _LogicLib_Label_${__LINE__} + !define __t _LogicLib_Label_${LOGICLIB_COUNTER} + !insertmacro _IncreaseCounter !else !define __t ${_t} !endif @@ -311,7 +321,8 @@ !verbose ${LOGICLIB_VERBOSITY} !insertmacro _PushLogic !define ${_Logic}If - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the Else + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the Else + !insertmacro _IncreaseCounter !define _c=${_c} !ifdef _c=true ; If is true !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} @@ -354,11 +365,13 @@ !ifndef ${_Logic}Else !error "Cannot use Or following an Else" !endif - !define _label _LogicLib_Label_${__LINE__} ; Skip this test as we already + !define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Skip this test as we already + !insertmacro _IncreaseCounter Goto ${_label} ; have a successful result ${${_Logic}Else}: ; Place the Else label !undef ${_Logic}Else ; and remove it - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new If + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If + !insertmacro _IncreaseCounter !define _c=${_c} !ifdef _c=true ; If is true !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} @@ -383,7 +396,8 @@ !error "Cannot use Else following an Else" !endif !ifndef ${_Logic}EndIf ; First Else for this If? - !define ${_Logic}EndIf _LogicLib_Label_${__LINE__} ; Get a label for the EndIf + !define ${_Logic}EndIf _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the EndIf + !insertmacro _IncreaseCounter !endif Goto ${${_Logic}EndIf} ; Go to the EndIf ${${_Logic}Else}: ; Place the Else label @@ -396,7 +410,8 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} ${Else} ; Perform the Else - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new If + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If + !insertmacro _IncreaseCounter !define _c=${_c} !ifdef _c=true ; If is true !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} @@ -483,9 +498,11 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} !insertmacro _PushLogic - !define ${_Logic}${_n} _LogicLib_Label_${__LINE__} ; Get a label for the start of the loop + !define ${_Logic}${_n} _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the start of the loop + !insertmacro _IncreaseCounter ${${_Logic}${_n}}: - !insertmacro _PushScope Exit${_n} _LogicLib_Label_${__LINE__} ; Get a label for the end of the loop + !insertmacro _PushScope Exit${_n} _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the end of the loop + !insertmacro _IncreaseCounter !insertmacro _PushScope Break ${_Exit${_n}} ; Break goes to the end of the loop !ifdef _DoLoopExpression ${_DoLoopExpression} ; Special extra parameter for inserting code @@ -493,7 +510,8 @@ !endif !define _c=${_c} !ifdef _c= ; No starting condition - !insertmacro _PushScope Continue _LogicLib_Label_${__LINE__} ; Get a label for Continue at the end of the loop + !insertmacro _PushScope Continue _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for Continue at the end of the loop + !insertmacro _IncreaseCounter !else !insertmacro _PushScope Continue ${${_Logic}${_n}} ; Continue goes to the start of the loop !ifdef _c=true ; If is true @@ -581,7 +599,8 @@ ${${_Logic}Else}: ; Place the Else label !undef ${_Logic}Else ; and remove it !else - !define ${_Logic}EndSelect _LogicLib_Label_${__LINE__} ; Get a label for the EndSelect + !define ${_Logic}EndSelect _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the EndSelect + !insertmacro _IncreaseCounter !endif !verbose pop !macroend @@ -593,7 +612,8 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} ${CaseElse} ; Perform the CaseElse - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new Case + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case + !insertmacro _IncreaseCounter !insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else} !verbose pop !macroend @@ -603,7 +623,8 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} ${CaseElse} ; Perform the CaseElse - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new Case + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case + !insertmacro _IncreaseCounter !insertmacro _== `${${_Logic}Select}` `${_a}` +2 "" !insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else} !verbose pop @@ -614,7 +635,8 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} ${CaseElse} ; Perform the CaseElse - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new Case + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case + !insertmacro _IncreaseCounter !insertmacro _== `${${_Logic}Select}` `${_a}` +3 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +2 "" !insertmacro _== `${${_Logic}Select}` `${_c}` "" ${${_Logic}Else} @@ -626,7 +648,8 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} ${CaseElse} ; Perform the CaseElse - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new Case + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case + !insertmacro _IncreaseCounter !insertmacro _== `${${_Logic}Select}` `${_a}` +4 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +3 "" !insertmacro _== `${${_Logic}Select}` `${_c}` +2 "" @@ -639,7 +662,8 @@ !verbose push !verbose ${LOGICLIB_VERBOSITY} ${CaseElse} ; Perform the CaseElse - !define ${_Logic}Else _LogicLib_Label_${__LINE__} ; Get a label for the next Else and perform the new Case + !define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case + !insertmacro _IncreaseCounter !insertmacro _== `${${_Logic}Select}` `${_a}` +5 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +4 "" !insertmacro _== `${${_Logic}Select}` `${_c}` +3 "" @@ -674,10 +698,12 @@ !verbose ${LOGICLIB_VERBOSITY} !insertmacro _PushLogic !insertmacro _PushScope Switch ${_Logic} ; Keep a separate stack for switch data - !insertmacro _PushScope Break _LogicLib_Label_${__LINE__} ; Get a lable for beyond the end of the switch + !insertmacro _PushScope Break _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a lable for beyond the end of the switch + !insertmacro _IncreaseCounter !define ${_Switch}Var `${_a}` ; Remember the left hand side of the comparison !tempfile ${_Switch}Tmp ; Create a temporary file - !define ${_Logic}Switch _LogicLib_Label_${__LINE__} ; Get a label for the end of the switch + !define ${_Logic}Switch _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the end of the switch + !insertmacro _IncreaseCounter Goto ${${_Logic}Switch} ; and go there !verbose pop !macroend @@ -691,7 +717,8 @@ !else ifndef _Switch ; If not then check for an active Switch !error "Cannot use Case without a preceding Select or Switch" !else - !define _label _LogicLib_Label_${__LINE__} ; Get a label for this case, + !define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for this case, + !insertmacro _IncreaseCounter ${_label}: ; place it and add it's check to the temp file !appendfile "${${_Switch}Tmp}" `!insertmacro _== $\`${${_Switch}Var}$\` $\`${_a}$\` ${_label} ""$\n` !undef _label @@ -709,7 +736,8 @@ !else ifdef ${_Switch}Else ; Already had a default case? !error "Cannot use CaseElse following a CaseElse" !else - !define ${_Switch}Else _LogicLib_Label_${__LINE__} ; Get a label for the default case, + !define ${_Switch}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the default case, + !insertmacro _IncreaseCounter ${${_Switch}Else}: ; and place it !endif !verbose pop