Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / StrFunc.nsh @ 3119

Historique | Voir | Annoter | Télécharger (43,42 ko)

1 728 mdecorde
/*
2 728 mdecorde
o-----------------------------------------------------------------------------o
3 2956 mdecorde
|String Functions Header File 1.10                                            |
4 728 mdecorde
(-----------------------------------------------------------------------------)
5 728 mdecorde
| By deguix                                     / A Header file for NSIS 2.01 |
6 728 mdecorde
| <cevo_deguix@yahoo.com.br>                   -------------------------------|
7 728 mdecorde
|                                                                             |
8 728 mdecorde
|    This header file contains NSIS functions for string manipulation.        |
9 728 mdecorde
o-----------------------------------------------------------------------------o
10 728 mdecorde
*/
11 728 mdecorde
12 2956 mdecorde
!verbose push 3
13 2956 mdecorde
!define /IfNDef STRFUNC_VERBOSITY 3
14 2956 mdecorde
!define /IfNDef _STRFUNC_VERBOSITY ${STRFUNC_VERBOSITY}
15 2956 mdecorde
!define /IfNDef _STRFUNC_CREDITVERBOSITY ${STRFUNC_VERBOSITY}
16 728 mdecorde
!undef STRFUNC_VERBOSITY
17 728 mdecorde
!verbose ${_STRFUNC_VERBOSITY}
18 728 mdecorde
19 728 mdecorde
!include LogicLib.nsh
20 728 mdecorde
21 728 mdecorde
!ifndef STRFUNC
22 728 mdecorde
23 2956 mdecorde
  !define /IfNDef FALSE 0
24 2956 mdecorde
  !define /IfNDef TRUE 1
25 728 mdecorde
26 728 mdecorde
  ;Header File Identification
27 728 mdecorde
28 728 mdecorde
  !define STRFUNC `String Functions Header File`
29 2956 mdecorde
  ;define STRFUNC_SHORT `StrFunc`
30 728 mdecorde
  !define STRFUNC_CREDITS `2004 Diego Pedroso`
31 728 mdecorde
32 728 mdecorde
  ;Header File Version
33 728 mdecorde
34 728 mdecorde
  !define STRFUNC_VERMAJ 1
35 2956 mdecorde
  !define STRFUNC_VERMED 10
36 728 mdecorde
 ;!define STRFUNC_VERMIN 0
37 728 mdecorde
 ;!define STRFUNC_VERBLD 0
38 728 mdecorde
39 728 mdecorde
  !define STRFUNC_VER `${STRFUNC_VERMAJ}.${STRFUNC_VERMED}`
40 728 mdecorde
41 728 mdecorde
  ;Header File Init Message Prefix and Postfix
42 728 mdecorde
43 728 mdecorde
  !define STRFUNC_INITMSGPRE `----------------------------------------------------------------------$\r$\n`
44 728 mdecorde
  !define STRFUNC_INITMSGPOST `$\r$\n----------------------------------------------------------------------$\r$\n`
45 728 mdecorde
46 728 mdecorde
  ;Header File Init Message
47 728 mdecorde
48 2956 mdecorde
  !verbose push ${_STRFUNC_CREDITVERBOSITY}
49 728 mdecorde
  !echo `${STRFUNC_INITMSGPRE}NSIS ${STRFUNC} ${STRFUNC_VER} - Copyright ${STRFUNC_CREDITS}${STRFUNC_INITMSGPOST}`
50 728 mdecorde
  !verbose pop
51 728 mdecorde
52 728 mdecorde
  ;Header File Function Macros
53 728 mdecorde
54 2956 mdecorde
  !ifdef STRFUNC_USECALLARTIFICIALFUNCTION
55 2956 mdecorde
    !include Util.nsh
56 2956 mdecorde
  !endif
57 2956 mdecorde
58 2956 mdecorde
  !define "Using:StrFunc" `!insertmacro STRFUNC_USING `
59 2956 mdecorde
  !macro STRFUNC_USING Name
60 2956 mdecorde
    !if "${STRFUNC_VERBOSITY}" > 4
61 2956 mdecorde
      !verbose push 4
62 2956 mdecorde
    !endif
63 2956 mdecorde
    !ifndef ${Name}_INCLUDED
64 2956 mdecorde
      ${${Name}} ; Invoke !insertmacro STRFUNC_MAKEFUNC
65 2956 mdecorde
    !endif
66 2956 mdecorde
    !if "${STRFUNC_VERBOSITY}" > 4
67 2956 mdecorde
      !verbose pop
68 2956 mdecorde
    !endif
69 2956 mdecorde
  !macroend
70 2956 mdecorde
71 728 mdecorde
  !macro STRFUNC_FUNCLIST_INSERT Name
72 728 mdecorde
    !ifdef StrFunc_List
73 2956 mdecorde
      !define /ReDef StrFunc_List `${StrFunc_List}|${Name}`
74 728 mdecorde
    !else
75 728 mdecorde
      !define StrFunc_List `${Name}`
76 728 mdecorde
    !endif
77 728 mdecorde
  !macroend
78 728 mdecorde
79 2956 mdecorde
  !macro STRFUNC_DEFFUNC Name List TypeList
80 728 mdecorde
    !insertmacro STRFUNC_FUNCLIST_INSERT ${Name}
81 2956 mdecorde
    !define `${Name}_List` `${List}`
82 2956 mdecorde
    !define `${Name}_TypeList` `${TypeList}`
83 2956 mdecorde
    !ifdef STRFUNC_USECALLARTIFICIALFUNCTION
84 2956 mdecorde
      !define `${Name}` `!insertmacro STRFUNC_CALL_${Name} "${un}" `
85 2956 mdecorde
      !define `Un${Name}` `!insertmacro STRFUNC_CALL_${Name} "${un}" `
86 728 mdecorde
    !else
87 2956 mdecorde
      !define `${Name}` `!insertmacro STRFUNC_MAKEFUNC ${Name} ""`
88 2956 mdecorde
      !define `Un${Name}` `!insertmacro STRFUNC_MAKEFUNC ${Name} Un`
89 728 mdecorde
    !endif
90 728 mdecorde
  !macroend
91 728 mdecorde
92 2956 mdecorde
  !macro STRFUNC_MAKEFUNC basename un
93 2956 mdecorde
    !insertmacro STRFUNC_MAKEFUNC_${basename}
94 728 mdecorde
  !macroend
95 728 mdecorde
96 2956 mdecorde
  !macro STRFUNC_BEGINFUNC basename un credits
97 2956 mdecorde
    !verbose push ${_STRFUNC_CREDITVERBOSITY}
98 2956 mdecorde
    !echo `${U+24}{${un}${basename}} - Copyright ${credits}`
99 2956 mdecorde
    !verbose pop
100 2956 mdecorde
    !define ${un}${basename}_INCLUDED
101 2956 mdecorde
    !ifndef STRFUNC_USECALLARTIFICIALFUNCTION
102 2956 mdecorde
      !define /ReDef ${un}${basename} `!insertmacro STRFUNC_CALL_${basename} "${un}" `
103 2956 mdecorde
      !if "${un}" != ""
104 2956 mdecorde
        Function un.${basename}
105 2956 mdecorde
      !else
106 2956 mdecorde
        Function ${basename}
107 2956 mdecorde
      !endif
108 2956 mdecorde
    !endif
109 728 mdecorde
  !macroend
110 2956 mdecorde
  !macro STRFUNC_ENDFUNC
111 2956 mdecorde
    !ifndef STRFUNC_USECALLARTIFICIALFUNCTION
112 2956 mdecorde
      FunctionEnd
113 2956 mdecorde
    !endif
114 728 mdecorde
  !macroend
115 728 mdecorde
116 2956 mdecorde
  !macro STRFUNC_CALL basename un
117 2956 mdecorde
    !ifdef STRFUNC_USECALLARTIFICIALFUNCTION
118 2956 mdecorde
      ${CallArtificialFunction} STRFUNC_MAKEFUNC_${basename}
119 2956 mdecorde
    !else
120 2956 mdecorde
      !if "${un}" != ""
121 2956 mdecorde
        Call un.${basename}
122 2956 mdecorde
      !else
123 2956 mdecorde
        Call ${basename}
124 2956 mdecorde
      !endif
125 2956 mdecorde
    !endif
126 728 mdecorde
  !macroend
127 728 mdecorde
128 728 mdecorde
129 2956 mdecorde
  ############################################################################
130 2956 mdecorde
  # StrCase
131 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrCase `ResultVar|String|Type` `Output|Text|Option  U L T S <>`
132 728 mdecorde
133 2956 mdecorde
  !macro STRFUNC_CALL_StrCase un ResultVar String Type
134 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
135 2956 mdecorde
    !echo `${U+24}{${un}StrCase} "${ResultVar}" "${String}" "${Type}"`
136 2956 mdecorde
    !verbose 2
137 2956 mdecorde
    Push `${String}`
138 2956 mdecorde
    Push `${Type}`
139 2956 mdecorde
    !insertmacro STRFUNC_CALL StrCase "${un}"
140 2956 mdecorde
    Pop ${ResultVar}
141 2956 mdecorde
    !verbose pop
142 728 mdecorde
  !macroend
