using __LINE__ for special labels can result in duplicate labels across files (two includes in the same function)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5130 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2007-04-27 15:15:12 +00:00
parent 416146d6e6
commit 1ba91cb11f

View file

@ -78,6 +78,7 @@
!define LOGICLIB !define LOGICLIB
!define | "'" !define | "'"
!define || "' '" !define || "' '"
!define LOGICLIB_COUNTER 0
!include Sections.nsh !include Sections.nsh
@ -88,8 +89,16 @@
!endif !endif
!macroend !macroend
!macro _IncreaseCounter
!define _LOGICLIB_COUNTER ${LOGICLIB_COUNTER}
!undef LOGICLIB_COUNTER
!define /math LOGICLIB_COUNTER ${_LOGICLIB_COUNTER} + 1
!undef _LOGICLIB_COUNTER
!macroend
!macro _PushLogic !macro _PushLogic
!insertmacro _PushScope Logic _LogicLib_Label_${__LINE__} !insertmacro _PushScope Logic _LogicLib_Label_${LOGICLIB_COUNTER}
!insertmacro _IncreaseCounter
!macroend !macroend
!macro _PopLogic !macro _PopLogic
@ -269,7 +278,8 @@
!macro _Cmd _a _b _t _f !macro _Cmd _a _b _t _f
!define _t=${_t} !define _t=${_t}
!ifdef _t= ; If no true label then make one !ifdef _t= ; If no true label then make one
!define __t _LogicLib_Label_${__LINE__} !define __t _LogicLib_Label_${LOGICLIB_COUNTER}
!insertmacro _IncreaseCounter
!else !else
!define __t ${_t} !define __t ${_t}
!endif !endif
@ -311,7 +321,8 @@
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
!insertmacro _PushLogic !insertmacro _PushLogic
!define ${_Logic}If !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} !define _c=${_c}
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
@ -354,11 +365,13 @@
!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_${__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 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_${__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} !define _c=${_c}
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
@ -383,7 +396,8 @@
!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_${__LINE__} ; Get a label for the EndIf !define ${_Logic}EndIf _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the EndIf
!insertmacro _IncreaseCounter
!endif !endif
Goto ${${_Logic}EndIf} ; Go to the EndIf Goto ${${_Logic}EndIf} ; Go to the EndIf
${${_Logic}Else}: ; Place the Else label ${${_Logic}Else}: ; Place the Else label
@ -396,7 +410,8 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${Else} ; Perform the Else ${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} !define _c=${_c}
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} !insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else}
@ -483,9 +498,11 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
!insertmacro _PushLogic !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}}: ${${_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 !insertmacro _PushScope Break ${_Exit${_n}} ; Break goes to the end of the loop
!ifdef _DoLoopExpression !ifdef _DoLoopExpression
${_DoLoopExpression} ; Special extra parameter for inserting code ${_DoLoopExpression} ; Special extra parameter for inserting code
@ -493,7 +510,8 @@
!endif !endif
!define _c=${_c} !define _c=${_c}
!ifdef _c= ; No starting condition !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 !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
!ifdef _c=true ; If is true !ifdef _c=true ; If is true
@ -581,7 +599,8 @@
${${_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_${__LINE__} ; Get a label for the EndSelect !define ${_Logic}EndSelect _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the EndSelect
!insertmacro _IncreaseCounter
!endif !endif
!verbose pop !verbose pop
!macroend !macroend
@ -593,7 +612,8 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${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} !insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else}
!verbose pop !verbose pop
!macroend !macroend
@ -603,7 +623,8 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${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}` `${_a}` +2 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else} !insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else}
!verbose pop !verbose pop
@ -614,7 +635,8 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${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}` `${_a}` +3 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` +2 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +2 ""
!insertmacro _== `${${_Logic}Select}` `${_c}` "" ${${_Logic}Else} !insertmacro _== `${${_Logic}Select}` `${_c}` "" ${${_Logic}Else}
@ -626,7 +648,8 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${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}` `${_a}` +4 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` +3 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +3 ""
!insertmacro _== `${${_Logic}Select}` `${_c}` +2 "" !insertmacro _== `${${_Logic}Select}` `${_c}` +2 ""
@ -639,7 +662,8 @@
!verbose push !verbose push
!verbose ${LOGICLIB_VERBOSITY} !verbose ${LOGICLIB_VERBOSITY}
${CaseElse} ; Perform the CaseElse ${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}` `${_a}` +5 ""
!insertmacro _== `${${_Logic}Select}` `${_b}` +4 "" !insertmacro _== `${${_Logic}Select}` `${_b}` +4 ""
!insertmacro _== `${${_Logic}Select}` `${_c}` +3 "" !insertmacro _== `${${_Logic}Select}` `${_c}` +3 ""
@ -674,10 +698,12 @@
!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_${__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 !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_${__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 Goto ${${_Logic}Switch} ; and go there
!verbose pop !verbose pop
!macroend !macroend
@ -691,7 +717,8 @@
!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_${__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 ${_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`
!undef _label !undef _label
@ -709,7 +736,8 @@
!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_${__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 ${${_Switch}Else}: ; and place it
!endif !endif
!verbose pop !verbose pop