David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 1 | #############################################
|
| 2 | ; StrRep
|
| 3 |
|
| 4 | !define StrRep "!insertmacro StrRep"
|
| 5 | !macro StrRep output string old new
|
| 6 | Push `${string}`
|
| 7 | Push `${old}`
|
| 8 | Push `${new}`
|
| 9 | !ifdef __UNINSTALL__
|
| 10 | Call un.StrRep
|
| 11 | !else
|
| 12 | Call StrRep
|
| 13 | !endif
|
| 14 | Pop ${output}
|
| 15 | !macroend
|
| 16 |
|
| 17 | !macro Func_StrRep un
|
| 18 | Function ${un}StrRep
|
| 19 | Exch $R2 ;new
|
| 20 | Exch 1
|
| 21 | Exch $R1 ;old
|
| 22 | Exch 2
|
| 23 | Exch $R0 ;string
|
| 24 | Push $R3
|
| 25 | Push $R4
|
| 26 | Push $R5
|
| 27 | Push $R6
|
| 28 | Push $R7
|
| 29 | Push $R8
|
| 30 | Push $R9
|
| 31 |
|
| 32 | StrCpy $R3 0
|
| 33 | StrLen $R4 $R1
|
| 34 | StrLen $R6 $R0
|
| 35 | StrLen $R9 $R2
|
| 36 | loop:
|
| 37 | StrCpy $R5 $R0 $R4 $R3
|
| 38 | StrCmp $R5 $R1 found
|
| 39 | StrCmp $R3 $R6 done
|
| 40 | IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character
|
| 41 | Goto loop
|
| 42 | found:
|
| 43 | StrCpy $R5 $R0 $R3
|
| 44 | IntOp $R8 $R3 + $R4
|
| 45 | StrCpy $R7 $R0 "" $R8
|
| 46 | StrCpy $R0 $R5$R2$R7
|
| 47 | StrLen $R6 $R0
|
| 48 | IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string
|
| 49 | Goto loop
|
| 50 | done:
|
| 51 |
|
| 52 | Pop $R9
|
| 53 | Pop $R8
|
| 54 | Pop $R7
|
| 55 | Pop $R6
|
| 56 | Pop $R5
|
| 57 | Pop $R4
|
| 58 | Pop $R3
|
| 59 | Push $R0
|
| 60 | Push $R1
|
| 61 | Pop $R0
|
| 62 | Pop $R1
|
| 63 | Pop $R0
|
| 64 | Pop $R2
|
| 65 | Exch $R1
|
| 66 | FunctionEnd
|
| 67 | !macroend
|
| 68 | !insertmacro Func_StrRep ""
|
| 69 | !insertmacro Func_StrRep "un."
|