143 728 mdecorde
144 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrCase
145 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Dave Laundon`
146 728 mdecorde
    /*After this point:
147 728 mdecorde
      ------------------------------------------
148 728 mdecorde
       $0 = String (input)
149 728 mdecorde
       $1 = Type (input)
150 728 mdecorde
       $2 = StrLength (temp)
151 728 mdecorde
       $3 = StartChar (temp)
152 728 mdecorde
       $4 = EndChar (temp)
153 728 mdecorde
       $5 = ResultStr (temp)
154 728 mdecorde
       $6 = CurrentChar (temp)
155 728 mdecorde
       $7 = LastChar (temp)
156 728 mdecorde
       $8 = Temp (temp)*/
157 728 mdecorde
158 728 mdecorde
      ;Get input from user
159 728 mdecorde
      Exch $1
160 728 mdecorde
      Exch
161 728 mdecorde
      Exch $0
162 728 mdecorde
      Exch
163 728 mdecorde
      Push $2
164 728 mdecorde
      Push $3
165 728 mdecorde
      Push $4
166 728 mdecorde
      Push $5
167 728 mdecorde
      Push $6
168 728 mdecorde
      Push $7
169 728 mdecorde
      Push $8
170 728 mdecorde
171 728 mdecorde
      ;Initialize variables
172 728 mdecorde
      StrCpy $2 ""
173 728 mdecorde
      StrCpy $3 ""
174 728 mdecorde
      StrCpy $4 ""
175 728 mdecorde
      StrCpy $5 ""
176 728 mdecorde
      StrCpy $6 ""
177 728 mdecorde
      StrCpy $7 ""
178 728 mdecorde
      StrCpy $8 ""
179 728 mdecorde
180 728 mdecorde
      ;Upper and lower cases are simple to use
181 728 mdecorde
      ${If} $1 == "U"
182 728 mdecorde
183 728 mdecorde
        ;Upper Case System:
184 728 mdecorde
        ;------------------
185 728 mdecorde
        ; Convert all characters to upper case.
186 728 mdecorde
187 728 mdecorde
        System::Call "User32::CharUpper(t r0 r5)i"
188 728 mdecorde
        Goto StrCase_End
189 728 mdecorde
      ${ElseIf} $1 == "L"
190 728 mdecorde
191 728 mdecorde
        ;Lower Case System:
192 728 mdecorde
        ;------------------
193 728 mdecorde
        ; Convert all characters to lower case.
194 728 mdecorde
195 728 mdecorde
        System::Call "User32::CharLower(t r0 r5)i"
196 728 mdecorde
        Goto StrCase_End
197 728 mdecorde
      ${EndIf}
198 728 mdecorde
199 728 mdecorde
      ;For the rest of cases:
200 728 mdecorde
      ;Get "String" length
201 728 mdecorde
      StrLen $2 $0
202 728 mdecorde
203 728 mdecorde
      ;Make a loop until the end of "String"
204 728 mdecorde
      ${For} $3 0 $2
205 728 mdecorde
        ;Add 1 to "EndChar" counter also
206 728 mdecorde
        IntOp $4 $3 + 1
207 728 mdecorde
208 728 mdecorde
        # Step 1: Detect one character at a time
209 728 mdecorde
210 728 mdecorde
        ;Remove characters before "StartChar" except when
211 728 mdecorde
        ;"StartChar" is the first character of "String"
212 728 mdecorde
        ${If} $3 <> 0
213 728 mdecorde
          StrCpy $6 $0 `` $3
214 728 mdecorde
        ${EndIf}
215 728 mdecorde
216 728 mdecorde
        ;Remove characters after "EndChar" except when
217 728 mdecorde
        ;"EndChar" is the last character of "String"
218 728 mdecorde
        ${If} $4 <> $2
219 728 mdecorde
          ${If} $3 = 0
220 728 mdecorde
            StrCpy $6 $0 1
221 728 mdecorde
          ${Else}
222 728 mdecorde
            StrCpy $6 $6 1
223 728 mdecorde
          ${EndIf}
224 728 mdecorde
        ${EndIf}
225 728 mdecorde
226 728 mdecorde
        # Step 2: Convert to the advanced case user chose:
227 728 mdecorde
228 728 mdecorde
        ${If} $1 == "T"
229 728 mdecorde
230 728 mdecorde
          ;Title Case System:
231 728 mdecorde
          ;------------------
232 728 mdecorde
          ; Convert all characters after a non-alphabetic character to upper case.
233 728 mdecorde
          ; Else convert to lower case.
234 728 mdecorde
235 728 mdecorde
          ;Use "IsCharAlpha" for the job
236 2956 mdecorde
          System::Call "*(&t1 r7) p .r8"
237 728 mdecorde
          System::Call "*$8(&i1 .r7)"
238 728 mdecorde
          System::Free $8
239 728 mdecorde
          System::Call "user32::IsCharAlpha(i r7) i .r8"
240 728 mdecorde
241 728 mdecorde
          ;Verify "IsCharAlpha" result and convert the character
242 728 mdecorde
          ${If} $8 = 0
243 728 mdecorde
            System::Call "User32::CharUpper(t r6 r6)i"
244 728 mdecorde
          ${Else}
245 728 mdecorde
            System::Call "User32::CharLower(t r6 r6)i"
246 728 mdecorde
          ${EndIf}
247 728 mdecorde
        ${ElseIf} $1 == "S"
248 728 mdecorde
249 728 mdecorde
          ;Sentence Case System:
250 728 mdecorde
          ;------------------
251 728 mdecorde
          ; Convert all characters after a ".", "!" or "?" character to upper case.
252 728 mdecorde
          ; Else convert to lower case. Spaces or tabs after these marks are ignored.
253 728 mdecorde
254 728 mdecorde
          ;Detect current characters and ignore if necessary
255 728 mdecorde
          ${If} $6 == " "
256 728 mdecorde
          ${OrIf} $6 == "$\t"
257 728 mdecorde
            Goto IgnoreLetter
258 728 mdecorde
          ${EndIf}
259 728 mdecorde
260 728 mdecorde
          ;Detect last characters and convert
261 728 mdecorde
          ${If} $7 == "."
262 728 mdecorde
          ${OrIf} $7 == "!"
263 728 mdecorde
          ${OrIf} $7 == "?"
264 728 mdecorde
          ${OrIf} $7 == ""
265 728 mdecorde
            System::Call "User32::CharUpper(t r6 r6)i"
266 728 mdecorde
          ${Else}
267 728 mdecorde
            System::Call "User32::CharLower(t r6 r6)i"
268 728 mdecorde
          ${EndIf}
269 728 mdecorde
        ${ElseIf} $1 == "<>"
270 728 mdecorde
271 728 mdecorde
          ;Switch Case System:
272 728 mdecorde
          ;------------------
273 728 mdecorde
          ; Switch all characters cases to their inverse case.
274 728 mdecorde
275 728 mdecorde
          ;Use "IsCharUpper" for the job
276 2956 mdecorde
          System::Call "*(&t1 r6) p .r8"
277 728 mdecorde
          System::Call "*$8(&i1 .r7)"
278 728 mdecorde
          System::Free $8
279 728 mdecorde
          System::Call "user32::IsCharUpper(i r7) i .r8"
280 728 mdecorde
281 728 mdecorde
          ;Verify "IsCharUpper" result and convert the character
282 728 mdecorde
          ${If} $8 = 0
283 728 mdecorde
            System::Call "User32::CharUpper(t r6 r6)i"
284 728 mdecorde
          ${Else}
285 728 mdecorde
            System::Call "User32::CharLower(t r6 r6)i"
286 728 mdecorde
          ${EndIf}
287 728 mdecorde
        ${EndIf}
288 728 mdecorde
289 728 mdecorde
        ;Write the character to "LastChar"
290 728 mdecorde
        StrCpy $7 $6
291 728 mdecorde
292 728 mdecorde
        IgnoreLetter:
293 728 mdecorde
        ;Add this character to "ResultStr"
294 728 mdecorde
        StrCpy $5 `$5$6`
295 728 mdecorde
      ${Next}
296 728 mdecorde
297 728 mdecorde
      StrCase_End:
298 728 mdecorde
299 728 mdecorde
    /*After this point:
300 728 mdecorde
      ------------------------------------------
301 728 mdecorde
       $0 = OutVar (output)*/
302 728 mdecorde
303 728 mdecorde
      ; Copy "ResultStr" to "OutVar"
304 728 mdecorde
      StrCpy $0 $5
305 728 mdecorde
306 728 mdecorde
      ;Return output to user
307 728 mdecorde
      Pop $8
308 728 mdecorde
      Pop $7
309 728 mdecorde
      Pop $6
310 728 mdecorde
      Pop $5
311 728 mdecorde
      Pop $4
312 728 mdecorde
      Pop $3
313 728 mdecorde
      Pop $2
314 728 mdecorde
      Pop $1
315 728 mdecorde
      Exch $0
316 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
317 728 mdecorde
318 728 mdecorde
  !macroend
319 728 mdecorde
320 2956 mdecorde
  ############################################################################
321 2956 mdecorde
  # StrClb
322 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrClb `ResultVar|String|Action` `Output|Text|Option  > < <>`
323 728 mdecorde
324 2956 mdecorde
  !macro STRFUNC_CALL_StrClb un ResultVar String Action
325 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
326 2956 mdecorde
    !echo `${U+24}{${un}StrClb} "${ResultVar}" "${String}" "${Action}"`
327 2956 mdecorde
    !verbose 2
328 2956 mdecorde
    Push `${String}`
329 2956 mdecorde
    Push `${Action}`
330 2956 mdecorde
    !insertmacro STRFUNC_CALL StrClb "${un}"
331 2956 mdecorde
    Pop ${ResultVar}
332 2956 mdecorde
    !verbose pop
333 2956 mdecorde
  !macroend
334 2956 mdecorde
335 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrClb
336 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Nik Medved`
337 2956 mdecorde
338 728 mdecorde
    /*After this point:
339 728 mdecorde
      ------------------------------------------
340 728 mdecorde
       $0 = String (input)
341 728 mdecorde
       $1 = Action (input)
342 728 mdecorde
       $2 = Lock/Unlock (temp)
343 728 mdecorde
       $3 = Temp (temp)
344 728 mdecorde
       $4 = Temp2 (temp)*/
345 728 mdecorde
346 728 mdecorde
      ;Get input from user
347 728 mdecorde
348 728 mdecorde
      Exch $1
349 728 mdecorde
      Exch
350 728 mdecorde
      Exch $0
351 728 mdecorde
      Exch
352 728 mdecorde
      Push $2
353 728 mdecorde
      Push $3
354 728 mdecorde
      Push $4
355 728 mdecorde
356 728 mdecorde
      StrCpy $2 ""
357 728 mdecorde
      StrCpy $3 ""
358 728 mdecorde
      StrCpy $4 ""
