| 1 |
; NSIS LOGIC LIBRARY - LogicLib.nsh |
| 2 |
; Version 2.6 - 08/12/2007 |
| 3 |
; By [email protected] |
| 4 |
; and [email protected] |
| 5 |
; with IfNot support added by Message |
| 6 |
; |
| 7 |
; Questions/Comments - |
| 8 |
; See http://forums.winamp.com/showthread.php?s=&postid=1116241 |
| 9 |
; |
| 10 |
; Description: |
| 11 |
; Provides the use of various logic statements within NSIS. |
| 12 |
; |
| 13 |
; Usage: |
| 14 |
; The following "statements" are available: |
| 15 |
; If|IfNot|Unless..{ElseIf|ElseIfNot|ElseUnless}..[Else]..EndIf|EndUnless |
| 16 |
; - Conditionally executes a block of statements, depending on the value |
| 17 |
; of an expression. IfNot and Unless are equivalent and |
| 18 |
; interchangeable, as are ElseIfNot and ElseUnless. |
| 19 |
; AndIf|AndIfNot|AndUnless|OrIf|OrIfNot|OrUnless |
| 20 |
; - Adds any number of extra conditions to If, IfNot, Unless, ElseIf, |
| 21 |
; ElseIfNot and ElseUnless statements. |
| 22 |
; IfThen|IfNotThen..|..| |
| 23 |
; - Conditionally executes an inline statement, depending on the value |
| 24 |
; of an expression. |
| 25 |
; IfCmd..||..| |
| 26 |
; - Conditionally executes an inline statement, depending on a true |
| 27 |
; value of the provided NSIS function. |
| 28 |
; Select..{Case[2|3|4|5]}..[CaseElse|Default]..EndSelect |
| 29 |
; - Executes one of several blocks of statements, depending on the value |
| 30 |
; of an expression. |
| 31 |
; Switch..{Case|CaseElse|Default}..EndSwitch |
| 32 |
; - Jumps to one of several labels, depending on the value of an |
| 33 |
; expression. |
| 34 |
; Do[While|Until]..{ExitDo|Continue|Break}..Loop[While|Until] |
| 35 |
; - Repeats a block of statements until stopped, or depending on the |
| 36 |
; value of an expression. |
| 37 |
; While..{ExitWhile|Continue|Break}..EndWhile |
| 38 |
; - An alias for DoWhile..Loop (for backwards-compatibility) |
| 39 |
; For[Each]..{ExitFor|Continue|Break}..Next |
| 40 |
; - Repeats a block of statements varying the value of a variable. |
| 41 |
; |
| 42 |
; The following "expressions" are available: |
| 43 |
; Standard (built-in) string tests (which are case-insensitive): |
| 44 |
; a == b; a != b |
| 45 |
; Additional case-insensitive string tests (using System.dll): |
| 46 |
; a S< b; a S>= b; a S> b; a S<= b |
| 47 |
; Case-sensitive string tests: |
| 48 |
; a S== b; a S!= b |
| 49 |
; Standard (built-in) signed integer tests: |
| 50 |
; a = b; a <> b; a < b; a >= b; a > b; a <= b; a & b |
| 51 |
; Standard (built-in) unsigned integer tests: |
| 52 |
; a U< b; a U>= b; a U> b; a U<= b |
| 53 |
; 64-bit integer tests (using System.dll): |
| 54 |
; a L= b; a L<> b; a L< b; a L>= b; a L> b; a L<= b |
| 55 |
; ptrdiff_t integer tests |
| 56 |
; a P= b; a P<> b; a P< b; a P>= b; a P> b; a P<= b |
| 57 |
; size_t integer tests |
| 58 |
; a Z= b; a Z<> b; a Z< b; a Z>= b; a Z> b; a Z<= b |
| 59 |
; Built-in NSIS flag tests: |
| 60 |
; ${Abort}; ${Errors}; ${RebootFlag}; ${Silent}; ${RtlLanguage}; |
| 61 |
; ${ShellVarContextAll} |
| 62 |
; Built-in NSIS other tests: |
| 63 |
; ${FileExists} a |
| 64 |
; Complex string tests: |
| 65 |
; a ${StartsWith} b; a ${StartsWithS} b; a ${EndsWith} b; a ${EndsWithS} b; |
| 66 |
; a ${Contains} b; a ${ContainsS} b; ${IsLowerCase} b; ${IsUpperCase} b |
| 67 |
; Any conditional NSIS instruction test: |
| 68 |
; ${Cmd} a |
| 69 |
; Section flag tests: |
| 70 |
; ${SectionIsSelected} a; ${SectionIsSectionGroup} a; |
| 71 |
; ${SectionIsSectionGroupEnd} a; ${SectionIsBold} a; |
| 72 |
; ${SectionIsReadOnly} a; ${SectionIsExpanded} a; |
| 73 |
; ${SectionIsPartiallySelected} a |
| 74 |
; Additional tests: |
| 75 |
; HK ${RegKeyIsEmpty} SubKey |
| 76 |
; |
| 77 |
; Examples: |
| 78 |
; See LogicLib.nsi in the Examples folder for lots of example usage. |
| 79 |
|
| 80 |
!verbose push |
| 81 |
!verbose 3 |
| 82 |
!ifndef LOGICLIB_VERBOSITY |
| 83 |
!define LOGICLIB_VERBOSITY 3 |
| 84 |
!endif |
| 85 |
!define _LOGICLIB_VERBOSITY ${LOGICLIB_VERBOSITY} |
| 86 |
!undef LOGICLIB_VERBOSITY |
| 87 |
!verbose ${_LOGICLIB_VERBOSITY} |
| 88 |
|
| 89 |
!ifndef LOGICLIB |
| 90 |
!define LOGICLIB 20260419 |
| 91 |
!define | "'" |
| 92 |
!define || "' '" |
| 93 |
!define LOGICLIB_COUNTER 0 |
| 94 |
|
| 95 |
!include Sections.nsh |
| 96 |
|
| 97 |
!macro _LOGICLIB_TEMP |
| 98 |
!ifndef _LOGICLIB_TEMP |
| 99 |
!define _LOGICLIB_TEMP |
| 100 |
Var /GLOBAL _LOGICLIB_TEMP ; Temporary variable to aid the more elaborate logic tests |
| 101 |
!endif |
| 102 |
!macroend |
| 103 |
|
| 104 |
!macro LogicLib_JumpToBranch _Jump _Skip |
| 105 |
!if `${_Jump}${_Skip}` != `` |
| 106 |
StrCmp "" "" `${_Jump}` ${_Skip} |
| 107 |
!endif |
| 108 |
!macroend |
| 109 |
|
| 110 |
!macro _IncreaseCounter |
| 111 |
!define /redef /math LOGICLIB_COUNTER `${LOGICLIB_COUNTER}` + 1 |
| 112 |
!macroend |
| 113 |
|
| 114 |
!macro _PushLogic |
| 115 |
!insertmacro _PushScope Logic _LogicLib_Label_${LOGICLIB_COUNTER} |
| 116 |
!insertmacro _IncreaseCounter |
| 117 |
!macroend |
| 118 |
|
| 119 |
!macro _PopLogic |
| 120 |
!insertmacro _PopScope Logic |
| 121 |
!macroend |
| 122 |
|
| 123 |
!macro _PushScope Type label |
| 124 |
!ifdef _${Type} ; If we already have a statement |
| 125 |
!define _Cur${Type} ${_${Type}} |
| 126 |
!undef _${Type} |
| 127 |
!define _${Type} ${label} |
| 128 |
!define ${_${Type}}Prev${Type} ${_Cur${Type}} ; Save the current logic |
| 129 |
!undef _Cur${Type} |
| 130 |
!else |
| 131 |
!define _${Type} ${label} ; Initialise for first statement |
| 132 |
!endif |
| 133 |
!macroend |
| 134 |
|
| 135 |
!macro _PopScope Type |
| 136 |
!ifndef _${Type} |
| 137 |
!error "Cannot use _Pop${Type} without a preceding _Push${Type}" |
| 138 |
!endif |
| 139 |
!ifdef ${_${Type}}Prev${Type} ; If a previous statement was active then restore it |
| 140 |
!define _Cur${Type} ${_${Type}} |
| 141 |
!undef _${Type} |
| 142 |
!define _${Type} ${${_Cur${Type}}Prev${Type}} |
| 143 |
!undef ${_Cur${Type}}Prev${Type} |
| 144 |
!undef _Cur${Type} |
| 145 |
!else |
| 146 |
!undef _${Type} |
| 147 |
!endif |
| 148 |
!macroend |
| 149 |
|
| 150 |
!macro _LogicLib_AlwaysTrue _a _b _t _f |
| 151 |
!insertmacro LogicLib_JumpToBranch `${_t}` `${_f}` |
| 152 |
!macroend |
| 153 |
!macro _LogicLib_AlwaysFalse _a _b _t _f |
| 154 |
!insertmacro LogicLib_JumpToBranch `${_f}` `${_t}` |
| 155 |
!macroend |
| 156 |
|
| 157 |
; String tests |
| 158 |
!macro _== _a _b _t _f |
| 159 |
StrCmp `${_a}` `${_b}` `${_t}` `${_f}` |
| 160 |
!macroend |
| 161 |
|
| 162 |
!macro _!= _a _b _t _f |
| 163 |
!insertmacro _== `${_a}` `${_b}` `${_f}` `${_t}` |
| 164 |
!macroend |
| 165 |
|
| 166 |
; Case-sensitive string tests |
| 167 |
!macro _S== _a _b _t _f |
| 168 |
StrCmpS `${_a}` `${_b}` `${_t}` `${_f}` |
| 169 |
!macroend |
| 170 |
|
| 171 |
!macro _S!= _a _b _t _f |
| 172 |
!insertmacro _S== `${_a}` `${_b}` `${_f}` `${_t}` |
| 173 |
!macroend |
| 174 |
|
| 175 |
; Extra string tests (cannot do these case-sensitively - I tried and lstrcmp still ignored the case) |
| 176 |
!macro _StrCmpI _a _b _e _l _m |
| 177 |
!insertmacro _LOGICLIB_TEMP |
| 178 |
System::Call `kernel32::lstrcmpi(ts, ts) i.s` `${_a}` `${_b}` |
| 179 |
Pop $_LOGICLIB_TEMP |
| 180 |
IntCmp $_LOGICLIB_TEMP 0 `${_e}` `${_l}` `${_m}` |
| 181 |
!macroend |
| 182 |
|
| 183 |
!macro _S< _a _b _t _f |
| 184 |
!insertmacro _StrCmpI `${_a}` `${_b}` `${_f}` `${_t}` `${_f}` |
| 185 |
!macroend |
| 186 |
|
| 187 |
!macro _S>= _a _b _t _f |
| 188 |
!insertmacro _S< `${_a}` `${_b}` `${_f}` `${_t}` |
| 189 |
!macroend |
| 190 |
|
| 191 |
!macro _S> _a _b _t _f |
| 192 |
!insertmacro _StrCmpI `${_a}` `${_b}` `${_f}` `${_f}` `${_t}` |
| 193 |
!macroend |
| 194 |
|
| 195 |
!macro _S<= _a _b _t _f |
| 196 |
!insertmacro _S> `${_a}` `${_b}` `${_f}` `${_t}` |
| 197 |
!macroend |
| 198 |
|
| 199 |
; Integer tests |
| 200 |
!macro _= _a _b _t _f |
| 201 |
IntCmp `${_a}` `${_b}` `${_t}` `${_f}` `${_f}` |
| 202 |
!macroend |
| 203 |
|
| 204 |
!macro _<> _a _b _t _f |
| 205 |
!insertmacro _= `${_a}` `${_b}` `${_f}` `${_t}` |
| 206 |
!macroend |
| 207 |
|
| 208 |
!macro _< _a _b _t _f |
| 209 |
IntCmp `${_a}` `${_b}` `${_f}` `${_t}` `${_f}` |
| 210 |
!macroend |
| 211 |
|
| 212 |
!macro _>= _a _b _t _f |
| 213 |
!insertmacro _< `${_a}` `${_b}` `${_f}` `${_t}` |
| 214 |
!macroend |
| 215 |
|
| 216 |
!macro _> _a _b _t _f |
| 217 |
IntCmp `${_a}` `${_b}` `${_f}` `${_f}` `${_t}` |
| 218 |
!macroend |
| 219 |
|
| 220 |
!macro _<= _a _b _t _f |
| 221 |
!insertmacro _> `${_a}` `${_b}` `${_f}` `${_t}` |
| 222 |
!macroend |
| 223 |
|
| 224 |
!macro _& _a _b _t _f |
| 225 |
!insertmacro _LOGICLIB_TEMP |
| 226 |
IntOp $_LOGICLIB_TEMP `${_a}` & `${_b}` |
| 227 |
!insertmacro _<> $_LOGICLIB_TEMP 0 `${_t}` `${_f}` |
| 228 |
!macroend |
| 229 |
|
| 230 |
; Unsigned integer tests (NB: no need for extra equality tests) |
| 231 |
!macro _U< _a _b _t _f |
| 232 |
IntCmpU `${_a}` `${_b}` `${_f}` `${_t}` `${_f}` |
| 233 |
!macroend |
| 234 |
|
| 235 |
!macro _U>= _a _b _t _f |
| 236 |
!insertmacro _U< `${_a}` `${_b}` `${_f}` `${_t}` |
| 237 |
!macroend |
| 238 |
|
| 239 |
!macro _U> _a _b _t _f |
| 240 |
IntCmpU `${_a}` `${_b}` `${_f}` `${_f}` `${_t}` |
| 241 |
!macroend |
| 242 |
|
| 243 |
!macro _U<= _a _b _t _f |
| 244 |
!insertmacro _U> `${_a}` `${_b}` `${_f}` `${_t}` |
| 245 |
!macroend |
| 246 |
|
| 247 |
; Int64 tests |
| 248 |
!macro _Int64Cmp _a _o _b _t _f |
| 249 |
!insertmacro _LOGICLIB_TEMP |
| 250 |
System::Int64Op `${_a}` `${_o}` `${_b}` |
| 251 |
Pop $_LOGICLIB_TEMP |
| 252 |
!insertmacro _= $_LOGICLIB_TEMP 0 `${_f}` `${_t}` |
| 253 |
!macroend |
| 254 |
|
| 255 |
!macro _L= _a _b _t _f |
| 256 |
!insertmacro _Int64Cmp `${_a}` = `${_b}` `${_t}` `${_f}` |
| 257 |
!macroend |
| 258 |
|
| 259 |
!macro _L<> _a _b _t _f |
| 260 |
!insertmacro _L= `${_a}` `${_b}` `${_f}` `${_t}` |
| 261 |
!macroend |
| 262 |
|
| 263 |
!macro _L< _a _b _t _f |
| 264 |
!insertmacro _Int64Cmp `${_a}` < `${_b}` `${_t}` `${_f}` |
| 265 |
!macroend |
| 266 |
|
| 267 |
!macro _L>= _a _b _t _f |
| 268 |
!insertmacro _L< `${_a}` `${_b}` `${_f}` `${_t}` |
| 269 |
!macroend |
| 270 |
|
| 271 |
!macro _L> _a _b _t _f |
| 272 |
!insertmacro _Int64Cmp `${_a}` > `${_b}` `${_t}` `${_f}` |
| 273 |
!macroend |
| 274 |
|
| 275 |
!macro _L<= _a _b _t _f |
| 276 |
!insertmacro _L> `${_a}` `${_b}` `${_f}` `${_t}` |
| 277 |
!macroend |
| 278 |
|
| 279 |
; ptrdiff_t & size_t tests |
| 280 |
!macro LogicLib_PtrDiffTest _o _a _b _t _f |
| 281 |
!if "${NSIS_PTR_SIZE}" <= 4 |
| 282 |
!insertmacro _${_o} `${_a}` `${_b}` `${_t}` `${_f}` |
| 283 |
!else |
| 284 |
!insertmacro _L${_o} `${_a}` `${_b}` `${_t}` `${_f}` |
| 285 |
!endif |
| 286 |
!macroend |
| 287 |
!macro _P= _a _b _t _f |
| 288 |
!insertmacro LogicLib_PtrDiffTest = `${_a}` `${_b}` `${_t}` `${_f}` |
| 289 |
!macroend |
| 290 |
!macro _P<> _a _b _t _f |
| 291 |
!insertmacro LogicLib_PtrDiffTest <> `${_a}` `${_b}` `${_t}` `${_f}` |
| 292 |
!macroend |
| 293 |
!macro _P< _a _b _t _f |
| 294 |
!insertmacro LogicLib_PtrDiffTest < `${_a}` `${_b}` `${_t}` `${_f}` |
| 295 |
!macroend |
| 296 |
!macro _P>= _a _b _t _f |
| 297 |
!insertmacro LogicLib_PtrDiffTest >= `${_a}` `${_b}` `${_t}` `${_f}` |
| 298 |
!macroend |
| 299 |
!macro _P> _a _b _t _f |
| 300 |
!insertmacro LogicLib_PtrDiffTest > `${_a}` `${_b}` `${_t}` `${_f}` |
| 301 |
!macroend |
| 302 |
!macro _P<= _a _b _t _f |
| 303 |
!insertmacro LogicLib_PtrDiffTest <= `${_a}` `${_b}` `${_t}` `${_f}` |
| 304 |
!macroend |
| 305 |
!include Util.nsh |
| 306 |
!macro _Z= _a _b _t _f |
| 307 |
!insertmacro LogicLib_PtrDiffTest = `${_a}` `${_b}` `${_t}` `${_f}` |
| 308 |
!macroend |
| 309 |
!macro _Z<> _a _b _t _f |
| 310 |
!insertmacro LogicLib_PtrDiffTest <> `${_a}` `${_b}` `${_t}` `${_f}` |
| 311 |
!macroend |
| 312 |
!macro _Z< _a _b _t _f |
| 313 |
!insertmacro IntPtrCmpU `${_a}` `${_b}` `${_f}` `${_t}` `${_f}` |
| 314 |
!macroend |
| 315 |
!macro _Z>= _a _b _t _f |
| 316 |
!insertmacro IntPtrCmpU `${_a}` `${_b}` `${_t}` `${_f}` `${_t}` |
| 317 |
!macroend |
| 318 |
!macro _Z> _a _b _t _f |
| 319 |
!insertmacro IntPtrCmpU `${_a}` `${_b}` `${_f}` `${_f}` `${_t}` |
| 320 |
!macroend |
| 321 |
!macro _Z<= _a _b _t _f |
| 322 |
!insertmacro IntPtrCmpU `${_a}` `${_b}` `${_t}` `${_t}` `${_f}` |
| 323 |
!macroend |
| 324 |
|
| 325 |
; Flag tests |
| 326 |
!macro _Abort _a _b _t _f |
| 327 |
IfAbort `${_t}` `${_f}` |
| 328 |
!macroend |
| 329 |
!define Abort `"" Abort ""` |
| 330 |
|
| 331 |
!macro _Errors _a _b _t _f |
| 332 |
IfErrors `${_t}` `${_f}` |
| 333 |
!macroend |
| 334 |
!define Errors `"" Errors ""` |
| 335 |
|
| 336 |
!macro _FileExists _a _b _t _f |
| 337 |
IfFileExists `${_b}` `${_t}` `${_f}` |
| 338 |
!macroend |
| 339 |
!define FileExists `"" FileExists` |
| 340 |
|
| 341 |
!macro _RebootFlag _a _b _t _f |
| 342 |
IfRebootFlag `${_t}` `${_f}` |
| 343 |
!macroend |
| 344 |
!define RebootFlag `"" RebootFlag ""` |
| 345 |
|
| 346 |
!macro _Silent _a _b _t _f |
| 347 |
IfSilent `${_t}` `${_f}` |
| 348 |
!macroend |
| 349 |
!define Silent `"" Silent ""` |
| 350 |
|
| 351 |
!macro _ShellVarContextAll _a _b _t _f |
| 352 |
IfShellVarContextAll `${_t}` `${_f}` |
| 353 |
!macroend |
| 354 |
!define ShellVarContextAll `"" ShellVarContextAll ""` |
| 355 |
|
| 356 |
!macro _RtlLanguage _a _b _t _f |
| 357 |
IfRtlLanguage `${_t}` `${_f}` |
| 358 |
!macroend |
| 359 |
!define RtlLanguage `"" RtlLanguage ""` |
| 360 |
|
| 361 |
!macro _AltRegView _a _b _t _f |
| 362 |
IfAltRegView `${_t}` `${_f}` |
| 363 |
!macroend |
| 364 |
!define AltRegView `"" AltRegView ""` |
| 365 |
|
| 366 |
; Complex string tests |
| 367 |
!macro _LL_StartsWith _op _a _b _t _f |
| 368 |
!insertmacro _LOGICLIB_TEMP |
| 369 |
StrLen $_LOGICLIB_TEMP `${_b}` |
| 370 |
StrCpy $_LOGICLIB_TEMP `${_a}` $_LOGICLIB_TEMP |
| 371 |
${_op} $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 372 |
!macroend |
| 373 |
!define StartsWith `"LL_StartsWith StrCmp"` |
| 374 |
!define StartsWithS `"LL_StartsWith StrCmpS"` |
| 375 |
|
| 376 |
!macro _LL_EndsWith _op _a _b _t _f |
| 377 |
!insertmacro _LOGICLIB_TEMP |
| 378 |
StrLen $_LOGICLIB_TEMP `${_b}` |
| 379 |
StrCpy $_LOGICLIB_TEMP `${_a}` "" -$_LOGICLIB_TEMP |
| 380 |
${_op} $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 381 |
!macroend |
| 382 |
!define EndsWith `"LL_EndsWith StrCmp"` |
| 383 |
!define EndsWithS `"LL_EndsWith StrCmpS"` |
| 384 |
|
| 385 |
!macro _LL_StrContains _op _a _b _t _f |
| 386 |
!insertmacro _LOGICLIB_TEMP |
| 387 |
Push $0 |
| 388 |
Push $1 |
| 389 |
Push $2 |
| 390 |
StrCpy $0 `${_b}` |
| 391 |
StrCpy $1 `${_a}` |
| 392 |
StrLen $_LOGICLIB_TEMP $0 |
| 393 |
_LL${LOGICLIB_COUNTER}_Loop: |
| 394 |
StrCpy $2 $1 $_LOGICLIB_TEMP |
| 395 |
StrCmp $2 "" _LL${LOGICLIB_COUNTER}_Done |
| 396 |
StrCpy $1 $1 "" 1 |
| 397 |
${_op} $2 $0 ""_LL${LOGICLIB_COUNTER}_Loop |
| 398 |
StrCpy $_LOGICLIB_TEMP "" |
| 399 |
_LL${LOGICLIB_COUNTER}_Done: |
| 400 |
Pop $2 |
| 401 |
Pop $1 |
| 402 |
Pop $0 |
| 403 |
StrCmp $_LOGICLIB_TEMP "" `${_t}` `${_f}` |
| 404 |
!insertmacro _IncreaseCounter |
| 405 |
!macroend |
| 406 |
!define Contains `"LL_StrContains StrCmp"` |
| 407 |
!define ContainsS `"LL_StrContains StrCmpS"` |
| 408 |
|
| 409 |
!macro _LL_IsCase _func _a _b _t _f |
| 410 |
!insertmacro _LOGICLIB_TEMP |
| 411 |
System::Call USER32::${_func}(tss) `${_b}` |
| 412 |
Pop $_LOGICLIB_TEMP |
| 413 |
StrCmpS $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 414 |
!macroend |
| 415 |
!define IsLowerCase `"" "LL_IsCase CharLower"` |
| 416 |
!define IsUpperCase `"" "LL_IsCase CharUpper"` |
| 417 |
|
| 418 |
; Registry tests |
| 419 |
!macro _RegKeyIsEmpty _a _b _t _f |
| 420 |
!insertmacro _LOGICLIB_TEMP |
| 421 |
ClearErrors |
| 422 |
EnumRegValue $_LOGICLIB_TEMP ${_a} `${_b}` "" |
| 423 |
!if `${_f}` != `` |
| 424 |
IfErrors "" `${_f}` ; Skip calls to EnumRegKey and _== if possible |
| 425 |
!else |
| 426 |
IfErrors +3 |
| 427 |
StrCpy $_LOGICLIB_TEMP "1" ; The default value is also named "", make sure we don't mistake it as empty |
| 428 |
Goto +2 |
| 429 |
!endif |
| 430 |
EnumRegKey $_LOGICLIB_TEMP ${_a} `${_b}` "" |
| 431 |
!insertmacro _== $_LOGICLIB_TEMP "" `${_t}` `${_f}` |
| 432 |
!macroend |
| 433 |
!define RegKeyIsEmpty `RegKeyIsEmpty` |
| 434 |
|
| 435 |
; "Any instruction" test |
| 436 |
!macro _Cmd _a _b _t _f |
| 437 |
!define _t=${_t} |
| 438 |
!ifdef _t= ; If no true label then make one |
| 439 |
!define __t _LogicLib_Label_${LOGICLIB_COUNTER} |
| 440 |
!insertmacro _IncreaseCounter |
| 441 |
!else |
| 442 |
!define __t ${_t} |
| 443 |
!endif |
| 444 |
${_b} ${__t} |
| 445 |
!define _f=${_f} |
| 446 |
!ifndef _f= ; If a false label then go there |
| 447 |
Goto ${_f} |
| 448 |
!endif |
| 449 |
!undef _f=${_f} |
| 450 |
!ifdef _t= ; If we made our own true label then place it |
| 451 |
${__t}: |
| 452 |
!endif |
| 453 |
!undef __t |
| 454 |
!undef _t=${_t} |
| 455 |
!macroend |
| 456 |
!define Cmd `"" Cmd` |
| 457 |
|
| 458 |
; Section flag test |
| 459 |
!macro _SectionFlagIsSet _a _b _t _f |
| 460 |
!insertmacro _LOGICLIB_TEMP |
| 461 |
SectionGetFlags `${_b}` $_LOGICLIB_TEMP |
| 462 |
IntOp $_LOGICLIB_TEMP $_LOGICLIB_TEMP & `${_a}` |
| 463 |
!insertmacro _= $_LOGICLIB_TEMP `${_a}` `${_t}` `${_f}` |
| 464 |
!macroend |
| 465 |
!define SectionIsSelected `${SF_SELECTED} SectionFlagIsSet` |
| 466 |
!define SectionIsSubSection `${SF_SUBSEC} SectionFlagIsSet` |
| 467 |
!define SectionIsSubSectionEnd `${SF_SUBSECEND} SectionFlagIsSet` |
| 468 |
!define SectionIsSectionGroup `${SF_SECGRP} SectionFlagIsSet` |
| 469 |
!define SectionIsSectionGroupEnd `${SF_SECGRPEND} SectionFlagIsSet` |
| 470 |
!define SectionIsBold `${SF_BOLD} SectionFlagIsSet` |
| 471 |
!define SectionIsReadOnly `${SF_RO} SectionFlagIsSet` |
| 472 |
!define SectionIsExpanded `${SF_EXPAND} SectionFlagIsSet` |
| 473 |
!define SectionIsPartiallySelected `${SF_PSELECTED} SectionFlagIsSet` |
| 474 |
|
| 475 |
!define IfCmd `!insertmacro _IfThen "" Cmd ${|}` |
| 476 |
|
| 477 |
!macro _If _c _a _o _b |
| 478 |
!verbose push |
| 479 |
!verbose ${LOGICLIB_VERBOSITY} |
| 480 |
!insertmacro _PushLogic |
| 481 |
!define ${_Logic}If |
| 482 |
!define ${_Logic}Else _LogicLib_ElseLabel_${LOGICLIB_COUNTER} ; Get a label for the Else |
| 483 |
!insertmacro _IncreaseCounter |
| 484 |
!define _c=${_c} |
| 485 |
!ifdef _c=true ; If is true |
| 486 |
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} |
| 487 |
!else ; If condition is false |
| 488 |
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} "" |
| 489 |
!endif |
| 490 |
!undef _c=${_c} |
| 491 |
!verbose pop |
| 492 |
!macroend |
| 493 |
!define If `!insertmacro _If true` |
| 494 |
!define Unless `!insertmacro _If false` |
| 495 |
!define IfNot `!insertmacro _If false` |
| 496 |
|
| 497 |
!macro _And _c _a _o _b |
| 498 |
!verbose push |
| 499 |
!verbose ${LOGICLIB_VERBOSITY} |
| 500 |
!ifndef _Logic | ${_Logic}If |
| 501 |
!error "Cannot use And without a preceding If or IfNot/Unless" |
| 502 |
!endif |
| 503 |
!ifndef ${_Logic}Else |
| 504 |
!error "Cannot use And following an Else" |
| 505 |
!endif |
| 506 |
!define _c=${_c} |
| 507 |
!ifdef _c=true ; If is true |
| 508 |
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} |
| 509 |
!else ; If condition is false |
| 510 |
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} "" |
| 511 |
!endif |
| 512 |
!undef _c=${_c} |
| 513 |
!verbose pop |
| 514 |
!macroend |
| 515 |
!define AndIf `!insertmacro _And true` |
| 516 |
!define AndUnless `!insertmacro _And false` |
| 517 |
!define AndIfNot `!insertmacro _And false` |
| 518 |
|
| 519 |
!macro _Or _c _a _o _b |
| 520 |
!verbose push |
| 521 |
!verbose ${LOGICLIB_VERBOSITY} |
| 522 |
!ifndef _Logic | ${_Logic}If |
| 523 |
!error "Cannot use Or without a preceding If or IfNot/Unless" |
| 524 |
!endif |
| 525 |
!ifndef ${_Logic}Else |
| 526 |
!error "Cannot use Or following an Else" |
| 527 |
!endif |
| 528 |
!define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Skip this test as we already |
| 529 |
!insertmacro _IncreaseCounter |
| 530 |
Goto ${_label} ; have a successful result |
| 531 |
${${_Logic}Else}: ; Place the Else label |
| 532 |
!undef ${_Logic}Else ; and remove it |
| 533 |
!define ${_Logic}Else _LogicLib_ElseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If |
| 534 |
!insertmacro _IncreaseCounter |
| 535 |
!define _c=${_c} |
| 536 |
!ifdef _c=true ; If is true |
| 537 |
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} |
| 538 |
!else ; If condition is false |
| 539 |
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} "" |
| 540 |
!endif |
| 541 |
!undef _c=${_c} |
| 542 |
${_label}: |
| 543 |
!undef _label |
| 544 |
!verbose pop |
| 545 |
!macroend |
| 546 |
!define OrIf `!insertmacro _Or true` |
| 547 |
!define OrUnless `!insertmacro _Or false` |
| 548 |
!define OrIfNot `!insertmacro _Or false` |
| 549 |
|
| 550 |
!macro _Else |
| 551 |
!verbose push |
| 552 |
!verbose ${LOGICLIB_VERBOSITY} |
| 553 |
!ifndef _Logic | ${_Logic}If |
| 554 |
!error "Cannot use Else without a preceding If or IfNot/Unless" |
| 555 |
!endif |
| 556 |
!ifndef ${_Logic}Else |
| 557 |
!error "Cannot use Else following an Else" |
| 558 |
!endif |
| 559 |
!ifndef ${_Logic}EndIf ; First Else for this If? |
| 560 |
!define ${_Logic}EndIf _LogicLib_EndIfLabel_${LOGICLIB_COUNTER} ; Get a label for the EndIf |
| 561 |
!insertmacro _IncreaseCounter |
| 562 |
!endif |
| 563 |
Goto ${${_Logic}EndIf} ; Go to the EndIf |
| 564 |
${${_Logic}Else}: ; Place the Else label |
| 565 |
!undef ${_Logic}Else ; and remove it |
| 566 |
!verbose pop |
| 567 |
!macroend |
| 568 |
!define Else `!insertmacro _Else` |
| 569 |
|
| 570 |
!macro _ElseIf _c _a _o _b |
| 571 |
!verbose push |
| 572 |
!verbose ${LOGICLIB_VERBOSITY} |
| 573 |
${Else} ; Perform the Else |
| 574 |
!define ${_Logic}Else _LogicLib_ElseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new If |
| 575 |
!insertmacro _IncreaseCounter |
| 576 |
!define _c=${_c} |
| 577 |
!ifdef _c=true ; If is true |
| 578 |
!insertmacro _${_o} `${_a}` `${_b}` "" ${${_Logic}Else} |
| 579 |
!else ; If condition is false |
| 580 |
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}Else} "" |
| 581 |
!endif |
| 582 |
!undef _c=${_c} |
| 583 |
!verbose pop |
| 584 |
!macroend |
| 585 |
!define ElseIf `!insertmacro _ElseIf true` |
| 586 |
!define ElseUnless `!insertmacro _ElseIf false` |
| 587 |
!define ElseIfNot `!insertmacro _ElseIf false` |
| 588 |
|
| 589 |
!macro _EndIf _n |
| 590 |
!verbose push |
| 591 |
!verbose ${LOGICLIB_VERBOSITY} |
| 592 |
!ifndef _Logic | ${_Logic}If |
| 593 |
!error "Cannot use End${_n} without a preceding If or IfNot/Unless" |
| 594 |
!endif |
| 595 |
!ifdef ${_Logic}Else |
| 596 |
${${_Logic}Else}: ; Place the Else label |
| 597 |
!undef ${_Logic}Else ; and remove it |
| 598 |
!endif |
| 599 |
!ifdef ${_Logic}EndIf |
| 600 |
${${_Logic}EndIf}: ; Place the EndIf |
| 601 |
!undef ${_Logic}EndIf ; and remove it |
| 602 |
!endif |
| 603 |
!undef ${_Logic}If |
| 604 |
!insertmacro _PopLogic |
| 605 |
!verbose pop |
| 606 |
!macroend |
| 607 |
!define EndIf `!insertmacro _EndIf If` |
| 608 |
!define EndUnless `!insertmacro _EndIf Unless` |
| 609 |
|
| 610 |
!macro _IfThen _a _o _b _t |
| 611 |
!verbose push |
| 612 |
!verbose ${LOGICLIB_VERBOSITY} |
| 613 |
${If} `${_a}` `${_o}` `${_b}` |
| 614 |
${_t} |
| 615 |
${EndIf} |
| 616 |
!verbose pop |
| 617 |
!macroend |
| 618 |
!define IfThen `!insertmacro _IfThen` |
| 619 |
|
| 620 |
!macro _IfNotThen _a _o _b _t |
| 621 |
!verbose push |
| 622 |
!verbose ${LOGICLIB_VERBOSITY} |
| 623 |
${IfNot} `${_a}` `${_o}` `${_b}` |
| 624 |
${_t} |
| 625 |
${EndIf} |
| 626 |
!verbose pop |
| 627 |
!macroend |
| 628 |
!define IfNotThen `!insertmacro _IfNotThen` |
| 629 |
|
| 630 |
!macro _ForEach _v _f _t _o _s |
| 631 |
!verbose push |
| 632 |
!verbose ${LOGICLIB_VERBOSITY} |
| 633 |
StrCpy "${_v}" "${_f}" ; Assign the initial value |
| 634 |
Goto +2 ; Skip the loop expression for the first iteration |
| 635 |
!define _DoLoopExpression `IntOp "${_v}" "${_v}" "${_o}" "${_s}"` ; Define the loop expression |
| 636 |
!define _o=${_o} |
| 637 |
!ifdef _o=+ ; Check the loop expression operator |
| 638 |
!define __o > ; to determine the correct loop condition |
| 639 |
!else ifdef _o=- |
| 640 |
!define __o < |
| 641 |
!else |
| 642 |
!error "Unsupported ForEach step operator (must be + or -)" |
| 643 |
!endif |
| 644 |
!undef _o=${_o} |
| 645 |
!insertmacro _Do For false `${_v}` `${__o}` `${_t}` ; Let Do do the rest |
| 646 |
!undef __o |
| 647 |
!verbose pop |
| 648 |
!macroend |
| 649 |
!define ForEach `!insertmacro _ForEach` |
| 650 |
|
| 651 |
!macro _For _v _f _t |
| 652 |
!verbose push |
| 653 |
!verbose ${LOGICLIB_VERBOSITY} |
| 654 |
${ForEach} `${_v}` `${_f}` `${_t}` + 1 ; Pass on to ForEach |
| 655 |
!verbose pop |
| 656 |
!macroend |
| 657 |
!define For `!insertmacro _For` |
| 658 |
|
| 659 |
!define ExitFor `!insertmacro _Goto ExitFor For` |
| 660 |
|
| 661 |
!define Next `!insertmacro _Loop For Next "" "" "" ""` |
| 662 |
|
| 663 |
!define While `!insertmacro _Do While true` |
| 664 |
|
| 665 |
!define ExitWhile `!insertmacro _Goto ExitWhile While` |
| 666 |
|
| 667 |
!define EndWhile `!insertmacro _Loop While EndWhile "" "" "" ""` |
| 668 |
|
| 669 |
!macro _Do _n _c _a _o _b |
| 670 |
!verbose push |
| 671 |
!verbose ${LOGICLIB_VERBOSITY} |
| 672 |
!insertmacro _PushLogic |
| 673 |
!define ${_Logic}${_n} _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the start of the loop |
| 674 |
!insertmacro _IncreaseCounter |
| 675 |
${${_Logic}${_n}}: |
| 676 |
!insertmacro _PushScope Exit${_n} _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the end of the loop |
| 677 |
!insertmacro _IncreaseCounter |
| 678 |
!insertmacro _PushScope Break ${_Exit${_n}} ; Break goes to the end of the loop |
| 679 |
!ifdef _DoLoopExpression |
| 680 |
${_DoLoopExpression} ; Special extra parameter for inserting code |
| 681 |
!undef _DoLoopExpression ; between the Continue label and the loop condition |
| 682 |
!endif |
| 683 |
!define _c=${_c} |
| 684 |
!ifdef _c= ; No starting condition |
| 685 |
!insertmacro _PushScope Continue _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for Continue at the end of the loop |
| 686 |
!insertmacro _IncreaseCounter |
| 687 |
!else |
| 688 |
!insertmacro _PushScope Continue ${${_Logic}${_n}} ; Continue goes to the start of the loop |
| 689 |
!ifdef _c=true ; If is true |
| 690 |
!insertmacro _${_o} `${_a}` `${_b}` "" ${_Exit${_n}} |
| 691 |
!else ; If condition is false |
| 692 |
!insertmacro _${_o} `${_a}` `${_b}` ${_Exit${_n}} "" |
| 693 |
!endif |
| 694 |
!endif |
| 695 |
!undef _c=${_c} |
| 696 |
!define ${_Logic}Condition ${_c} ; Remember the condition used |
| 697 |
!verbose pop |
| 698 |
!macroend |
| 699 |
!define Do `!insertmacro _Do Do "" "" "" ""` |
| 700 |
!define DoWhile `!insertmacro _Do Do true` |
| 701 |
!define DoUntil `!insertmacro _Do Do false` |
| 702 |
|
| 703 |
!macro _Goto _n _s |
| 704 |
!verbose push |
| 705 |
!verbose ${LOGICLIB_VERBOSITY} |
| 706 |
!ifndef _${_n} |
| 707 |
!error "Cannot use ${_n} without a preceding ${_s}" |
| 708 |
!endif |
| 709 |
Goto ${_${_n}} |
| 710 |
!verbose pop |
| 711 |
!macroend |
| 712 |
!define ExitDo `!insertmacro _Goto ExitDo Do` |
| 713 |
|
| 714 |
!macro _Loop _n _e _c _a _o _b |
| 715 |
!verbose push |
| 716 |
!verbose ${LOGICLIB_VERBOSITY} |
| 717 |
!ifndef _Logic | ${_Logic}${_n} |
| 718 |
!error "Cannot use ${_e} without a preceding ${_n}" |
| 719 |
!endif |
| 720 |
!define _c=${${_Logic}Condition} |
| 721 |
!ifdef _c= ; If Do had no condition place the Continue label |
| 722 |
${_Continue}: |
| 723 |
!endif |
| 724 |
!undef _c=${${_Logic}Condition} |
| 725 |
!define _c=${_c} |
| 726 |
!ifdef _c= ; No ending condition |
| 727 |
Goto ${${_Logic}${_n}} |
| 728 |
!else ifdef _c=true ; If condition is true |
| 729 |
!insertmacro _${_o} `${_a}` `${_b}` ${${_Logic}${_n}} ${_Exit${_n}} |
| 730 |
!else ; If condition is false |
| 731 |
!insertmacro _${_o} `${_a}` `${_b}` ${_Exit${_n}} ${${_Logic}${_n}} |
| 732 |
!endif |
| 733 |
!undef _c=${_c} |
| 734 |
Goto ${_Continue} ; Just to ensure it is referenced at least once |
| 735 |
Goto ${_Exit${_n}} ; Just to ensure it is referenced at least once |
| 736 |
${_Exit${_n}}: ; Place the loop exit point |
| 737 |
!undef ${_Logic}Condition |
| 738 |
!insertmacro _PopScope Continue |
| 739 |
!insertmacro _PopScope Break |
| 740 |
!insertmacro _PopScope Exit${_n} |
| 741 |
!undef ${_Logic}${_n} |
| 742 |
!insertmacro _PopLogic |
| 743 |
!verbose pop |
| 744 |
!macroend |
| 745 |
!define Loop `!insertmacro _Loop Do Loop "" "" "" ""` |
| 746 |
!define LoopWhile `!insertmacro _Loop Do LoopWhile true` |
| 747 |
!define LoopUntil `!insertmacro _Loop Do LoopUntil false` |
| 748 |
|
| 749 |
!define Continue `!insertmacro _Goto Continue "For or Do or While"` |
| 750 |
!define Break `!insertmacro _Goto Break "For or Do or While"` |
| 751 |
|
| 752 |
!macro _Select _a |
| 753 |
!verbose push |
| 754 |
!verbose ${LOGICLIB_VERBOSITY} |
| 755 |
!insertmacro _PushLogic |
| 756 |
!define ${_Logic}Select `${_a}` ; Remember the left hand side of the comparison |
| 757 |
!verbose pop |
| 758 |
!macroend |
| 759 |
!define Select `!insertmacro _Select` |
| 760 |
|
| 761 |
!macro _Select_CaseElse |
| 762 |
!verbose push |
| 763 |
!verbose ${LOGICLIB_VERBOSITY} |
| 764 |
!ifndef _Logic | ${_Logic}Select |
| 765 |
!error "Cannot use Case without a preceding Select" |
| 766 |
!endif |
| 767 |
!ifdef ${_Logic}EndSelect ; This is set only after the first case |
| 768 |
!ifndef ${_Logic}Else |
| 769 |
!error "Cannot use Case following a CaseElse" |
| 770 |
!endif |
| 771 |
Goto ${${_Logic}EndSelect} ; Go to EndSelect (Ends the previous Case) |
| 772 |
!define /IfNDef _LogicLib_EndSelectLabelUsed_${_Logic} |
| 773 |
${${_Logic}Else}: ; Place the Else label |
| 774 |
!undef ${_Logic}Else ; and remove it |
| 775 |
!else |
| 776 |
!define ${_Logic}EndSelect _LogicLib_EndSelectLabel_${LOGICLIB_COUNTER} ; Get a label for the EndSelect |
| 777 |
!insertmacro _IncreaseCounter |
| 778 |
!endif |
| 779 |
!verbose pop |
| 780 |
!macroend |
| 781 |
!define CaseElse `!insertmacro _CaseElse` |
| 782 |
!define Case_Else `!insertmacro _CaseElse` ; Compatibility with 2.2 and earlier |
| 783 |
!define Default `!insertmacro _CaseElse` ; For the C-minded |
| 784 |
|
| 785 |
!macro _Select_Case _a |
| 786 |
!verbose push |
| 787 |
!verbose ${LOGICLIB_VERBOSITY} |
| 788 |
${CaseElse} ; Perform the CaseElse |
| 789 |
!define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case |
| 790 |
!insertmacro _IncreaseCounter |
| 791 |
!insertmacro _== `${${_Logic}Select}` `${_a}` "" ${${_Logic}Else} |
| 792 |
!verbose pop |
| 793 |
!macroend |
| 794 |
!define Case `!insertmacro _Case` |
| 795 |
|
| 796 |
!macro _Case2 _a _b |
| 797 |
!verbose push |
| 798 |
!verbose ${LOGICLIB_VERBOSITY} |
| 799 |
${CaseElse} ; Perform the CaseElse |
| 800 |
!define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case |
| 801 |
!insertmacro _IncreaseCounter |
| 802 |
!insertmacro _== `${${_Logic}Select}` `${_a}` +2 "" |
| 803 |
!insertmacro _== `${${_Logic}Select}` `${_b}` "" ${${_Logic}Else} |
| 804 |
!verbose pop |
| 805 |
!macroend |
| 806 |
!define Case2 `!insertmacro _Case2` |
| 807 |
|
| 808 |
!macro _Case3 _a _b _c |
| 809 |
!verbose push |
| 810 |
!verbose ${LOGICLIB_VERBOSITY} |
| 811 |
${CaseElse} ; Perform the CaseElse |
| 812 |
!define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case |
| 813 |
!insertmacro _IncreaseCounter |
| 814 |
!insertmacro _== `${${_Logic}Select}` `${_a}` +3 "" |
| 815 |
!insertmacro _== `${${_Logic}Select}` `${_b}` +2 "" |
| 816 |
!insertmacro _== `${${_Logic}Select}` `${_c}` "" ${${_Logic}Else} |
| 817 |
!verbose pop |
| 818 |
!macroend |
| 819 |
!define Case3 `!insertmacro _Case3` |
| 820 |
|
| 821 |
!macro _Case4 _a _b _c _d |
| 822 |
!verbose push |
| 823 |
!verbose ${LOGICLIB_VERBOSITY} |
| 824 |
${CaseElse} ; Perform the CaseElse |
| 825 |
!define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case |
| 826 |
!insertmacro _IncreaseCounter |
| 827 |
!insertmacro _== `${${_Logic}Select}` `${_a}` +4 "" |
| 828 |
!insertmacro _== `${${_Logic}Select}` `${_b}` +3 "" |
| 829 |
!insertmacro _== `${${_Logic}Select}` `${_c}` +2 "" |
| 830 |
!insertmacro _== `${${_Logic}Select}` `${_d}` "" ${${_Logic}Else} |
| 831 |
!verbose pop |
| 832 |
!macroend |
| 833 |
!define Case4 `!insertmacro _Case4` |
| 834 |
|
| 835 |
!macro _Case5 _a _b _c _d _e |
| 836 |
!verbose push |
| 837 |
!verbose ${LOGICLIB_VERBOSITY} |
| 838 |
${CaseElse} ; Perform the CaseElse |
| 839 |
!define ${_Logic}Else _LogicLib_NextSelectCaseLabel_${LOGICLIB_COUNTER} ; Get a label for the next Else and perform the new Case |
| 840 |
!insertmacro _IncreaseCounter |
| 841 |
!insertmacro _== `${${_Logic}Select}` `${_a}` +5 "" |
| 842 |
!insertmacro _== `${${_Logic}Select}` `${_b}` +4 "" |
| 843 |
!insertmacro _== `${${_Logic}Select}` `${_c}` +3 "" |
| 844 |
!insertmacro _== `${${_Logic}Select}` `${_d}` +2 "" |
| 845 |
!insertmacro _== `${${_Logic}Select}` `${_e}` "" ${${_Logic}Else} |
| 846 |
!verbose pop |
| 847 |
!macroend |
| 848 |
!define Case5 `!insertmacro _Case5` |
| 849 |
|
| 850 |
!macro _EndSelect |
| 851 |
!verbose push |
| 852 |
!verbose ${LOGICLIB_VERBOSITY} |
| 853 |
!ifndef _Logic | ${_Logic}Select |
| 854 |
!error "Cannot use EndSelect without a preceding Select" |
| 855 |
!endif |
| 856 |
!ifdef ${_Logic}Else |
| 857 |
${${_Logic}Else}: ; Place the Else label |
| 858 |
!undef ${_Logic}Else ; and remove it |
| 859 |
!endif |
| 860 |
!ifdef ${_Logic}EndSelect ; This won't be set if there weren't any cases |
| 861 |
!ifdef _LogicLib_EndSelectLabelUsed_${_Logic} ; There is no jump to ${${_Logic}EndSelect}: if there is only one Case |
| 862 |
${${_Logic}EndSelect}: ; Place the EndSelect |
| 863 |
!undef _LogicLib_EndSelectLabelUsed_${_Logic} |
| 864 |
!endif |
| 865 |
!undef ${_Logic}EndSelect ; and remove it |
| 866 |
!endif |
| 867 |
!undef ${_Logic}Select |
| 868 |
!insertmacro _PopLogic |
| 869 |
!verbose pop |
| 870 |
!macroend |
| 871 |
!define EndSelect `!insertmacro _EndSelect` |
| 872 |
|
| 873 |
!macro _Switch _a |
| 874 |
!verbose push |
| 875 |
!verbose ${LOGICLIB_VERBOSITY} |
| 876 |
!insertmacro _PushLogic |
| 877 |
!insertmacro _PushScope Switch ${_Logic} ; Keep a separate stack for switch data |
| 878 |
!insertmacro _PushScope Break _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for beyond the end of the switch |
| 879 |
!insertmacro _IncreaseCounter |
| 880 |
!define ${_Switch}Var `${_a}` ; Remember the left hand side of the comparison |
| 881 |
!ifdef LL_NOAPPENDMEMFILE |
| 882 |
!tempfile ${_Switch}Tmp ; Create a temporary file |
| 883 |
!if "${NSIS_CHAR_SIZE}" > 1 |
| 884 |
!appendfile /CHARSET=UTF8SIG "${${_Switch}Tmp}" "" ; Make sure the file uses Unicode |
| 885 |
!endif |
| 886 |
!else |
| 887 |
!appendmemfile ${_Switch}Tmp ; Create a temporary file |
| 888 |
!endif |
| 889 |
!define ${_Logic}Switch _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the end of the switch |
| 890 |
!insertmacro _IncreaseCounter |
| 891 |
Goto ${${_Logic}Switch} ; and go there |
| 892 |
!verbose pop |
| 893 |
!macroend |
| 894 |
!define Switch `!insertmacro _Switch` |
| 895 |
|
| 896 |
!macro _Case _a |
| 897 |
!verbose push |
| 898 |
!verbose ${LOGICLIB_VERBOSITY} |
| 899 |
!ifdef _Logic & ${_Logic}Select ; Check for an active Select |
| 900 |
!insertmacro _Select_Case `${_a}` |
| 901 |
!else ifndef _Switch ; If not then check for an active Switch |
| 902 |
!error "Cannot use Case without a preceding Select or Switch" |
| 903 |
!else |
| 904 |
!define _label _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for this case, |
| 905 |
!insertmacro _IncreaseCounter |
| 906 |
${_label}: ; place it and add it's check to the temp file |
| 907 |
!ifdef LL_NOAPPENDMEMFILE |
| 908 |
!appendfile "${${_Switch}Tmp}" `!insertmacro _== $\`${${_Switch}Var}$\` $\`${_a}$\` ${_label} ""$\n` |
| 909 |
!else |
| 910 |
!appendmemfile ${_Switch}Tmp `!insertmacro _== $\`${${_Switch}Var}$\` $\`${_a}$\` ${_label} ""$\n` |
| 911 |
!endif |
| 912 |
!undef _label |
| 913 |
!endif |
| 914 |
!verbose pop |
| 915 |
!macroend |
| 916 |
|
| 917 |
!macro _CaseElse |
| 918 |
!verbose push |
| 919 |
!verbose ${LOGICLIB_VERBOSITY} |
| 920 |
!ifdef _Logic & ${_Logic}Select ; Check for an active Select |
| 921 |
!insertmacro _Select_CaseElse |
| 922 |
!else ifndef _Switch ; If not then check for an active Switch |
| 923 |
!error "Cannot use Case without a preceding Select or Switch" |
| 924 |
!else ifdef ${_Switch}Else ; Already had a default case? |
| 925 |
!error "Cannot use CaseElse following a CaseElse" |
| 926 |
!else |
| 927 |
!define ${_Switch}Else _LogicLib_Label_${LOGICLIB_COUNTER} ; Get a label for the default case, |
| 928 |
!insertmacro _IncreaseCounter |
| 929 |
${${_Switch}Else}: ; and place it |
| 930 |
!endif |
| 931 |
!verbose pop |
| 932 |
!macroend |
| 933 |
|
| 934 |
!macro _EndSwitch |
| 935 |
!verbose push |
| 936 |
!verbose ${LOGICLIB_VERBOSITY} |
| 937 |
!ifndef _Logic | ${_Logic}Switch |
| 938 |
!error "Cannot use EndSwitch without a preceding Switch" |
| 939 |
!endif |
| 940 |
Goto ${_Break} ; Skip the jump table |
| 941 |
${${_Logic}Switch}: ; Place the end of the switch |
| 942 |
!undef ${_Logic}Switch |
| 943 |
!ifdef LL_NOAPPENDMEMFILE |
| 944 |
!include "${${_Switch}Tmp}" ; Include the jump table |
| 945 |
!delfile "${${_Switch}Tmp}" ; and delete it |
| 946 |
!undef ${_Switch}Tmp |
| 947 |
!else |
| 948 |
!include /memfile ${_Switch}Tmp ; Include the jump table |
| 949 |
!appendmemfile '' ${_Switch}Tmp ; and delete it |
| 950 |
!endif |
| 951 |
!ifdef ${_Switch}Else ; Was there a default case? |
| 952 |
Goto ${${_Switch}Else} ; then go there if all else fails |
| 953 |
!undef ${_Switch}Else |
| 954 |
!endif |
| 955 |
!undef ${_Switch}Var |
| 956 |
${_Break}: ; Place the break label |
| 957 |
!insertmacro _PopScope Break |
| 958 |
!insertmacro _PopScope Switch |
| 959 |
!insertmacro _PopLogic |
| 960 |
!verbose pop |
| 961 |
!macroend |
| 962 |
!define EndSwitch `!insertmacro _EndSwitch` |
| 963 |
|
| 964 |
!endif ; LOGICLIB |
| 965 |
!verbose 3 |
| 966 |
!define LOGICLIB_VERBOSITY ${_LOGICLIB_VERBOSITY} |
| 967 |
!undef _LOGICLIB_VERBOSITY |
| 968 |
!verbose pop |