LogicLib: Don't add a EndSelect label when only one Case is used to avoid a unused label warning (bug #1126)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6650 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2015-12-01 21:02:56 +00:00
parent e65ac172c1
commit efc4cfccea

View file

@ -98,10 +98,7 @@
!macroend !macroend
!macro _IncreaseCounter !macro _IncreaseCounter
!define _LOGICLIB_COUNTER ${LOGICLIB_COUNTER} !define /redef /math LOGICLIB_COUNTER `${LOGICLIB_COUNTER}` + 1
!undef LOGICLIB_COUNTER
!define /math LOGICLIB_COUNTER ${_LOGICLIB_COUNTER} + 1
!undef _LOGICLIB_COUNTER
!macroend !macroend
!macro _PushLogic !macro _PushLogic
@ -356,7 +353,7 @@
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
!insertmacro _PushLogic !insertmacro _PushLogic
!define ${_Logic}If !define ${_Logic}If
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the Else !define ${_Logic}Else _LogicLib_ElseLabel_${LOGICLIB_COUNTER} ; Get a label for the Else
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!define _c=${_c} !define _c=${_c}
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
@ -402,12 +399,12 @@
!ifndef ${_Logic}Else !ifndef ${_Logic}Else
!error "Cannot use Or following an Else" !error "Cannot use Or following an Else"
!endif !endif
!define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Skip this test as we already !define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Skip this test as we already
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
Goto ${_label} ; have a successful result Goto ${_label} ; have a successful result
${${_Logic}Else}: ; Place the Else label ${${_Logic}Else}: ; Place the Else label
!undef ${_Logic}Else ; and remove it !undef ${_Logic}Else ; and remove it
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If !define ${_Logic}Else _LogicLib_ElseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!define _c=${_c} !define _c=${_c}
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
@ -434,7 +431,7 @@
!error "Cannot use Else following an Else" !error "Cannot use Else following an Else"
!endif !endif
!ifndef ${_Logic}EndIf ; First Else for this If? !ifndef ${_Logic}EndIf ; First Else for this If?
!define ${_Logic}EndIf _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the EndIf !define ${_Logic}EndIf _LogicLib_EndIfLabel_${LOGICLIB_COUNTER} ; Get a label for the EndIf
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!endif !endif
Goto ${${_Logic}EndIf} ; Go to the EndIf Goto ${${_Logic}EndIf} ; Go to the EndIf
@ -448,7 +445,7 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${Else} ; Perform the Else ${Else} ; Perform the Else
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If !define ${_Logic}Else _LogicLib_ElseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!define _c=${_c} !define _c=${_c}
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
@ -547,10 +544,10 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
!insertmacro _PushLogic !insertmacro _PushLogic
!define ${_Logic}${_n} _LogicLib_Label_${LOGICLIB_COUNTER} ; 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 !insertmacro _IncreaseCounter
${${_Logic}${_n}}: ${${_Logic}${_n}}:
!insertmacro _PushScope Exit${_n} _LogicLib_Label_${LOGICLIB_COUNTER} ; 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 _IncreaseCounter
!insertmacro _PushScope Break ${_Exit${_n}} ; Break goes to the end of the loop !insertmacro _PushScope Break ${_Exit${_n}} ; Break goes to the end of the loop
!ifdef _DoLoopExpression !ifdef _DoLoopExpression
@ -559,7 +556,7 @@
!endif !endif
!define _c=${_c} !define _c=${_c}
!ifdef _c= ; No starting condition !ifdef _c= ; No starting condition
!insertmacro _PushScope Continue _LogicLib_Label_${LOGICLIB_COUNTER} ; 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 !insertmacro _IncreaseCounter
!else !else
!insertmacro _PushScope Continue ${${_Logic}${_n}} ; Continue goes to the start of the loop !insertmacro _PushScope Continue ${${_Logic}${_n}} ; Continue goes to the start of the loop
@ -609,7 +606,7 @@
!endif !endif
!undef _c=${_c} !undef _c=${_c}
Goto ${_Continue} ; Just to ensure it is referenced at least once Goto ${_Continue} ; Just to ensure it is referenced at least once
Goto ${_Exit${_n}} ; Just to ensure it is referenced at least once Goto ${_Exit${_n}} ; Just to ensure it is referenced at least once
${_Exit${_n}}: ; Place the loop exit point ${_Exit${_n}}: ; Place the loop exit point
!undef ${_Logic}Condition !undef ${_Logic}Condition
!insertmacro _PopScope Continue !insertmacro _PopScope Continue
@ -645,11 +642,12 @@
!ifndef ${_Logic}Else !ifndef ${_Logic}Else
!error "Cannot use Case following a CaseElse" !error "Cannot use Case following a CaseElse"
!endif !endif
Goto ${${_Logic}EndSelect} ; Go to the EndSelect Goto ${${_Logic}EndSelect} ; Go to EndSelect (Ends the previous Case)
!define _LogicLib_EndSelectLabelUsed
${${_Logic}Else}: ; Place the Else label ${${_Logic}Else}: ; Place the Else label
!undef ${_Logic}Else ; and remove it !undef ${_Logic}Else ; and remove it
!else !else
!define ${_Logic}EndSelect _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the EndSelect !define ${_Logic}EndSelect _LogicLib_EndSelectLabel_${LOGICLIB_COUNTER} ; Get a label for the EndSelect
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!endif !endif
!verbose pop !verbose pop
@ -662,7 +660,7 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${CaseElse} ; Perform the CaseElse
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case !define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else} !insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else}
!verbose pop !verbose pop
@ -673,7 +671,7 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${CaseElse} ; Perform the CaseElse
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case !define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!insertmacro _== `${${_Logic}Select}` `${_a}` +2 "" !insertmacro _== `${${_Logic}Select}` `${_a}` +2 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else} !insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else}
@ -685,7 +683,7 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${CaseElse} ; Perform the CaseElse
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case !define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!insertmacro _== `${${_Logic}Select}` `${_a}` +3 "" !insertmacro _== `${${_Logic}Select}` `${_a}` +3 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` +2 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +2 ""
@ -698,7 +696,7 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${CaseElse} ; Perform the CaseElse
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case !define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!insertmacro _== `${${_Logic}Select}` `${_a}` +4 "" !insertmacro _== `${${_Logic}Select}` `${_a}` +4 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` +3 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +3 ""
@ -712,7 +710,7 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${CaseElse} ; Perform the CaseElse
!define ${_Logic}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case !define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
!insertmacro _== `${${_Logic}Select}` `${_a}` +5 "" !insertmacro _== `${${_Logic}Select}` `${_a}` +5 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` +4 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +4 ""
@ -734,7 +732,10 @@
!undef ${_Logic}Else ; and remove it !undef ${_Logic}Else ; and remove it
!endif !endif
!ifdef ${_Logic}EndSelect ; This won't be set if there weren't any cases !ifdef ${_Logic}EndSelect ; This won't be set if there weren't any cases
${${_Logic}EndSelect}: ; Place the EndSelect !ifdef _LogicLib_EndSelectLabelUsed ; There is no jump to ${${_Logic}EndSelect}: if there is only one Case
${${_Logic}EndSelect}: ; Place the EndSelect
!undef _LogicLib_EndSelectLabelUsed
!endif
!undef ${_Logic}EndSelect ; and remove it !undef ${_Logic}EndSelect ; and remove it
!endif !endif
!undef ${_Logic}Select !undef ${_Logic}Select
@ -748,11 +749,11 @@
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
!insertmacro _PushLogic !insertmacro _PushLogic
!insertmacro _PushScope Switch ${_Logic} ; Keep a separate stack for switch data !insertmacro _PushScope Switch ${_Logic} ; Keep a separate stack for switch data
!insertmacro _PushScope Break _LogicLib_Label_${LOGICLIB_COUNTER} ; 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 !insertmacro _IncreaseCounter
!define ${_Switch}Var `${_a}` ; Remember the left hand side of the comparison !define ${_Switch}Var `${_a}` ; Remember the left hand side of the comparison
!tempfile ${_Switch}Tmp ; Create a temporary file !tempfile ${_Switch}Tmp ; Create a temporary file
!define ${_Logic}Switch _LogicLib_Label_${LOGICLIB_COUNTER} ; 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 !insertmacro _IncreaseCounter
Goto ${${_Logic}Switch} ; and go there Goto ${${_Logic}Switch} ; and go there
!verbose pop !verbose pop
@ -767,7 +768,7 @@
!else ifndef _Switch ; If not then check for an active Switch !else ifndef _Switch ; If not then check for an active Switch
!error "Cannot use Case without a preceding Select or Switch" !error "Cannot use Case without a preceding Select or Switch"
!else !else
!define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for this case, !define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for this case,
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
${_label}: ; place it and add it's check to the temp file ${_label}: ; place it and add it's check to the temp file
!appendfile "${${_Switch}Tmp}" `!insertmacro _== $\`${${_Switch}Var}$\` $\`${_a}$\` ${_label} ""$\n` !appendfile "${${_Switch}Tmp}" `!insertmacro _== $\`${${_Switch}Var}$\` $\`${_a}$\` ${_label} ""$\n`
@ -786,7 +787,7 @@
!else ifdef ${_Switch}Else ; Already had a default case? !else ifdef ${_Switch}Else ; Already had a default case?
!error "Cannot use CaseElse following a CaseElse" !error "Cannot use CaseElse following a CaseElse"
!else !else
!define ${_Switch}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the default case, !define ${_Switch}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the default case,
!insertmacro _IncreaseCounter !insertmacro _IncreaseCounter
${${_Switch}Else}: ; and place it ${${_Switch}Else}: ; and place it
!endif !endif