359 728 mdecorde
360 728 mdecorde
      ;Open the clipboard to do the operations the user chose (kichik's fix)
361 2956 mdecorde
      System::Call 'user32::OpenClipboard(p $HWNDPARENT)'
362 728 mdecorde
363 728 mdecorde
      ${If} $1 == ">" ;Set
364 728 mdecorde
365 728 mdecorde
        ;Step 1: Clear the clipboard
366 728 mdecorde
        System::Call 'user32::EmptyClipboard()'
367 728 mdecorde
368 728 mdecorde
        ;Step 2: Allocate global heap
369 728 mdecorde
        StrLen $2 $0
370 728 mdecorde
        IntOp $2 $2 + 1
371 2956 mdecorde
        IntOp $2 $2 * ${NSIS_CHAR_SIZE}
372 2956 mdecorde
        System::Call 'kernel32::GlobalAlloc(i 2, i r2) p.r2'
373 728 mdecorde
374 728 mdecorde
        ;Step 3: Lock the handle
375 2956 mdecorde
        System::Call 'kernel32::GlobalLock(p r2) i.r3'
376 728 mdecorde
377 728 mdecorde
        ;Step 4: Copy the text to locked clipboard buffer
378 2956 mdecorde
        System::Call 'kernel32::lstrcpy(p r3, t r0)'
379 728 mdecorde
380 728 mdecorde
        ;Step 5: Unlock the handle again
381 2956 mdecorde
        System::Call 'kernel32::GlobalUnlock(p r2)'
382 728 mdecorde
383 728 mdecorde
        ;Step 6: Set the information to the clipboard
384 2956 mdecorde
        System::Call 'user32::SetClipboardData(i 1, p r2)'
385 728 mdecorde
386 728 mdecorde
        StrCpy $0 ""
387 728 mdecorde
388 728 mdecorde
      ${ElseIf} $1 == "<" ;Get
389 728 mdecorde
390 728 mdecorde
        ;Step 1: Get clipboard data
391 2956 mdecorde
        System::Call 'user32::GetClipboardData(i 1) p .r2'
392 728 mdecorde
393 728 mdecorde
        ;Step 2: Lock and copy data (kichik's fix)
394 2956 mdecorde
        System::Call 'kernel32::GlobalLock(p r2) t .r0'
395 728 mdecorde
396 728 mdecorde
        ;Step 3: Unlock (kichik's fix)
397 2956 mdecorde
        System::Call 'kernel32::GlobalUnlock(p r2)'
398 728 mdecorde
399 728 mdecorde
      ${ElseIf} $1 == "<>" ;Swap
400 728 mdecorde
401 728 mdecorde
        ;Step 1: Get clipboard data
402 2956 mdecorde
        System::Call 'user32::GetClipboardData(i 1) p .r2'
403 728 mdecorde
404 728 mdecorde
        ;Step 2: Lock and copy data (kichik's fix)
405 2956 mdecorde
        System::Call 'kernel32::GlobalLock(p r2) t .r4'
406 728 mdecorde
407 728 mdecorde
        ;Step 3: Unlock (kichik's fix)
408 2956 mdecorde
        System::Call 'kernel32::GlobalUnlock(p r2)'
409 728 mdecorde
410 728 mdecorde
        ;Step 4: Clear the clipboard
411 728 mdecorde
        System::Call 'user32::EmptyClipboard()'
412 728 mdecorde
413 728 mdecorde
        ;Step 5: Allocate global heap
414 728 mdecorde
        StrLen $2 $0
415 728 mdecorde
        IntOp $2 $2 + 1
416 2956 mdecorde
        IntOp $2 $2 * ${NSIS_CHAR_SIZE}
417 2956 mdecorde
        System::Call 'kernel32::GlobalAlloc(i 2, i r2) p.r2'
418 728 mdecorde
419 728 mdecorde
        ;Step 6: Lock the handle
420 2956 mdecorde
        System::Call 'kernel32::GlobalLock(p r2) i.r3'
421 728 mdecorde
422 728 mdecorde
        ;Step 7: Copy the text to locked clipboard buffer
423 2956 mdecorde
        System::Call 'kernel32::lstrcpy(p r3, t r0)'
424 728 mdecorde
425 728 mdecorde
        ;Step 8: Unlock the handle again
426 2956 mdecorde
        System::Call 'kernel32::GlobalUnlock(p r2)'
427 728 mdecorde
428 728 mdecorde
        ;Step 9: Set the information to the clipboard
429 2956 mdecorde
        System::Call 'user32::SetClipboardData(i 1, p r2)'
430 728 mdecorde
431 728 mdecorde
        StrCpy $0 $4
432 728 mdecorde
      ${Else} ;Clear
433 728 mdecorde
434 728 mdecorde
        ;Step 1: Clear the clipboard
435 728 mdecorde
        System::Call 'user32::EmptyClipboard()'
436 728 mdecorde
437 728 mdecorde
        StrCpy $0 ""
438 728 mdecorde
      ${EndIf}
439 728 mdecorde
440 728 mdecorde
      ;Close the clipboard
441 728 mdecorde
      System::Call 'user32::CloseClipboard()'
442 728 mdecorde
443 728 mdecorde
    /*After this point:
444 728 mdecorde
      ------------------------------------------
445 728 mdecorde
       $0 = OutVar (output)*/
446 728 mdecorde
447 728 mdecorde
      ;Return result to user
448 728 mdecorde
      Pop $4
449 728 mdecorde
      Pop $3
450 728 mdecorde
      Pop $2
451 728 mdecorde
      Pop $1
452 728 mdecorde
      Exch $0
453 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
454 728 mdecorde
455 728 mdecorde
  !macroend
456 728 mdecorde
457 2956 mdecorde
  ############################################################################
458 2956 mdecorde
  # StrIOToNSIS
459 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrIOToNSIS `ResultVar|String` `Output|Text`
460 728 mdecorde
461 2956 mdecorde
  !macro STRFUNC_CALL_StrIOToNSIS un ResultVar String
462 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
463 2956 mdecorde
    !echo `${U+24}{${un}StrIOToNSIS} "${ResultVar}" "${String}"`
464 2956 mdecorde
    !verbose 2
465 2956 mdecorde
    Push `${String}`
466 2956 mdecorde
    !insertmacro STRFUNC_CALL StrIOToNSIS "${un}"
467 2956 mdecorde
    Pop ${ResultVar}
468 2956 mdecorde
    !verbose pop
469 2956 mdecorde
  !macroend
470 728 mdecorde
471 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrIOToNSIS
472 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 "bluenet" - Based on functions by Amir Szekely, Joost Verburg, Dave Laundon and Diego Pedroso`
473 2956 mdecorde
474 728 mdecorde
    /*After this point:
475 728 mdecorde
      ------------------------------------------
476 728 mdecorde
       $R0 = String (input/output)
477 728 mdecorde
       $R1 = StartCharPos (temp)
478 728 mdecorde
       $R2 = StrLen (temp)
479 728 mdecorde
       $R3 = TempStr (temp)
480 728 mdecorde
       $R4 = TempRepStr (temp)*/
481 728 mdecorde
482 728 mdecorde
      ;Get input from user
483 728 mdecorde
      Exch $R0
484 728 mdecorde
      Push $R1
485 728 mdecorde
      Push $R2
486 728 mdecorde
      Push $R3
487 728 mdecorde
      Push $R4
488 728 mdecorde
489 728 mdecorde
      ;Get "String" length
490 728 mdecorde
      StrLen $R2 $R0
491 728 mdecorde
492 728 mdecorde
      ;Loop until "String" end is reached
493 728 mdecorde
      ${For} $R1 0 $R2
494 728 mdecorde
        ;Get the next "String" characters
495 728 mdecorde
        StrCpy $R3 $R0 2 $R1
496 728 mdecorde
497 728 mdecorde
        ;Detect if current character is:
498 728 mdecorde
        ${If} $R3 == "\\" ;Back-slash
499 728 mdecorde
          StrCpy $R4 "\"
500 728 mdecorde
        ${ElseIf} $R3 == "\r" ;Carriage return
501 728 mdecorde
          StrCpy $R4 "$\r"
502 728 mdecorde
        ${ElseIf} $R3 == "\n" ;Line feed
503 728 mdecorde
          StrCpy $R4 "$\n"
504 728 mdecorde
        ${ElseIf} $R3 == "\t" ;Tab
505 728 mdecorde
          StrCpy $R4 "$\t"
506 728 mdecorde
        ${Else} ;Anything else
507 728 mdecorde
          StrCpy $R4 ""
508 728 mdecorde
        ${EndIf}
509 728 mdecorde
510 728 mdecorde
        ;Detect if "TempRepStr" is not empty
511 728 mdecorde
        ${If} $R4 != ""
512 728 mdecorde
          ;Replace the old characters with the new one
513 728 mdecorde
          StrCpy $R3 $R0 $R1
514 728 mdecorde
          IntOp $R1 $R1 + 2
515 728 mdecorde
          StrCpy $R0 $R0 "" $R1
516 728 mdecorde
          StrCpy $R0 "$R3$R4$R0"
517 728 mdecorde
          IntOp $R2 $R2 - 1 ;Decrease "StrLen"
518 728 mdecorde
          IntOp $R1 $R1 - 2 ;Go back to the next character
519 728 mdecorde
        ${EndIf}
520 728 mdecorde
      ${Next}
521 728 mdecorde
      Pop $R4
522 728 mdecorde
      Pop $R3
523 728 mdecorde
      Pop $R2
524 728 mdecorde
      Pop $R1
525 728 mdecorde
      Exch $R0
526 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
527 728 mdecorde
  !macroend
528 728 mdecorde
529 2956 mdecorde
  ############################################################################
530 2956 mdecorde
  # StrLoc
531 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrLoc `ResultVar|String|StrToSearchFor|CounterDirection` `Output|Text|Text|Option > <`
532 728 mdecorde
533 2956 mdecorde
  !macro STRFUNC_CALL_StrLoc un ResultVar String StrToSearchFor OffsetDirection
534 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
535 2956 mdecorde
    !echo `${U+24}{${un}StrLoc} "${ResultVar}" "${String}" "${StrToSearchFor}" "${OffsetDirection}"`
536 2956 mdecorde
    !verbose 2
537 2956 mdecorde
    Push `${String}`
538 2956 mdecorde
    Push `${StrToSearchFor}`
539 2956 mdecorde
    Push `${OffsetDirection}`
540 2956 mdecorde
    !insertmacro STRFUNC_CALL StrLoc "${un}"
541 2956 mdecorde
    Pop ${ResultVar}
542 2956 mdecorde
    !verbose pop
543 2956 mdecorde
  !macroend
544 728 mdecorde
545 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrLoc
546 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Ximon Eighteen`
547 2956 mdecorde
548 728 mdecorde
    /*After this point:
549 728 mdecorde
      ------------------------------------------
550 728 mdecorde
       $R0 = OffsetDirection (input)
551 728 mdecorde
       $R1 = StrToSearch (input)
552 728 mdecorde
       $R2 = String (input)
553 728 mdecorde
       $R3 = StrToSearchLen (temp)
554 728 mdecorde
       $R4 = StrLen (temp)
555 728 mdecorde
       $R5 = StartCharPos (temp)
556 728 mdecorde
       $R6 = TempStr (temp)*/
557 728 mdecorde
558 728 mdecorde
      ;Get input from user
559 728 mdecorde
      Exch $R0
560 728 mdecorde
      Exch
561 728 mdecorde
      Exch $R1
562 728 mdecorde
      Exch 2
563 728 mdecorde
      Exch $R2
564 728 mdecorde
      Push $R3
565 728 mdecorde
      Push $R4
566 728 mdecorde
      Push $R5
567 728 mdecorde
      Push $R6
568 728 mdecorde
569 728 mdecorde
      ;Get "String" and "StrToSearch" length
570 728 mdecorde
      StrLen $R3 $R1
571 728 mdecorde
      StrLen $R4 $R2
572 728 mdecorde
      ;Start "StartCharPos" counter
573 728 mdecorde
      StrCpy $R5 0
574 728 mdecorde
575 728 mdecorde
      ;Loop until "StrToSearch" is found or "String" reaches its end
576 728 mdecorde
      ${Do}
577 728 mdecorde
        ;Remove everything before and after the searched part ("TempStr")
578 728 mdecorde
        StrCpy $R6 $R2 $R3 $R5
579 728 mdecorde
580 728 mdecorde
        ;Compare "TempStr" with "StrToSearch"
581 728 mdecorde
        ${If} $R6 == $R1
582 728 mdecorde
          ${If} $R0 == `<`
583 728 mdecorde
            IntOp $R6 $R3 + $R5
584 728 mdecorde
            IntOp $R0 $R4 - $R6
585 728 mdecorde
          ${Else}
586 728 mdecorde
            StrCpy $R0 $R5
587 728 mdecorde
          ${EndIf}
588 728 mdecorde
          ${ExitDo}
589 728 mdecorde
        ${EndIf}
590 728 mdecorde
        ;If not "StrToSearch", this could be "String" end
591 728 mdecorde
        ${If} $R5 >= $R4
592 728 mdecorde
          StrCpy $R0 ``
593 728 mdecorde
          ${ExitDo}
594 728 mdecorde
        ${EndIf}
595 728 mdecorde
        ;If not, continue the loop
596 728 mdecorde
        IntOp $R5 $R5 + 1
597 728 mdecorde
      ${Loop}
598 728 mdecorde
599 728 mdecorde
      ;Return output to user
600 728 mdecorde
      Pop $R6
601 728 mdecorde
      Pop $R5
602 728 mdecorde
      Pop $R4
603 728 mdecorde
      Pop $R3
604 728 mdecorde
      Pop $R2
605 728 mdecorde
      Exch
606 728 mdecorde
      Pop $R1
607 728 mdecorde
      Exch $R0
608 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
609 728 mdecorde
610 728 mdecorde
  !macroend
611 728 mdecorde
612 2956 mdecorde
  ############################################################################
613 2956 mdecorde
  # StrNSISToIO
614 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrNSISToIO `ResultVar|String` `Output|Text`
615 728 mdecorde
616 2956 mdecorde
  !macro STRFUNC_CALL_StrNSISToIO un ResultVar String
617 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
618 2956 mdecorde
    !echo `${U+24}{${un}StrNSISToIO} "${ResultVar}" "${String}"`
619 2956 mdecorde
    !verbose 2
620 2956 mdecorde
    Push `${String}`
621 2956 mdecorde
    !insertmacro STRFUNC_CALL StrNSISToIO "${un}"
622 2956 mdecorde
    Pop ${ResultVar}
623 2956 mdecorde
    !verbose pop
624 2956 mdecorde
  !macroend
625 728 mdecorde
626 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrNSISToIO
627 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 "bluenet" - Based on functions by Amir Szekely, Joost Verburg, Dave Laundon and Diego Pedroso`
628 2956 mdecorde
629 728 mdecorde
    /*After this point:
630 728 mdecorde
      ------------------------------------------
631 728 mdecorde
       $R0 = String (input/output)
632 728 mdecorde
       $R1 = StartCharPos (temp)
633 728 mdecorde
       $R2 = StrLen (temp)
634 728 mdecorde
       $R3 = TempStr (temp)
635 728 mdecorde
       $R4 = TempRepStr (temp)*/
636 728 mdecorde
637 728 mdecorde
      ;Get input from user
638 728 mdecorde
      Exch $R0
639 728 mdecorde
      Push $R1
640 728 mdecorde
      Push $R2
641 728 mdecorde
      Push $R3
642 728 mdecorde
      Push $R4
643 728 mdecorde
644 728 mdecorde
      ;Get "String" length
645 728 mdecorde
      StrLen $R2 $R0
646 728 mdecorde
647 728 mdecorde
      ;Loop until "String" end is reached
648 728 mdecorde
      ${For} $R1 0 $R2
649 728 mdecorde
        ;Get the next "String" character
650 728 mdecorde
        StrCpy $R3 $R0 1 $R1
651 728 mdecorde
652 728 mdecorde
        ;Detect if current character is:
653 728 mdecorde
        ${If} $R3 == "$\r" ;Back-slash
654 728 mdecorde
          StrCpy $R4 "\r"
655 728 mdecorde
        ${ElseIf} $R3 == "$\n" ;Carriage return
656 728 mdecorde
          StrCpy $R4 "\n"
657 728 mdecorde
        ${ElseIf} $R3 == "$\t" ;Line feed
658 728 mdecorde
          StrCpy $R4 "\t"
659 728 mdecorde
        ${ElseIf} $R3 == "\" ;Tab
660 728 mdecorde
          StrCpy $R4 "\\"
661 728 mdecorde
        ${Else} ;Anything else
662 728 mdecorde
          StrCpy $R4 ""
663 728 mdecorde
        ${EndIf}
664 728 mdecorde
665 728 mdecorde
        ;Detect if "TempRepStr" is not empty
666 728 mdecorde
        ${If} $R4 != ""
667 728 mdecorde
          ;Replace the old character with the new ones
668 728 mdecorde
          StrCpy $R3 $R0 $R1
669 728 mdecorde
          IntOp $R1 $R1 + 1
670 728 mdecorde
          StrCpy $R0 $R0 "" $R1
671 728 mdecorde
          StrCpy $R0 "$R3$R4$R0"
672 728 mdecorde
          IntOp $R2 $R2 + 1 ;Increase "StrLen"
673 728 mdecorde
        ${EndIf}
674 728 mdecorde
      ${Next}
675 728 mdecorde
676 728 mdecorde
      ;Return output to user
677 728 mdecorde
      Pop $R4
678 728 mdecorde
      Pop $R3
679 728 mdecorde
      Pop $R2
680 728 mdecorde
      Pop $R1
681 728 mdecorde
      Exch $R0
682 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
683 728 mdecorde
  !macroend
684 728 mdecorde
685 2956 mdecorde
  ############################################################################
686 2956 mdecorde
  # StrRep
687 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrRep `ResultVar|String|StrToReplace|ReplacementString` `Output|Text|Text|Text`
688 728 mdecorde
689 2956 mdecorde
  !macro STRFUNC_CALL_StrRep un ResultVar String StringToReplace ReplacementString
690 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
691 2956 mdecorde
    !echo `${U+24}{${un}StrRep} "${ResultVar}" "${String}" "${StringToReplace}" "${ReplacementString}"`
692 2956 mdecorde
    !verbose 2
693 2956 mdecorde
    Push `${String}`
694 2956 mdecorde
    Push `${StringToReplace}`
695 2956 mdecorde
    Push `${ReplacementString}`
696 2956 mdecorde
    !insertmacro STRFUNC_CALL StrRep "${un}"
697 2956 mdecorde
    Pop ${ResultVar}
698 2956 mdecorde
    !verbose pop
699 2956 mdecorde
  !macroend
700 728 mdecorde
701 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrRep
702 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Hendri Adriaens`
703 2956 mdecorde
704 728 mdecorde
    /*After this point:
705 728 mdecorde
      ------------------------------------------
706 728 mdecorde
       $R0 = ReplacementString (input)
707 728 mdecorde
       $R1 = StrToSearch (input)
708 728 mdecorde
       $R2 = String (input)
709 728 mdecorde
       $R3 = RepStrLen (temp)
710 728 mdecorde
       $R4 = StrToSearchLen (temp)
711 728 mdecorde
       $R5 = StrLen (temp)
712 728 mdecorde
       $R6 = StartCharPos (temp)
713 728 mdecorde
       $R7 = TempStrL (temp)
714 728 mdecorde
       $R8 = TempStrR (temp)*/
715 728 mdecorde
716 728 mdecorde
      ;Get input from user
717 728 mdecorde
      Exch $R0
718 728 mdecorde
      Exch
719 728 mdecorde
      Exch $R1
720 728 mdecorde
      Exch
721 728 mdecorde
      Exch 2
722 728 mdecorde
      Exch $R2
723 728 mdecorde
      Push $R3
724 728 mdecorde
      Push $R4
725 728 mdecorde
      Push $R5
726 728 mdecorde
      Push $R6
727 728 mdecorde
      Push $R7
728 728 mdecorde
      Push $R8
729 728 mdecorde
730 728 mdecorde
      ;Return "String" if "StrToSearch" is ""
731 728 mdecorde
      ${IfThen} $R1 == "" ${|} Goto Done ${|}
732 728 mdecorde
733 728 mdecorde
      ;Get "ReplacementString", "String" and "StrToSearch" length
734 728 mdecorde
      StrLen $R3 $R0
735 728 mdecorde
      StrLen $R4 $R1
736 728 mdecorde
      StrLen $R5 $R2
737 728 mdecorde
      ;Start "StartCharPos" counter
738 728 mdecorde
      StrCpy $R6 0
739 728 mdecorde
740 728 mdecorde
      ;Loop until "StrToSearch" is found or "String" reaches its end
741 728 mdecorde
      ${Do}
742 728 mdecorde
        ;Remove everything before and after the searched part ("TempStrL")
743 728 mdecorde
        StrCpy $R7 $R2 $R4 $R6
744 728 mdecorde
745 728 mdecorde
        ;Compare "TempStrL" with "StrToSearch"
746 728 mdecorde
        ${If} $R7 == $R1
747 728 mdecorde
          ;Split "String" to replace the string wanted
748 728 mdecorde
          StrCpy $R7 $R2 $R6 ;TempStrL
749 728 mdecorde
750 728 mdecorde
          ;Calc: "StartCharPos" + "StrToSearchLen" = EndCharPos
751 728 mdecorde
          IntOp $R8 $R6 + $R4
752 728 mdecorde
753 728 mdecorde
          StrCpy $R8 $R2 "" $R8 ;TempStrR
754 728 mdecorde
755 728 mdecorde
          ;Insert the new string between the two separated parts of "String"
756 728 mdecorde
          StrCpy $R2 $R7$R0$R8
757 728 mdecorde
          ;Now calculate the new "StrLen" and "StartCharPos"
758 728 mdecorde
          StrLen $R5 $R2
759 728 mdecorde
          IntOp $R6 $R6 + $R3
760 728 mdecorde
          ${Continue}
761 728 mdecorde
        ${EndIf}
762 728 mdecorde
763 728 mdecorde
        ;If not "StrToSearch", this could be "String" end
764 728 mdecorde
        ${IfThen} $R6 >= $R5 ${|} ${ExitDo} ${|}
765 728 mdecorde
        ;If not, continue the loop
766 728 mdecorde
        IntOp $R6 $R6 + 1
767 728 mdecorde
      ${Loop}
768 728 mdecorde
769 728 mdecorde
      Done:
770 728 mdecorde
771 728 mdecorde
    /*After this point:
772 728 mdecorde
      ------------------------------------------
773 728 mdecorde
       $R0 = OutVar (output)*/
774 728 mdecorde
775 728 mdecorde
      ;Return output to user
776 728 mdecorde
      StrCpy $R0 $R2
777 728 mdecorde
      Pop $R8
778 728 mdecorde
      Pop $R7
779 728 mdecorde
      Pop $R6
780 728 mdecorde
      Pop $R5
781 728 mdecorde
      Pop $R4
782 728 mdecorde
      Pop $R3
783 728 mdecorde
      Pop $R2
784 728 mdecorde
      Pop $R1
785 728 mdecorde
      Exch $R0
786 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
787 728 mdecorde
788 728 mdecorde
  !macroend
789 728 mdecorde
790 2956 mdecorde
  ############################################################################
791 2956 mdecorde
  # StrSort
792 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrSort `ResultVar|String|CenterStr|LeftStr|RightStr|IncludeLeftStr|IncludeCenterStr|IncludeRightStr` `Output|Text|Text|Text|Text|Option 1 0|Option 1 0|Option 1 0`
793 728 mdecorde
794 2956 mdecorde
  !macro STRFUNC_CALL_StrSort un ResultVar String CenterStr LeftStr RightStr IncludeCenterStr IncludeLeftStr IncludeRightStr
795 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
796 2956 mdecorde
    !echo `${U+24}{${un}StrSort} "${ResultVar}" "${String}" "${CenterStr}" "${LeftStr}" "${RightStr}" "${IncludeCenterStr}" "${IncludeLeftStr}" "${IncludeRightStr}"`
797 2956 mdecorde
    !verbose 2
798 2956 mdecorde
    Push `${String}`
799 2956 mdecorde
    Push `${CenterStr}`
800 2956 mdecorde
    Push `${LeftStr}`
801 2956 mdecorde
    Push `${RightStr}`
802 2956 mdecorde
    Push `${IncludeCenterStr}`
803 2956 mdecorde
    Push `${IncludeLeftStr}`
804 2956 mdecorde
    Push `${IncludeRightStr}`
805 2956 mdecorde
    !insertmacro STRFUNC_CALL StrSort "${un}"
806 2956 mdecorde
    Pop ${ResultVar}
807 2956 mdecorde
    !verbose pop
808 2956 mdecorde
  !macroend
809 728 mdecorde
810 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrSort
811 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Stuart Welch`
812 2956 mdecorde
813 728 mdecorde
    /*After this point:
814 728 mdecorde
      ------------------------------------------
815 728 mdecorde
       $R0 = String (input)
816 728 mdecorde
       $R1 = LeftStr (input)
817 728 mdecorde
       $R2 = CenterStr (input)
818 728 mdecorde
       $R3 = RightStr (input)
819 728 mdecorde
       $R4 = IncludeLeftStr (input)
820 728 mdecorde
       $R5 = IncludeCenterStr (input)
821 728 mdecorde
       $R6 = IncludeRightStr (input)
822 728 mdecorde
823 728 mdecorde
       $0 = StrLen (temp)
824 728 mdecorde
       $1 = LeftStrLen (temp)
825 728 mdecorde
       $2 = CenterStrLen (temp)
826 728 mdecorde
       $3 = RightStrLen (temp)
827 728 mdecorde
       $4 = StartPos (temp)
828 728 mdecorde
       $5 = EndPos (temp)
829 728 mdecorde
       $6 = StartCharPos (temp)
830 728 mdecorde
       $7 = EndCharPos (temp)
831 728 mdecorde
       $8 = TempStr (temp)*/
832 728 mdecorde
833 728 mdecorde
      ;Get input from user
834 728 mdecorde
      Exch $R6
835 728 mdecorde
      Exch
836 728 mdecorde
      Exch $R5
837 728 mdecorde
      Exch
838 728 mdecorde
      Exch 2
839 728 mdecorde
      Exch $R4
840 728 mdecorde
      Exch 2
841 728 mdecorde
      Exch 3
842 728 mdecorde
      Exch $R3
843 728 mdecorde
      Exch 3
844 728 mdecorde
      Exch 4
845 728 mdecorde
      Exch $R2
846 728 mdecorde
      Exch 4
847 728 mdecorde
      Exch 5
848 728 mdecorde
      Exch $R1
849 728 mdecorde
      Exch 5
850 728 mdecorde
      Exch 6
851 728 mdecorde
      Exch $R0
852 728 mdecorde
      Exch 6
853 728 mdecorde
      Push $0
854 728 mdecorde
      Push $1
855 728 mdecorde
      Push $2
856 728 mdecorde
      Push $3
857 728 mdecorde
      Push $4
858 728 mdecorde
      Push $5
859 728 mdecorde
      Push $6
860 728 mdecorde
      Push $7
861 728 mdecorde
      Push $8
862 728 mdecorde
863 728 mdecorde
      ;Parameter defaults
864 728 mdecorde
      ${IfThen} $R4 == `` ${|} StrCpy $R4 `1` ${|}
865 728 mdecorde
      ${IfThen} $R5 == `` ${|} StrCpy $R5 `1` ${|}
866 728 mdecorde
      ${IfThen} $R6 == `` ${|} StrCpy $R6 `1` ${|}
867 728 mdecorde
868 728 mdecorde
      ;Get "String", "CenterStr", "LeftStr" and "RightStr" length
869 728 mdecorde
      StrLen $0 $R0
870 728 mdecorde
      StrLen $1 $R1
871 728 mdecorde
      StrLen $2 $R2
872 728 mdecorde
      StrLen $3 $R3
873 728 mdecorde
      ;Start "StartCharPos" counter
874 728 mdecorde
      StrCpy $6 0
875 728 mdecorde
      ;Start "EndCharPos" counter based on "CenterStr" length
876 728 mdecorde
      IntOp $7 $6 + $2
877 728 mdecorde
878 728 mdecorde
      ;Loop until "CenterStr" is found or "String" reaches its end
879 728 mdecorde
      ${Do}
880 728 mdecorde
        ;Remove everything before and after the searched part ("TempStr")
881 728 mdecorde
        StrCpy $8 $R0 $2 $6
882 728 mdecorde
883 728 mdecorde
        ;Compare "TempStr" with "CenterStr"
884 728 mdecorde
        ${IfThen} $8 == $R2 ${|} ${ExitDo} ${|}
885 728 mdecorde
        ;If not, this could be "String" end
886 728 mdecorde
        ${IfThen} $7 >= $0 ${|} Goto Done ${|}
887 728 mdecorde
        ;If not, continue the loop
888 728 mdecorde
        IntOp $6 $6 + 1
889 728 mdecorde
        IntOp $7 $7 + 1
890 728 mdecorde
      ${Loop}
891 728 mdecorde
892 728 mdecorde
      # "CenterStr" was found
893 728 mdecorde
894 728 mdecorde
      ;Remove "CenterStr" from "String" if the user wants
895 728 mdecorde
      ${If} $R5 = ${FALSE}
896 728 mdecorde
        StrCpy $8 $R0 $6
897 728 mdecorde
        StrCpy $R0 $R0 `` $7
898 728 mdecorde
        StrCpy $R0 $8$R0
899 728 mdecorde
      ${EndIf}
900 728 mdecorde
901 728 mdecorde
      ;"StartPos" and "EndPos" will record "CenterStr" coordinates for now
902 728 mdecorde
      StrCpy $4 $6
903 728 mdecorde
      StrCpy $5 $7
904 728 mdecorde
      ;"StartCharPos" and "EndCharPos" should be before "CenterStr"
905 728 mdecorde
      IntOp $6 $6 - $1
906 728 mdecorde
      IntOp $7 $6 + $1
907 728 mdecorde
908 728 mdecorde
      ;Loop until "LeftStr" is found or "String" reaches its start
909 728 mdecorde
      ${Do}
910 728 mdecorde
        ;Remove everything before and after the searched part ("TempStr")
911 728 mdecorde
        StrCpy $8 $R0 $1 $6
912 728 mdecorde
913 728 mdecorde
        ;If "LeftStr" is empty
914 728 mdecorde
        ${If} $R1 == ``
915 728 mdecorde
          StrCpy $6 0
916 728 mdecorde
          StrCpy $7 0
917 728 mdecorde
          ${ExitDo}
918 728 mdecorde
        ${EndIf}
919 728 mdecorde
920 728 mdecorde
        ;Compare "TempStr" with "LeftStr"
921 728 mdecorde
        ${IfThen} $8 == $R1 ${|} ${ExitDo} ${|}
922 728 mdecorde
        ;If not, this could be "String" start
923 728 mdecorde
        ${IfThen} $6 <= 0 ${|} ${ExitDo} ${|}
924 728 mdecorde
        ;If not, continue the loop
925 728 mdecorde
        IntOp $6 $6 - 1
926 728 mdecorde
        IntOp $7 $7 - 1
927 728 mdecorde
      ${Loop}
928 728 mdecorde
929 728 mdecorde
      # "LeftStr" is found or "String" start was reached
930 728 mdecorde
931 728 mdecorde
      ;Remove "LeftStr" from "String" if the user wants
932 728 mdecorde
      ${If} $R4 = ${FALSE}
933 728 mdecorde
        IntOp $6 $6 + $1
934 728 mdecorde
      ${EndIf}
935 728 mdecorde
936 728 mdecorde
      ;Record "LeftStr" first character position on "TempStr" (temporarily)
937 728 mdecorde
      StrCpy $8 $6
938 728 mdecorde
939 728 mdecorde
      ;"StartCharPos" and "EndCharPos" should be after "CenterStr"
940 728 mdecorde
      ${If} $R5 = ${FALSE}
941 728 mdecorde
        StrCpy $6 $4
942 728 mdecorde
      ${Else}
943 728 mdecorde
        IntOp $6 $4 + $2
944 728 mdecorde
      ${EndIf}
945 728 mdecorde
      IntOp $7 $6 + $3
946 728 mdecorde
947 728 mdecorde
      ;Record "LeftStr" first character position on "StartPos"
948 728 mdecorde
      StrCpy $4 $8
949 728 mdecorde
950 728 mdecorde
      ;Loop until "RightStr" is found or "String" reaches its end
951 728 mdecorde
      ${Do}
952 728 mdecorde
        ;Remove everything before and after the searched part ("TempStr")
953 728 mdecorde
        StrCpy $8 $R0 $3 $6
954 728 mdecorde
955 728 mdecorde
        ;If "RightStr" is empty
956 728 mdecorde
        ${If} $R3 == ``
957 728 mdecorde
          StrCpy $6 $0
958 728 mdecorde
          StrCpy $7 $0
959 728 mdecorde
          ${ExitDo}
960 728 mdecorde
        ${EndIf}
961 728 mdecorde
962 728 mdecorde
        ;Compare "TempStr" with "RightStr"
963 728 mdecorde
        ${IfThen} $8 == $R3 ${|} ${ExitDo} ${|}
964 728 mdecorde
        ;If not, this could be "String" end
965 728 mdecorde
        ${IfThen} $7 >= $0 ${|} ${ExitDo} ${|}
966 728 mdecorde
        ;If not, continue the loop
967 728 mdecorde
        IntOp $6 $6 + 1
968 728 mdecorde
        IntOp $7 $7 + 1
969 728 mdecorde
      ${Loop}
970 728 mdecorde
971 728 mdecorde
      ;Remove "RightStr" from "String" if the user wants
972 728 mdecorde
      ${If} $R6 = ${FALSE}
973 728 mdecorde
        IntOp $7 $7 - $3
974 728 mdecorde
      ${EndIf}
975 728 mdecorde
976 728 mdecorde
      ;Record "RightStr" last character position on "StartPos"
977 728 mdecorde
      StrCpy $5 $7
978 728 mdecorde
979 728 mdecorde
      ;As the positionment is relative...
980 728 mdecorde
      IntOp $5 $5 - $4
981 728 mdecorde
982 728 mdecorde
      ;Write the string and finish the job
983 728 mdecorde
      StrCpy $R0 $R0 $5 $4
984 728 mdecorde
      Goto +2
985 728 mdecorde
986 728 mdecorde
      Done:
987 728 mdecorde
      StrCpy $R0 ``
988 728 mdecorde
989 728 mdecorde
    /*After this point:
990 728 mdecorde
      ------------------------------------------
991 728 mdecorde
       $R0 = OutVar (output)*/
992 728 mdecorde
993 728 mdecorde
      ;Return output to user
994 728 mdecorde
      Pop $8
995 728 mdecorde
      Pop $7
996 728 mdecorde
      Pop $6
997 728 mdecorde
      Pop $5
998 728 mdecorde
      Pop $4
999 728 mdecorde
      Pop $3
1000 728 mdecorde
      Pop $2
1001 728 mdecorde
      Pop $1
1002 728 mdecorde
      Pop $0
1003 728 mdecorde
      Pop $R6
1004 728 mdecorde
      Pop $R5
1005 728 mdecorde
      Pop $R4
1006 728 mdecorde
      Pop $R3
1007 728 mdecorde
      Pop $R2
1008 728 mdecorde
      Pop $R1
1009 728 mdecorde
      Exch $R0
1010 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
1011 728 mdecorde
1012 728 mdecorde
  !macroend
1013 728 mdecorde
1014 2956 mdecorde
  ############################################################################
1015 2956 mdecorde
  # StrStr
1016 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrStr `ResultVar|String|StrToSearchFor` `Output|Text|Text`
1017 728 mdecorde
1018 2956 mdecorde
  !macro STRFUNC_CALL_StrStr un ResultVar String StrToSearchFor
1019 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
1020 2956 mdecorde
    !echo `${U+24}{${un}StrStr} "${ResultVar}" "${String}" "${StrToSearchFor}"`
1021 2956 mdecorde
    !verbose 2
1022 2956 mdecorde
    Push `${String}`
1023 2956 mdecorde
    Push `${StrToSearchFor}`
1024 2956 mdecorde
    !insertmacro STRFUNC_CALL StrStr "${un}"
1025 2956 mdecorde
    Pop ${ResultVar}
1026 2956 mdecorde
    !verbose pop
1027 2956 mdecorde
  !macroend
1028 2956 mdecorde
1029 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrStr
1030 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Ximon Eighteen`
1031 2956 mdecorde
1032 728 mdecorde
    /*After this point:
1033 728 mdecorde
      ------------------------------------------
1034 728 mdecorde
       $R0 = StrToSearch (input)
1035 728 mdecorde
       $R1 = String (input)
1036 728 mdecorde
       $R2 = StrToSearchLen (temp)
1037 728 mdecorde
       $R3 = StrLen (temp)
1038 728 mdecorde
       $R4 = StartCharPos (temp)
1039 728 mdecorde
       $R5 = TempStr (temp)*/
1040 728 mdecorde
1041 728 mdecorde
      ;Get input from user
1042 728 mdecorde
      Exch $R0
1043 728 mdecorde
      Exch
1044 728 mdecorde
      Exch $R1
1045 728 mdecorde
      Push $R2
1046 728 mdecorde
      Push $R3
1047 728 mdecorde
      Push $R4
1048 728 mdecorde
      Push $R5
1049 728 mdecorde
1050 728 mdecorde
      ;Get "String" and "StrToSearch" length
1051 728 mdecorde
      StrLen $R2 $R0
1052 728 mdecorde
      StrLen $R3 $R1
1053 728 mdecorde
      ;Start "StartCharPos" counter
1054 728 mdecorde
      StrCpy $R4 0
1055 728 mdecorde
1056 728 mdecorde
      ;Loop until "StrToSearch" is found or "String" reaches its end
1057 728 mdecorde
      ${Do}
1058 728 mdecorde
        ;Remove everything before and after the searched part ("TempStr")
1059 728 mdecorde
        StrCpy $R5 $R1 $R2 $R4
1060 728 mdecorde
1061 728 mdecorde
        ;Compare "TempStr" with "StrToSearch"
1062 728 mdecorde
        ${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|}
1063 728 mdecorde
        ;If not "StrToSearch", this could be "String" end
1064 728 mdecorde
        ${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|}
1065 728 mdecorde
        ;If not, continue the loop
1066 728 mdecorde
        IntOp $R4 $R4 + 1
1067 728 mdecorde
      ${Loop}
1068 728 mdecorde
1069 728 mdecorde
    /*After this point:
1070 728 mdecorde
      ------------------------------------------
1071 728 mdecorde
       $R0 = OutVar (output)*/
1072 728 mdecorde
1073 728 mdecorde
      ;Remove part before "StrToSearch" on "String" (if there has one)
1074 728 mdecorde
      StrCpy $R0 $R1 `` $R4
1075 728 mdecorde
1076 728 mdecorde
      ;Return output to user
1077 728 mdecorde
      Pop $R5
1078 728 mdecorde
      Pop $R4
1079 728 mdecorde
      Pop $R3
1080 728 mdecorde
      Pop $R2
1081 728 mdecorde
      Pop $R1
1082 728 mdecorde
      Exch $R0
1083 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
1084 728 mdecorde
1085 728 mdecorde
  !macroend
1086 728 mdecorde
1087 2956 mdecorde
  ############################################################################
1088 2956 mdecorde
  # StrStrAdv
1089 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrStrAdv `ResultVar|String|StrToSearchFor|SearchDirection|ResultStrDirection|DisplayStrToSearch|Loops|CaseSensitive` `Output|Text|Text|Option > <|Option > <|Option 1 0|Text|Option 0 1`
1090 728 mdecorde
1091 2956 mdecorde
  !macro STRFUNC_CALL_StrStrAdv un ResultVar String StrToSearchFor SearchDirection ResultStrDirection DisplayStrToSearch Loops CaseSensitive
1092 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
1093 2956 mdecorde
    !echo `${U+24}{${un}StrStrAdv} "${ResultVar}" "${String}" "${StrToSearchFor}" "${SearchDirection}" "${ResultStrDirection}" "${DisplayStrToSearch}" "${Loops}" "${CaseSensitive}"`
1094 2956 mdecorde
    !verbose 2
1095 2956 mdecorde
    Push `${String}`
1096 2956 mdecorde
    Push `${StrToSearchFor}`
1097 2956 mdecorde
    Push `${SearchDirection}`
1098 2956 mdecorde
    Push `${ResultStrDirection}`
1099 2956 mdecorde
    Push `${DisplayStrToSearch}`
1100 2956 mdecorde
    Push `${Loops}`
1101 2956 mdecorde
    Push `${CaseSensitive}`
1102 2956 mdecorde
    !insertmacro STRFUNC_CALL StrStrAdv "${un}"
1103 2956 mdecorde
    Pop ${ResultVar}
1104 2956 mdecorde
    !verbose pop
1105 2956 mdecorde
  !macroend
1106 728 mdecorde
1107 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrStrAdv
1108 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2003-2004 Diego Pedroso`
1109 2956 mdecorde
1110 728 mdecorde
    /*After this point:
1111 728 mdecorde
      ------------------------------------------
1112 728 mdecorde
       $0 = String (input)
1113 728 mdecorde
       $1 = StringToSearch (input)
1114 728 mdecorde
       $2 = DirectionOfSearch (input)
1115 728 mdecorde
       $3 = DirectionOfReturn (input)
1116 728 mdecorde
       $4 = ShowStrToSearch (input)
1117 728 mdecorde
       $5 = NumLoops (input)
1118 728 mdecorde
       $6 = CaseSensitive (input)
1119 728 mdecorde
       $7 = StringLength (temp)
1120 728 mdecorde
       $8 = StrToSearchLength (temp)
1121 728 mdecorde
       $9 = CurrentLoop (temp)
1122 728 mdecorde
       $R0 = EndCharPos (temp)
1123 728 mdecorde
       $R1 = StartCharPos (temp)
1124 728 mdecorde
       $R2 = OutVar (output)
1125 728 mdecorde
       $R3 = Temp (temp)*/
1126 728 mdecorde
1127 728 mdecorde
      ;Get input from user
1128 728 mdecorde
1129 728 mdecorde
      Exch $6
1130 728 mdecorde
      Exch
1131 728 mdecorde
      Exch $5
1132 728 mdecorde
      Exch
1133 728 mdecorde
      Exch 2
1134 728 mdecorde
      Exch $4
1135 728 mdecorde
      Exch 2
1136 728 mdecorde
      Exch 3
1137 728 mdecorde
      Exch $3
1138 728 mdecorde
      Exch 3
1139 728 mdecorde
      Exch 4
1140 728 mdecorde
      Exch $2
1141 728 mdecorde
      Exch 4
1142 728 mdecorde
      Exch 5
1143 728 mdecorde
      Exch $1
1144 728 mdecorde
      Exch 5
1145 728 mdecorde
      Exch 6
1146 728 mdecorde
      Exch $0
1147 728 mdecorde
      Exch 6
1148 728 mdecorde
      Push $7
1149 728 mdecorde
      Push $8
1150 728 mdecorde
      Push $9
1151 728 mdecorde
      Push $R3
1152 728 mdecorde
      Push $R2
1153 728 mdecorde
      Push $R1
1154 728 mdecorde
      Push $R0
1155 728 mdecorde
1156 728 mdecorde
      ; Clean $R0-$R3 variables
1157 728 mdecorde
      StrCpy $R0 ""
1158 728 mdecorde
      StrCpy $R1 ""
1159 728 mdecorde
      StrCpy $R2 ""
1160 728 mdecorde
      StrCpy $R3 ""
1161 728 mdecorde
1162 728 mdecorde
      ; Verify if we have the correct values on the variables
1163 728 mdecorde
      ${If} $0 == ``
1164 728 mdecorde
        SetErrors ;AdvStrStr_StrToSearch not found
1165 728 mdecorde
        Goto AdvStrStr_End
1166 728 mdecorde
      ${EndIf}
1167 728 mdecorde
1168 728 mdecorde
      ${If} $1 == ``
1169 728 mdecorde
        SetErrors ;No text to search
1170 728 mdecorde
        Goto AdvStrStr_End
1171 728 mdecorde
      ${EndIf}
1172 728 mdecorde
1173 728 mdecorde
      ${If} $2 != <
1174 728 mdecorde
        StrCpy $2 >
1175 728 mdecorde
      ${EndIf}
1176 728 mdecorde
1177 728 mdecorde
      ${If} $3 != <
1178 728 mdecorde
        StrCpy $3 >
1179 728 mdecorde
      ${EndIf}
1180 728 mdecorde
1181 728 mdecorde
      ${If} $4 <> 0
1182 728 mdecorde
        StrCpy $4 1
1183 728 mdecorde
      ${EndIf}
1184 728 mdecorde
1185 728 mdecorde
      ${If} $5 <= 0
1186 728 mdecorde
        StrCpy $5 0
1187 728 mdecorde
      ${EndIf}
1188 728 mdecorde
1189 728 mdecorde
      ${If} $6 <> 1
1190 728 mdecorde
        StrCpy $6 0
1191 728 mdecorde
      ${EndIf}
1192 728 mdecorde
1193 728 mdecorde
      ; Find "AdvStrStr_String" length
1194 728 mdecorde
      StrLen $7 $0
1195 728 mdecorde
1196 728 mdecorde
      ; Then find "AdvStrStr_StrToSearch" length
1197 728 mdecorde
      StrLen $8 $1
1198 728 mdecorde
1199 728 mdecorde
      ; Now set up basic variables
1200 728 mdecorde
1201 728 mdecorde
      ${If} $2 == <
1202 728 mdecorde
        IntOp $R1 $7 - $8
1203 728 mdecorde
        StrCpy $R2 $7
1204 728 mdecorde
      ${Else}
1205 728 mdecorde
        StrCpy $R1 0
1206 728 mdecorde
        StrCpy $R2 $8
1207 728 mdecorde
      ${EndIf}
1208 728 mdecorde
1209 728 mdecorde
      StrCpy $9 0 ; First loop
1210 728 mdecorde
1211 728 mdecorde
      ;Let's begin the search
1212 728 mdecorde
1213 728 mdecorde
      ${Do}
1214 728 mdecorde
        ; Step 1: If the starting or ending numbers are negative
1215 728 mdecorde
        ;         or more than AdvStrStr_StringLen, we return
1216 728 mdecorde
        ;         error
1217 728 mdecorde
1218 728 mdecorde
        ${If} $R1 < 0
1219 728 mdecorde
          StrCpy $R1 ``
1220 728 mdecorde
          StrCpy $R2 ``
1221 728 mdecorde
          StrCpy $R3 ``
1222 728 mdecorde
          SetErrors ;AdvStrStr_StrToSearch not found
1223 728 mdecorde
          Goto AdvStrStr_End
1224 728 mdecorde
        ${ElseIf} $R2 > $7
1225 728 mdecorde
          StrCpy $R1 ``
1226 728 mdecorde
          StrCpy $R2 ``
1227 728 mdecorde
          StrCpy $R3 ``
1228 728 mdecorde
          SetErrors ;AdvStrStr_StrToSearch not found
1229 728 mdecorde
          Goto AdvStrStr_End
1230 728 mdecorde
        ${EndIf}
1231 728 mdecorde
1232 728 mdecorde
        ; Step 2: Start the search depending on
1233 728 mdecorde
        ;         AdvStrStr_DirectionOfSearch. Chop down not needed
1234 728 mdecorde
        ;         characters.
1235 728 mdecorde
1236 728 mdecorde
        ${If} $R1 <> 0
1237 728 mdecorde
          StrCpy $R3 $0 `` $R1
1238 728 mdecorde
        ${EndIf}
1239 728 mdecorde
1240 728 mdecorde
        ${If} $R2 <> $7
1241 728 mdecorde
          ${If} $R1 = 0
1242 728 mdecorde
            StrCpy $R3 $0 $8
1243 728 mdecorde
          ${Else}
1244 728 mdecorde
            StrCpy $R3 $R3 $8
1245 728 mdecorde
          ${EndIf}
1246 728 mdecorde
        ${EndIf}
1247 728 mdecorde
1248 728 mdecorde
        ; Step 3: Make sure that's the string we want
1249 728 mdecorde
1250 728 mdecorde
        ; Case-Sensitive Support <- Use "AdvStrStr_Temp"
1251 728 mdecorde
        ; variable because it won't be used anymore
1252 728 mdecorde
1253 728 mdecorde
        ${If} $6 == 1
1254 2956 mdecorde
          System::Call `kernel32::lstrcmp(ts, ts) i.s` `$R3` `$1`
1255 728 mdecorde
          Pop $R3
1256 728 mdecorde
          ${If} $R3 = 0
1257 728 mdecorde
            StrCpy $R3 1 ; Continue
1258 728 mdecorde
          ${Else}
1259 728 mdecorde
            StrCpy $R3 0 ; Break
1260 728 mdecorde
          ${EndIf}
1261 728 mdecorde
        ${Else}
1262 728 mdecorde
          ${If} $R3 == $1
1263 728 mdecorde
            StrCpy $R3 1 ; Continue
1264 728 mdecorde
          ${Else}
1265 728 mdecorde
            StrCpy $R3 0 ; Break
1266 728 mdecorde
          ${EndIf}
1267 728 mdecorde
        ${EndIf}
1268 728 mdecorde
1269 728 mdecorde
        ; After the comparasion, confirm that it is the
1270 728 mdecorde
        ; value we want.
1271 728 mdecorde
1272 728 mdecorde
        ${If} $R3 = 1
1273 728 mdecorde
1274 728 mdecorde
          ;We found it, return except if the user has set up to
1275 728 mdecorde
          ;search for another one:
1276 728 mdecorde
          ${If} $9 >= $5
1277 728 mdecorde
1278 728 mdecorde
            ;Now, let's see if the user wants
1279 728 mdecorde
            ;AdvStrStr_StrToSearch to appear:
1280 728 mdecorde
            ${If} $4 == 0
1281 728 mdecorde
              ;Return depends on AdvStrStr_DirectionOfReturn
1282 728 mdecorde
              ${If} $3 == <
1283 728 mdecorde
                ; RTL
1284 728 mdecorde
                StrCpy $R0 $0 $R1
1285 728 mdecorde
              ${Else}
1286 728 mdecorde
                ; LTR
1287 728 mdecorde
                StrCpy $R0 $0 `` $R2
1288 728 mdecorde
              ${EndIf}
1289 728 mdecorde
              ${Break}
1290 728 mdecorde
            ${Else}
1291 728 mdecorde
              ;Return depends on AdvStrStr_DirectionOfReturn
1292 728 mdecorde
              ${If} $3 == <
1293 728 mdecorde
                ; RTL
1294 728 mdecorde
                StrCpy $R0 $0 $R2
1295 728 mdecorde
              ${Else}
1296 728 mdecorde
                ; LTR
1297 728 mdecorde
                StrCpy $R0 $0 `` $R1
1298 728 mdecorde
              ${EndIf}
1299 728 mdecorde
              ${Break}
1300 728 mdecorde
            ${EndIf}
1301 728 mdecorde
          ${Else}
1302 728 mdecorde
            ;If the user wants to have more loops, let's do it so!
1303 728 mdecorde
            IntOp $9 $9 + 1
1304 728 mdecorde
1305 728 mdecorde
            ${If} $2 == <
1306 728 mdecorde
              IntOp $R1 $R1 - 1
1307 728 mdecorde
              IntOp $R2 $R2 - 1
1308 728 mdecorde
            ${Else}
1309 728 mdecorde
              IntOp $R1 $R1 + 1
1310 728 mdecorde
              IntOp $R2 $R2 + 1
1311 728 mdecorde
            ${EndIf}
1312 728 mdecorde
          ${EndIf}
1313 728 mdecorde
        ${Else}
1314 728 mdecorde
          ; Step 4: We didn't find it, so do steps 1 thru 3 again
1315 728 mdecorde
1316 728 mdecorde
          ${If} $2 == <
1317 728 mdecorde
            IntOp $R1 $R1 - 1
1318 728 mdecorde
            IntOp $R2 $R2 - 1
1319 728 mdecorde
          ${Else}
1320 728 mdecorde
            IntOp $R1 $R1 + 1
1321 728 mdecorde
            IntOp $R2 $R2 + 1
1322 728 mdecorde
          ${EndIf}
1323 728 mdecorde
        ${EndIf}
1324 728 mdecorde
      ${Loop}
1325 728 mdecorde
1326 728 mdecorde
      AdvStrStr_End:
1327 728 mdecorde
1328 728 mdecorde
      ;Add 1 to AdvStrStr_EndCharPos to be supportable
1329 728 mdecorde
      ;by "StrCpy"
1330 728 mdecorde
1331 728 mdecorde
      IntOp $R2 $R2 - 1
1332 728 mdecorde
1333 728 mdecorde
      ;Return output to user
1334 728 mdecorde
1335 728 mdecorde
      Exch $R0
1336 728 mdecorde
      Exch
1337 728 mdecorde
      Pop $R1
1338 728 mdecorde
      Exch
1339 728 mdecorde
      Pop $R2
1340 728 mdecorde
      Exch
1341 728 mdecorde
      Pop $R3
1342 728 mdecorde
      Exch
1343 728 mdecorde
      Pop $9
1344 728 mdecorde
      Exch
1345 728 mdecorde
      Pop $8
1346 728 mdecorde
      Exch
1347 728 mdecorde
      Pop $7
1348 728 mdecorde
      Exch
1349 728 mdecorde
      Pop $6
1350 728 mdecorde
      Exch
1351 728 mdecorde
      Pop $5
1352 728 mdecorde
      Exch
1353 728 mdecorde
      Pop $4
1354 728 mdecorde
      Exch
1355 728 mdecorde
      Pop $3
1356 728 mdecorde
      Exch
1357 728 mdecorde
      Pop $2
1358 728 mdecorde
      Exch
1359 728 mdecorde
      Pop $1
1360 728 mdecorde
      Exch
1361 728 mdecorde
      Pop $0
1362 728 mdecorde
1363 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
1364 728 mdecorde
1365 728 mdecorde
  !macroend
1366 728 mdecorde
1367 2956 mdecorde
  ############################################################################
1368 2956 mdecorde
  # StrTok
1369 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrTok `ResultVar|String|Separators|ResultPart|SkipEmptyParts` `Output|Text|Text|Mixed L|Option 1 0`
1370 728 mdecorde
1371 2956 mdecorde
  !macro STRFUNC_CALL_StrTok un ResultVar String Separators ResultPart SkipEmptyParts
1372 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
1373 2956 mdecorde
    !echo `${U+24}{${un}StrTok} "${ResultVar}" "${String}" "${Separators}" "${ResultPart}" "${SkipEmptyParts}"`
1374 2956 mdecorde
    !verbose 2
1375 2956 mdecorde
    Push `${String}`
1376 2956 mdecorde
    Push `${Separators}`
1377 2956 mdecorde
    Push `${ResultPart}`
1378 2956 mdecorde
    Push `${SkipEmptyParts}`
1379 2956 mdecorde
    !insertmacro STRFUNC_CALL StrTok "${un}"
1380 2956 mdecorde
    Pop ${ResultVar}
1381 2956 mdecorde
    !verbose pop
1382 2956 mdecorde
  !macroend
1383 2956 mdecorde
1384 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrTok
1385 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by "bigmac666"`
1386 728 mdecorde
    /*After this point:
1387 728 mdecorde
      ------------------------------------------
1388 728 mdecorde
       $0 = SkipEmptyParts (input)
1389 728 mdecorde
       $1 = ResultPart (input)
1390 728 mdecorde
       $2 = Separators (input)
1391 728 mdecorde
       $3 = String (input)
1392 728 mdecorde
       $4 = StrToSearchLen (temp)
1393 728 mdecorde
       $5 = StrLen (temp)
1394 728 mdecorde
       $6 = StartCharPos (temp)
1395 728 mdecorde
       $7 = TempStr (temp)
1396 728 mdecorde
       $8 = CurrentLoop
1397 728 mdecorde
       $9 = CurrentSepChar
1398 728 mdecorde
       $R0 = CurrentSepCharNum
1399 728 mdecorde
       */
1400 728 mdecorde
1401 728 mdecorde
      ;Get input from user
1402 728 mdecorde
      Exch $0
1403 728 mdecorde
      Exch
1404 728 mdecorde
      Exch $1
1405 728 mdecorde
      Exch
1406 728 mdecorde
      Exch 2
1407 728 mdecorde
      Exch $2
1408 728 mdecorde
      Exch 2
1409 728 mdecorde
      Exch 3
1410 728 mdecorde
      Exch $3
1411 728 mdecorde
      Exch 3
1412 728 mdecorde
      Push $4
1413 728 mdecorde
      Push $5
1414 728 mdecorde
      Push $6
1415 728 mdecorde
      Push $7
1416 728 mdecorde
      Push $8
1417 728 mdecorde
      Push $9
1418 728 mdecorde
      Push $R0
1419 728 mdecorde
1420 728 mdecorde
      ;Parameter defaults
1421 728 mdecorde
      ${IfThen} $2 == `` ${|} StrCpy $2 `|` ${|}
1422 728 mdecorde
      ${IfThen} $1 == `` ${|} StrCpy $1 `L` ${|}
1423 728 mdecorde
      ${IfThen} $0 == `` ${|} StrCpy $0 `0` ${|}
1424 728 mdecorde
1425 728 mdecorde
      ;Get "String" and "StrToSearch" length
1426 728 mdecorde
      StrLen $4 $2
1427 728 mdecorde
      StrLen $5 $3
1428 728 mdecorde
      ;Start "StartCharPos" and "ResultPart" counters
1429 728 mdecorde
      StrCpy $6 0
1430 728 mdecorde
      StrCpy $8 -1
1431 728 mdecorde
1432 728 mdecorde
      ;Loop until "ResultPart" is met, "StrToSearch" is found or
1433 728 mdecorde
      ;"String" reaches its end
1434 728 mdecorde
      ResultPartLoop: ;"CurrentLoop" Loop
1435 728 mdecorde
1436 728 mdecorde
        ;Increase "CurrentLoop" counter
1437 728 mdecorde
        IntOp $8 $8 + 1
1438 728 mdecorde
1439 728 mdecorde
        StrSearchLoop:
1440 728 mdecorde
        ${Do} ;"String" Loop
1441 728 mdecorde
          ;Remove everything before and after the searched part ("TempStr")
1442 728 mdecorde
          StrCpy $7 $3 1 $6
1443 728 mdecorde
1444 728 mdecorde
          ;Verify if it's the "String" end
1445 728 mdecorde
          ${If} $6 >= $5
1446 728 mdecorde
            ;If "CurrentLoop" is what the user wants, remove the part
1447 728 mdecorde
            ;after "TempStr" and itself and get out of here
1448 728 mdecorde
            ${If} $8 == $1
1449 728 mdecorde
            ${OrIf} $1 == `L`
1450 728 mdecorde
              StrCpy $3 $3 $6
1451 728 mdecorde
            ${Else} ;If not, empty "String" and get out of here
1452 728 mdecorde
              StrCpy $3 ``
1453 728 mdecorde
            ${EndIf}
1454 728 mdecorde
            StrCpy $R0 `End`
1455 728 mdecorde
            ${ExitDo}
1456 728 mdecorde
          ${EndIf}
1457 728 mdecorde
1458 728 mdecorde
          ;Start "CurrentSepCharNum" counter (for "Separators" Loop)
1459 728 mdecorde
          StrCpy $R0 0
1460 728 mdecorde
1461 728 mdecorde
          ${Do} ;"Separators" Loop
1462 728 mdecorde
            ;Use one "Separators" character at a time
1463 728 mdecorde
            ${If} $R0 <> 0
1464 728 mdecorde
              StrCpy $9 $2 1 $R0
1465 728 mdecorde
            ${Else}
1466 728 mdecorde
              StrCpy $9 $2 1
1467 728 mdecorde
            ${EndIf}
1468 728 mdecorde
1469 728 mdecorde
            ;Go to the next "String" char if it's "Separators" end
1470 728 mdecorde
            ${IfThen} $R0 >= $4 ${|} ${ExitDo} ${|}
1471 728 mdecorde
1472 728 mdecorde
            ;Or, if "TempStr" equals "CurrentSepChar", then...
1473 728 mdecorde
            ${If} $7 == $9
1474 728 mdecorde
              StrCpy $7 $3 $6
1475 728 mdecorde
1476 728 mdecorde
              ;If "String" is empty because this result part doesn't
1477 728 mdecorde
              ;contain data, verify if "SkipEmptyParts" is activated,
1478 728 mdecorde
              ;so we don't return the output to user yet
1479 728 mdecorde
1480 728 mdecorde
              ${If} $7 == ``
1481 728 mdecorde
              ${AndIf} $0 = ${TRUE}
1482 728 mdecorde
                IntOp $6 $6 + 1
1483 728 mdecorde
                StrCpy $3 $3 `` $6
1484 728 mdecorde
                StrCpy $6 0
1485 728 mdecorde
                Goto StrSearchLoop
1486 728 mdecorde
              ${ElseIf} $8 == $1
1487 728 mdecorde
                StrCpy $3 $3 $6
1488 728 mdecorde
                StrCpy $R0 "End"
1489 728 mdecorde
                ${ExitDo}
1490 728 mdecorde
              ${EndIf} ;If not, go to the next result part
1491 728 mdecorde
              IntOp $6 $6 + 1
1492 728 mdecorde
              StrCpy $3 $3 `` $6
1493 728 mdecorde
              StrCpy $6 0
1494 728 mdecorde
              Goto ResultPartLoop
1495 728 mdecorde
            ${EndIf}
1496 728 mdecorde
1497 728 mdecorde
            ;Increase "CurrentSepCharNum" counter
1498 728 mdecorde
            IntOp $R0 $R0 + 1
1499 728 mdecorde
          ${Loop}
1500 728 mdecorde
          ${IfThen} $R0 == "End" ${|} ${ExitDo} ${|}
1501 728 mdecorde
1502 728 mdecorde
          ;Increase "StartCharPos" counter
1503 728 mdecorde
          IntOp $6 $6 + 1
1504 728 mdecorde
        ${Loop}
1505 728 mdecorde
1506 728 mdecorde
    /*After this point:
1507 728 mdecorde
      ------------------------------------------
1508 728 mdecorde
       $3 = OutVar (output)*/
1509 728 mdecorde
1510 728 mdecorde
      ;Return output to user
1511 728 mdecorde
1512 728 mdecorde
      Pop $R0
1513 728 mdecorde
      Pop $9
1514 728 mdecorde
      Pop $8
1515 728 mdecorde
      Pop $7
1516 728 mdecorde
      Pop $6
1517 728 mdecorde
      Pop $5
1518 728 mdecorde
      Pop $4
1519 728 mdecorde
      Pop $0
1520 728 mdecorde
      Pop $1
1521 728 mdecorde
      Pop $2
1522 728 mdecorde
      Exch $3
1523 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
1524 728 mdecorde
1525 728 mdecorde
  !macroend
1526 728 mdecorde
1527 2956 mdecorde
  ############################################################################
1528 2956 mdecorde
  # StrTrimNewLines
1529 2956 mdecorde
  !insertmacro STRFUNC_DEFFUNC StrTrimNewLines `ResultVar|String` `Output|Text`
1530 728 mdecorde
1531 2956 mdecorde
  !macro STRFUNC_CALL_StrTrimNewLines un ResultVar String
1532 2956 mdecorde
    !verbose push ${STRFUNC_VERBOSITY}
1533 2956 mdecorde
    !echo `${U+24}{${un}StrTrimNewLines} "${ResultVar}" "${String}"`
1534 2956 mdecorde
    !verbose 2
1535 2956 mdecorde
    Push `${String}`
1536 2956 mdecorde
    !insertmacro STRFUNC_CALL StrTrimNewLines "${un}"
1537 2956 mdecorde
    Pop ${ResultVar}
1538 2956 mdecorde
    !verbose pop
1539 2956 mdecorde
  !macroend
1540 728 mdecorde
1541 2956 mdecorde
  !macro STRFUNC_MAKEFUNC_StrTrimNewLines
1542 2956 mdecorde
    !insertmacro STRFUNC_BEGINFUNC ${basename} `${un}` `2004 Diego Pedroso - Based on functions by Ximon Eighteen`
1543 2956 mdecorde
1544 728 mdecorde
    /*After this point:
1545 728 mdecorde
      ------------------------------------------
1546 728 mdecorde
       $R0 = String (input)
1547 728 mdecorde
       $R1 = TrimCounter (temp)
1548 728 mdecorde
       $R2 = Temp (temp)*/
1549 728 mdecorde
1550 728 mdecorde
      ;Get input from user
1551 728 mdecorde
      Exch $R0
1552 728 mdecorde
      Push $R1
1553 728 mdecorde
      Push $R2
1554 728 mdecorde
1555 728 mdecorde
      ;Initialize trim counter
1556 728 mdecorde
      StrCpy $R1 0
1557 728 mdecorde
1558 728 mdecorde
      loop:
1559 728 mdecorde
        ;Subtract to get "String"'s last characters
1560 728 mdecorde
        IntOp $R1 $R1 - 1
1561 728 mdecorde
1562 728 mdecorde
        ;Verify if they are either $\r or $\n
1563 728 mdecorde
        StrCpy $R2 $R0 1 $R1
1564 728 mdecorde
        ${If} $R2 == `$\r`
1565 728 mdecorde
        ${OrIf} $R2 == `$\n`
1566 728 mdecorde
          Goto loop
1567 728 mdecorde
        ${EndIf}
1568 728 mdecorde
1569 728 mdecorde
      ;Trim characters (if needed)
1570 728 mdecorde
      IntOp $R1 $R1 + 1
1571 728 mdecorde
      ${If} $R1 < 0
1572 728 mdecorde
        StrCpy $R0 $R0 $R1
1573 728 mdecorde
      ${EndIf}
1574 728 mdecorde
1575 728 mdecorde
    /*After this point:
1576 728 mdecorde
      ------------------------------------------
1577 728 mdecorde
       $R0 = OutVar (output)*/
1578 728 mdecorde
1579 728 mdecorde
      ;Return output to user
1580 728 mdecorde
      Pop $R2
1581 728 mdecorde
      Pop $R1
1582 728 mdecorde
      Exch $R0
1583 2956 mdecorde
    !insertmacro STRFUNC_ENDFUNC
1584 728 mdecorde
1585 728 mdecorde
  !macroend
1586 728 mdecorde
1587 2956 mdecorde
  ############################################################################
1588 728 mdecorde
1589 728 mdecorde
!endif
1590 728 mdecorde
!verbose 3
1591 728 mdecorde
!define STRFUNC_VERBOSITY ${_STRFUNC_VERBOSITY}
1592 728 mdecorde
!undef _STRFUNC_VERBOSITY
1593 728 mdecorde
!verbose pop