Statistiques
| Révision :

root / tmp / org.txm.setups / nsis-2.5 / Examples / StrFunc.nsi @ 3117

Historique | Voir | Annoter | Télécharger (22,2 ko)

1 2961 mdecorde
Name "NSIS StrFunc Example"
2 2961 mdecorde
OutFile "StrFunc.exe"
3 2961 mdecorde
ShowInstDetails show
4 2961 mdecorde
ShowUninstDetails show
5 2961 mdecorde
XPStyle on
6 2961 mdecorde
RequestExecutionLevel user
7 2961 mdecorde
8 2961 mdecorde
!include "StrFunc.nsh"
9 2961 mdecorde
10 2961 mdecorde
# Declare used functions
11 2961 mdecorde
${StrCase}
12 2961 mdecorde
${StrClb}
13 2961 mdecorde
${StrIOToNSIS}
14 2961 mdecorde
${StrLoc}
15 2961 mdecorde
${StrNSISToIO}
16 2961 mdecorde
${StrRep}
17 2961 mdecorde
${StrStr}
18 2961 mdecorde
${StrStrAdv}
19 2961 mdecorde
${StrTok}
20 2961 mdecorde
${StrTrimNewLines}
21 2961 mdecorde
${StrSort}
22 2961 mdecorde
23 2961 mdecorde
${UnStrCase}
24 2961 mdecorde
${UnStrClb}
25 2961 mdecorde
${UnStrIOToNSIS}
26 2961 mdecorde
${UnStrLoc}
27 2961 mdecorde
${UnStrNSISToIO}
28 2961 mdecorde
${UnStrRep}
29 2961 mdecorde
${UnStrStr}
30 2961 mdecorde
${UnStrStrAdv}
31 2961 mdecorde
${UnStrTok}
32 2961 mdecorde
${UnStrTrimNewLines}
33 2961 mdecorde
${UnStrSort}
34 2961 mdecorde
35 2961 mdecorde
!macro StackVerificationStart
36 2961 mdecorde
  StrCpy $0 S0
37 2961 mdecorde
  StrCpy $1 S1
38 2961 mdecorde
  StrCpy $2 S2
39 2961 mdecorde
  StrCpy $3 S3
40 2961 mdecorde
  StrCpy $4 S4
41 2961 mdecorde
  StrCpy $5 S5
42 2961 mdecorde
  StrCpy $6 S6
43 2961 mdecorde
  StrCpy $7 S7
44 2961 mdecorde
  StrCpy $8 S8
45 2961 mdecorde
  StrCpy $9 S9
46 2961 mdecorde
  StrCpy $R0 SR0
47 2961 mdecorde
  StrCpy $R1 SR1
48 2961 mdecorde
  StrCpy $R2 SR2
49 2961 mdecorde
  StrCpy $R3 SR3
50 2961 mdecorde
  StrCpy $R4 SR4
51 2961 mdecorde
  StrCpy $R5 SR5
52 2961 mdecorde
  StrCpy $R6 SR6
53 2961 mdecorde
  StrCpy $R7 SR7
54 2961 mdecorde
  StrCpy $R8 SR8
55 2961 mdecorde
  StrCpy $R9 SR9
56 2961 mdecorde
!macroend
57 2961 mdecorde
58 2961 mdecorde
!macro StackVerificationEnd
59 2961 mdecorde
  ClearErrors
60 2961 mdecorde
  ${If} $1 != "S1"
61 2961 mdecorde
  ${OrIf} $2 != "S2"
62 2961 mdecorde
  ${OrIf} $3 != "S3"
63 2961 mdecorde
  ${OrIf} $4 != "S4"
64 2961 mdecorde
  ${OrIf} $5 != "S5"
65 2961 mdecorde
  ${OrIf} $6 != "S6"
66 2961 mdecorde
  ${OrIf} $7 != "S7"
67 2961 mdecorde
  ${OrIf} $8 != "S8"
68 2961 mdecorde
  ${OrIf} $9 != "S9"
69 2961 mdecorde
  ${OrIf} $R0 != "SR0"
70 2961 mdecorde
  ${OrIf} $R1 != "SR1"
71 2961 mdecorde
  ${OrIf} $R2 != "SR2"
72 2961 mdecorde
  ${OrIf} $R3 != "SR3"
73 2961 mdecorde
  ${OrIf} $R4 != "SR4"
74 2961 mdecorde
  ${OrIf} $R5 != "SR5"
75 2961 mdecorde
  ${OrIf} $R6 != "SR6"
76 2961 mdecorde
  ${OrIf} $R7 != "SR7"
77 2961 mdecorde
  ${OrIf} $R8 != "SR8"
78 2961 mdecorde
  ${OrIf} $R9 != "SR9"
79 2961 mdecorde
    SetErrors
80 2961 mdecorde
  ${EndIf}
81 2961 mdecorde
!macroend
82 2961 mdecorde
83 2961 mdecorde
Section
84 2961 mdecorde
85 2961 mdecorde
  # Test case conversion
86 2961 mdecorde
  !insertmacro StackVerificationStart
87 2961 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." ""
88 2961 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
89 2961 mdecorde
  ${StrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
90 2961 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
91 2961 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "L"
92 2961 mdecorde
  StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
93 2961 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "U"
94 2961 mdecorde
  StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
95 2961 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "T"
96 2961 mdecorde
  StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
97 2961 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "<>"
98 2961 mdecorde
  StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
99 2961 mdecorde
  ${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
100 2961 mdecorde
  StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
101 2961 mdecorde
  ${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
102 2961 mdecorde
  StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
103 2961 mdecorde
  ${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
104 2961 mdecorde
  StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
105 2961 mdecorde
  !insertmacro StackVerificationEnd
106 2961 mdecorde
  IfErrors strcaseerror
107 2961 mdecorde
108 2961 mdecorde
  DetailPrint "PASSED StrCase test"
109 2961 mdecorde
  Goto +2
110 2961 mdecorde
strcaseerror:
111 2961 mdecorde
  DetailPrint "FAILED StrCase test"
112 2961 mdecorde
113 2961 mdecorde
  # Test clipboard function
114 2961 mdecorde
  !insertmacro StackVerificationStart
115 2961 mdecorde
  ${StrClb} $0 "StrFunc clipboard test" ">"
116 2961 mdecorde
  StrCmp $0 "" 0 strclberror
117 2961 mdecorde
  ${StrClb} $0 "StrFunc clipboard test #2" "<>"
118 2961 mdecorde
  StrCmp $0 "StrFunc clipboard test" 0 strclberror
119 2961 mdecorde
  ${StrClb} $0 "" "<"
120 2961 mdecorde
  StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
121 2961 mdecorde
  ${StrClb} $0 "" ""
122 2961 mdecorde
  StrCmp $0 "" 0 strclberror
123 2961 mdecorde
  !insertmacro StackVerificationEnd
124 2961 mdecorde
  IfErrors strclberror
125 2961 mdecorde
126 2961 mdecorde
  DetailPrint "PASSED StrClb test"
127 2961 mdecorde
  Goto +2
128 2961 mdecorde
strclberror:
129 2961 mdecorde
  DetailPrint "FAILED StrClb test"
130 2961 mdecorde
131 2961 mdecorde
  # Test IO functions
132 2961 mdecorde
  !insertmacro StackVerificationStart
133 2961 mdecorde
  !macro testio str
134 2961 mdecorde
  ${StrNSISToIO} $0 "${str}"
135 2961 mdecorde
  ${StrIOToNSIS} $0 $0
136 2961 mdecorde
  StrCmp $0 "${str}" 0 ioerror
137 2961 mdecorde
  !macroend
138 2961 mdecorde
  !insertmacro testio "$\rtest$\n"
139 2961 mdecorde
  !insertmacro testio "test$\n"
140 2961 mdecorde
  !insertmacro testio "$\rtest"
141 2961 mdecorde
  !insertmacro testio "test"
142 2961 mdecorde
  !insertmacro testio "$\r\$\t$\n"
143 2961 mdecorde
  !insertmacro testio "$\r \ $\t $\n $$"
144 2961 mdecorde
  !insertmacro testio ""
145 2961 mdecorde
  !insertmacro testio " "
146 2961 mdecorde
  !insertmacro StackVerificationEnd
147 2961 mdecorde
  IfErrors ioerror
148 2961 mdecorde
149 2961 mdecorde
  DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
150 2961 mdecorde
  Goto +2
151 2961 mdecorde
ioerror:
152 2961 mdecorde
  DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
153 2961 mdecorde
154 2961 mdecorde
  # Test string search functions
155 2961 mdecorde
  !insertmacro StackVerificationStart
156 2961 mdecorde
  ${StrLoc} $0 "This is just an example" "just" "<"
157 2961 mdecorde
  StrCmp $0 "11" 0 strlocerror
158 2961 mdecorde
  ${StrLoc} $0 a abc <
159 2961 mdecorde
  StrCmp $0 "" 0 strlocerror
160 2961 mdecorde
  ${StrLoc} $0 a abc >
161 2961 mdecorde
  StrCmp $0 "" 0 strlocerror
162 2961 mdecorde
  ${StrLoc} $0 abc a >
163 2961 mdecorde
  StrCmp $0 "0" 0 strlocerror
164 2961 mdecorde
  ${StrLoc} $0 abc b >
165 2961 mdecorde
  StrCmp $0 "1" 0 strlocerror
166 2961 mdecorde
  ${StrLoc} $0 abc c >
167 2961 mdecorde
  StrCmp $0 "2" 0 strlocerror
168 2961 mdecorde
  ${StrLoc} $0 abc a <
169 2961 mdecorde
  StrCmp $0 "2" 0 strlocerror
170 2961 mdecorde
  ${StrLoc} $0 abc b <
171 2961 mdecorde
  StrCmp $0 "1" 0 strlocerror
172 2961 mdecorde
  ${StrLoc} $0 abc c <
173 2961 mdecorde
  StrCmp $0 "0" 0 strlocerror
174 2961 mdecorde
  ${StrLoc} $0 abc d <
175 2961 mdecorde
  StrCmp $0 "" 0 strlocerror
176 2961 mdecorde
  !insertmacro StackVerificationEnd
177 2961 mdecorde
  IfErrors strlocerror
178 2961 mdecorde
179 2961 mdecorde
  DetailPrint "PASSED StrLoc test"
180 2961 mdecorde
  Goto +2
181 2961 mdecorde
strlocerror:
182 2961 mdecorde
  DetailPrint "FAILED StrLoc test"
183 2961 mdecorde
184 2961 mdecorde
  # Test string replacement
185 2961 mdecorde
  !insertmacro StackVerificationStart
186 2961 mdecorde
  ${StrRep} $0 "This is just an example" "an" "one"
187 2961 mdecorde
  StrCmp $0 "This is just one example" 0 strreperror
188 2961 mdecorde
  ${StrRep} $0 "test... test... 1 2 3..." "test" "testing"
189 2961 mdecorde
  StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
190 2961 mdecorde
  ${StrRep} $0 "" "test" "testing"
191 2961 mdecorde
  StrCmp $0 "" 0 strreperror
192 2961 mdecorde
  ${StrRep} $0 "test" "test" "testing"
193 2961 mdecorde
  StrCmp $0 "testing" 0 strreperror
194 2961 mdecorde
  ${StrRep} $0 "test" "test" ""
195 2961 mdecorde
  StrCmp $0 "" 0 strreperror
196 2961 mdecorde
  ${StrRep} $0 "test" "" "abc"
197 2961 mdecorde
  StrCmp $0 "test" 0 strreperror
198 2961 mdecorde
  ${StrRep} $0 "test" "" ""
199 2961 mdecorde
  StrCmp $0 "test" 0 strreperror
200 2961 mdecorde
  !insertmacro StackVerificationEnd
201 2961 mdecorde
  IfErrors strreperror
202 2961 mdecorde
203 2961 mdecorde
  DetailPrint "PASSED StrRep test"
204 2961 mdecorde
  Goto +2
205 2961 mdecorde
strreperror:
206 2961 mdecorde
  DetailPrint "FAILED StrRep test"
207 2961 mdecorde
208 2961 mdecorde
  # Test sorting
209 2961 mdecorde
  !insertmacro StackVerificationStart
210 2961 mdecorde
  ${StrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
211 2961 mdecorde
  StrCmp $0 "This is an exam" 0 strsorterror
212 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
213 2961 mdecorde
  StrCmp $0 "just" 0 strsorterror
214 2961 mdecorde
  ${StrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
215 2961 mdecorde
  StrCmp $0 "This is just an example" 0 strsorterror
216 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
217 2961 mdecorde
  StrCmp $0 "just an example" 0 strsorterror
218 2961 mdecorde
  ${StrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
219 2961 mdecorde
  StrCmp $0 "This is just" 0 strsorterror
220 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
221 2961 mdecorde
  StrCmp $0 "just" 0 strsorterror
222 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
223 2961 mdecorde
  StrCmp $0 "This" 0 strsorterror
224 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
225 2961 mdecorde
  StrCmp $0 "example" 0 strsorterror
226 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
227 2961 mdecorde
  StrCmp $0 " examp" 0 strsorterror
228 2961 mdecorde
  ${StrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
229 2961 mdecorde
  StrCmp $0 "error" 0 strsorterror
230 2961 mdecorde
  ${StrSort} $0 "" " " "something" " " "0" "1" "0"
231 2961 mdecorde
  StrCmp $0 "" 0 strsorterror
232 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "j" " " "" "" ""
233 2961 mdecorde
  StrCmp $0 " just " 0 strsorterror
234 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
235 2961 mdecorde
  StrCmp $0 " ust " 0 strsorterror
236 2961 mdecorde
  ${StrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
237 2961 mdecorde
  StrCmp $0 "This is ust an example" 0 strsorterror
238 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
239 2961 mdecorde
  StrCmp $0 " jt an example" 0 strsorterror
240 2961 mdecorde
  ${StrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
241 2961 mdecorde
  StrCmp $0 "This is jst " 0 strsorterror
242 2961 mdecorde
  ${StrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
243 2961 mdecorde
  StrCmp $0 "  " 0 strsorterror
244 2961 mdecorde
  ${StrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
245 2961 mdecorde
  StrCmp $0 " rror " 0 strsorterror
246 2961 mdecorde
  ${StrSort} $0 "" " " "something" " " "1" "0" "1"
247 2961 mdecorde
  StrCmp $0 "" 0 strsorterror
248 2961 mdecorde
  !insertmacro StackVerificationEnd
249 2961 mdecorde
  IfErrors strsorterror
250 2961 mdecorde
251 2961 mdecorde
  DetailPrint "PASSED StrSort test"
252 2961 mdecorde
  Goto +2
253 2961 mdecorde
strsorterror:
254 2961 mdecorde
  DetailPrint "FAILED StrSort test"
255 2961 mdecorde
256 2961 mdecorde
  !insertmacro StackVerificationStart
257 2961 mdecorde
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
258 2961 mdecorde
  StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
259 2961 mdecorde
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
260 2961 mdecorde
  StrCmp $0 "" 0 strstrerror
261 2961 mdecorde
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
262 2961 mdecorde
  StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
263 2961 mdecorde
  ${StrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
264 2961 mdecorde
  StrCmp $0 "" 0 strstrerror
265 2961 mdecorde
  !insertmacro StackVerificationEnd
266 2961 mdecorde
  IfErrors strstrerror
267 2961 mdecorde
268 2961 mdecorde
  DetailPrint "PASSED StrStr test"
269 2961 mdecorde
  Goto +2
270 2961 mdecorde
strstrerror:
271 2961 mdecorde
  DetailPrint "FAILED StrStr test"
272 2961 mdecorde
273 2961 mdecorde
  !insertmacro StackVerificationStart
274 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
275 2961 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
276 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
277 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
278 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
279 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
280 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
281 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
282 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
283 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
284 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
285 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
286 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
287 2961 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
288 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
289 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
290 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
291 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
292 2961 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
293 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
294 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
295 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
296 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
297 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
298 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
299 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
300 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
301 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
302 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
303 2961 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
304 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
305 2961 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
306 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
307 2961 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
308 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
309 2961 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
310 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
311 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
312 2961 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
313 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
314 2961 mdecorde
  !insertmacro StackVerificationEnd
315 2961 mdecorde
  IfErrors strstradverror
316 2961 mdecorde
317 2961 mdecorde
  DetailPrint "PASSED StrStrAdv test"
318 2961 mdecorde
  Goto +2
319 2961 mdecorde
strstradverror:
320 2961 mdecorde
  DetailPrint "FAILED StrStrAdv test"
321 2961 mdecorde
322 2961 mdecorde
  # Test tokenizer
323 2961 mdecorde
  !insertmacro StackVerificationStart
324 2961 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "4" "1"
325 2961 mdecorde
  StrCmp $0 "not" 0 strtokerror
326 2961 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "4" "0"
327 2961 mdecorde
  StrCmp $0 "is" 0 strtokerror
328 2961 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "152" "0"
329 2961 mdecorde
  StrCmp $0 "" 0 strtokerror
330 2961 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "" "0"
331 2961 mdecorde
  StrCmp $0 "example" 0 strtokerror
332 2961 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "L" "0"
333 2961 mdecorde
  StrCmp $0 "example" 0 strtokerror
334 2961 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "0" "0"
335 2961 mdecorde
  StrCmp $0 "This" 0 strtokerror
336 2961 mdecorde
  !insertmacro StackVerificationEnd
337 2961 mdecorde
  IfErrors strtokerror
338 2961 mdecorde
339 2961 mdecorde
  DetailPrint "PASSED StrTok test"
340 2961 mdecorde
  Goto +2
341 2961 mdecorde
strtokerror:
342 2961 mdecorde
  DetailPrint "FAILED StrTok test"
343 2961 mdecorde
344 2961 mdecorde
  # Test trim new lines
345 2961 mdecorde
  !insertmacro StackVerificationStart
346 2961 mdecorde
  ${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
347 2961 mdecorde
  StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
348 2961 mdecorde
  !insertmacro StackVerificationEnd
349 2961 mdecorde
  IfErrors strtrimnewlineserror
350 2961 mdecorde
351 2961 mdecorde
  DetailPrint "PASSED StrTrimNewLines test"
352 2961 mdecorde
  Goto +2
353 2961 mdecorde
strtrimnewlineserror:
354 2961 mdecorde
  DetailPrint "FAILED StrTrimNewLines test"
355 2961 mdecorde
356 2961 mdecorde
  WriteUninstaller $EXEDIR\UnStrFunc.exe
357 2961 mdecorde
358 2961 mdecorde
  Exec $EXEDIR\UnStrFunc.exe
359 2961 mdecorde
360 2961 mdecorde
SectionEnd
361 2961 mdecorde
362 2961 mdecorde
Section Uninstall
363 2961 mdecorde
364 2961 mdecorde
  # Test case conversion
365 2961 mdecorde
  !insertmacro StackVerificationStart
366 2961 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." ""
367 2961 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
368 2961 mdecorde
  ${UnStrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
369 2961 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
370 2961 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "L"
371 2961 mdecorde
  StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
372 2961 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "U"
373 2961 mdecorde
  StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
374 2961 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "T"
375 2961 mdecorde
  StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
376 2961 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "<>"
377 2961 mdecorde
  StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
378 2961 mdecorde
  ${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
379 2961 mdecorde
  StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
380 2961 mdecorde
  ${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
381 2961 mdecorde
  StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
382 2961 mdecorde
  ${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
383 2961 mdecorde
  StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
384 2961 mdecorde
  !insertmacro StackVerificationEnd
385 2961 mdecorde
  IfErrors strcaseerror
386 2961 mdecorde
387 2961 mdecorde
  DetailPrint "PASSED StrCase test"
388 2961 mdecorde
  Goto +2
389 2961 mdecorde
strcaseerror:
390 2961 mdecorde
  DetailPrint "FAILED StrCase test"
391 2961 mdecorde
392 2961 mdecorde
  # Test clipboard function
393 2961 mdecorde
  !insertmacro StackVerificationStart
394 2961 mdecorde
  ${UnStrClb} $0 "StrFunc clipboard test" ">"
395 2961 mdecorde
  StrCmp $0 "" 0 strclberror
396 2961 mdecorde
  ${UnStrClb} $0 "StrFunc clipboard test #2" "<>"
397 2961 mdecorde
  StrCmp $0 "StrFunc clipboard test" 0 strclberror
398 2961 mdecorde
  ${UnStrClb} $0 "" "<"
399 2961 mdecorde
  StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
400 2961 mdecorde
  ${UnStrClb} $0 "" ""
401 2961 mdecorde
  StrCmp $0 "" 0 strclberror
402 2961 mdecorde
  !insertmacro StackVerificationEnd
403 2961 mdecorde
  IfErrors strclberror
404 2961 mdecorde
405 2961 mdecorde
  DetailPrint "PASSED StrClb test"
406 2961 mdecorde
  Goto +2
407 2961 mdecorde
strclberror:
408 2961 mdecorde
  DetailPrint "FAILED StrClb test"
409 2961 mdecorde
410 2961 mdecorde
  # Test IO functions
411 2961 mdecorde
  !insertmacro StackVerificationStart
412 2961 mdecorde
  !macro untestio str
413 2961 mdecorde
  ${UnStrNSISToIO} $0 "${str}"
414 2961 mdecorde
  ${UnStrIOToNSIS} $0 $0
415 2961 mdecorde
  StrCmp $0 "${str}" 0 ioerror
416 2961 mdecorde
  !macroend
417 2961 mdecorde
  !insertmacro untestio "$\rtest$\n"
418 2961 mdecorde
  !insertmacro untestio "test$\n"
419 2961 mdecorde
  !insertmacro untestio "$\rtest"
420 2961 mdecorde
  !insertmacro untestio "test"
421 2961 mdecorde
  !insertmacro untestio "$\r\$\t$\n"
422 2961 mdecorde
  !insertmacro untestio "$\r \ $\t $\n $$"
423 2961 mdecorde
  !insertmacro untestio ""
424 2961 mdecorde
  !insertmacro untestio " "
425 2961 mdecorde
  !insertmacro StackVerificationEnd
426 2961 mdecorde
  IfErrors ioerror
427 2961 mdecorde
428 2961 mdecorde
  DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
429 2961 mdecorde
  Goto +2
430 2961 mdecorde
ioerror:
431 2961 mdecorde
  DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
432 2961 mdecorde
433 2961 mdecorde
  # Test string search functions
434 2961 mdecorde
  !insertmacro StackVerificationStart
435 2961 mdecorde
  ${UnStrLoc} $0 "This is just an example" "just" "<"
436 2961 mdecorde
  StrCmp $0 "11" 0 strlocerror
437 2961 mdecorde
  ${UnStrLoc} $0 a abc <
438 2961 mdecorde
  StrCmp $0 "" 0 strlocerror
439 2961 mdecorde
  ${UnStrLoc} $0 a abc >
440 2961 mdecorde
  StrCmp $0 "" 0 strlocerror
441 2961 mdecorde
  ${UnStrLoc} $0 abc a >
442 2961 mdecorde
  StrCmp $0 "0" 0 strlocerror
443 2961 mdecorde
  ${UnStrLoc} $0 abc b >
444 2961 mdecorde
  StrCmp $0 "1" 0 strlocerror
445 2961 mdecorde
  ${UnStrLoc} $0 abc c >
446 2961 mdecorde
  StrCmp $0 "2" 0 strlocerror
447 2961 mdecorde
  ${UnStrLoc} $0 abc a <
448 2961 mdecorde
  StrCmp $0 "2" 0 strlocerror
449 2961 mdecorde
  ${UnStrLoc} $0 abc b <
450 2961 mdecorde
  StrCmp $0 "1" 0 strlocerror
451 2961 mdecorde
  ${UnStrLoc} $0 abc c <
452 2961 mdecorde
  StrCmp $0 "0" 0 strlocerror
453 2961 mdecorde
  ${UnStrLoc} $0 abc d <
454 2961 mdecorde
  StrCmp $0 "" 0 strlocerror
455 2961 mdecorde
  !insertmacro StackVerificationEnd
456 2961 mdecorde
  IfErrors strlocerror
457 2961 mdecorde
458 2961 mdecorde
  DetailPrint "PASSED StrLoc test"
459 2961 mdecorde
  Goto +2
460 2961 mdecorde
strlocerror:
461 2961 mdecorde
  DetailPrint "FAILED StrLoc test"
462 2961 mdecorde
463 2961 mdecorde
  # Test string replacement
464 2961 mdecorde
  !insertmacro StackVerificationStart
465 2961 mdecorde
  ${UnStrRep} $0 "This is just an example" "an" "one"
466 2961 mdecorde
  StrCmp $0 "This is just one example" 0 strreperror
467 2961 mdecorde
  ${UnStrRep} $0 "test... test... 1 2 3..." "test" "testing"
468 2961 mdecorde
  StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
469 2961 mdecorde
  ${UnStrRep} $0 "" "test" "testing"
470 2961 mdecorde
  StrCmp $0 "" 0 strreperror
471 2961 mdecorde
  ${UnStrRep} $0 "test" "test" "testing"
472 2961 mdecorde
  StrCmp $0 "testing" 0 strreperror
473 2961 mdecorde
  ${UnStrRep} $0 "test" "test" ""
474 2961 mdecorde
  StrCmp $0 "" 0 strreperror
475 2961 mdecorde
  ${UnStrRep} $0 "test" "" "abc"
476 2961 mdecorde
  StrCmp $0 "test" 0 strreperror
477 2961 mdecorde
  ${UnStrRep} $0 "test" "" ""
478 2961 mdecorde
  StrCmp $0 "test" 0 strreperror
479 2961 mdecorde
  !insertmacro StackVerificationEnd
480 2961 mdecorde
  IfErrors strreperror
481 2961 mdecorde
482 2961 mdecorde
  DetailPrint "PASSED StrRep test"
483 2961 mdecorde
  Goto +2
484 2961 mdecorde
strreperror:
485 2961 mdecorde
  DetailPrint "FAILED StrRep test"
486 2961 mdecorde
487 2961 mdecorde
  # Test sorting
488 2961 mdecorde
  !insertmacro StackVerificationStart
489 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
490 2961 mdecorde
  StrCmp $0 "This is an exam" 0 strsorterror
491 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
492 2961 mdecorde
  StrCmp $0 "just" 0 strsorterror
493 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
494 2961 mdecorde
  StrCmp $0 "This is just an example" 0 strsorterror
495 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
496 2961 mdecorde
  StrCmp $0 "just an example" 0 strsorterror
497 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
498 2961 mdecorde
  StrCmp $0 "This is just" 0 strsorterror
499 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
500 2961 mdecorde
  StrCmp $0 "just" 0 strsorterror
501 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
502 2961 mdecorde
  StrCmp $0 "This" 0 strsorterror
503 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
504 2961 mdecorde
  StrCmp $0 "example" 0 strsorterror
505 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
506 2961 mdecorde
  StrCmp $0 " examp" 0 strsorterror
507 2961 mdecorde
  ${UnStrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
508 2961 mdecorde
  StrCmp $0 "error" 0 strsorterror
509 2961 mdecorde
  ${UnStrSort} $0 "" " " "something" " " "0" "1" "0"
510 2961 mdecorde
  StrCmp $0 "" 0 strsorterror
511 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "j" " " "" "" ""
512 2961 mdecorde
  StrCmp $0 " just " 0 strsorterror
513 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
514 2961 mdecorde
  StrCmp $0 " ust " 0 strsorterror
515 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
516 2961 mdecorde
  StrCmp $0 "This is ust an example" 0 strsorterror
517 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
518 2961 mdecorde
  StrCmp $0 " jt an example" 0 strsorterror
519 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
520 2961 mdecorde
  StrCmp $0 "This is jst " 0 strsorterror
521 2961 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
522 2961 mdecorde
  StrCmp $0 "  " 0 strsorterror
523 2961 mdecorde
  ${UnStrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
524 2961 mdecorde
  StrCmp $0 " rror " 0 strsorterror
525 2961 mdecorde
  ${UnStrSort} $0 "" " " "something" " " "1" "0" "1"
526 2961 mdecorde
  StrCmp $0 "" 0 strsorterror
527 2961 mdecorde
  !insertmacro StackVerificationEnd
528 2961 mdecorde
  IfErrors strsorterror
529 2961 mdecorde
530 2961 mdecorde
  DetailPrint "PASSED StrSort test"
531 2961 mdecorde
  Goto +2
532 2961 mdecorde
strsorterror:
533 2961 mdecorde
  DetailPrint "FAILED StrSort test"
534 2961 mdecorde
535 2961 mdecorde
  !insertmacro StackVerificationStart
536 2961 mdecorde
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
537 2961 mdecorde
  StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
538 2961 mdecorde
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
539 2961 mdecorde
  StrCmp $0 "" 0 strstrerror
540 2961 mdecorde
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
541 2961 mdecorde
  StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
542 2961 mdecorde
  ${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
543 2961 mdecorde
  StrCmp $0 "" 0 strstrerror
544 2961 mdecorde
  !insertmacro StackVerificationEnd
545 2961 mdecorde
  IfErrors strstrerror
546 2961 mdecorde
547 2961 mdecorde
  DetailPrint "PASSED StrStr test"
548 2961 mdecorde
  Goto +2
549 2961 mdecorde
strstrerror:
550 2961 mdecorde
  DetailPrint "FAILED StrStr test"
551 2961 mdecorde
552 2961 mdecorde
  !insertmacro StackVerificationStart
553 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
554 2961 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
555 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
556 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
557 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
558 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
559 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
560 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
561 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
562 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
563 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
564 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
565 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
566 2961 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
567 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
568 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
569 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
570 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
571 2961 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
572 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
573 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
574 2961 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
575 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
576 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
577 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
578 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
579 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
580 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
581 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
582 2961 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
583 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
584 2961 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
585 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
586 2961 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
587 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
588 2961 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
589 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
590 2961 mdecorde
  StrCmp $0 "" 0 strstradverror
591 2961 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
592 2961 mdecorde
  StrCmp $0 "abc" 0 strstradverror
593 2961 mdecorde
  !insertmacro StackVerificationEnd
594 2961 mdecorde
  IfErrors strstradverror
595 2961 mdecorde
596 2961 mdecorde
  DetailPrint "PASSED StrStrAdv test"
597 2961 mdecorde
  Goto +2
598 2961 mdecorde
strstradverror:
599 2961 mdecorde
  DetailPrint "FAILED StrStrAdv test"
600 2961 mdecorde
601 2961 mdecorde
  # Test tokenizer
602 2961 mdecorde
  !insertmacro StackVerificationStart
603 2961 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "1"
604 2961 mdecorde
  StrCmp $0 "not" 0 strtokerror
605 2961 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "0"
606 2961 mdecorde
  StrCmp $0 "is" 0 strtokerror
607 2961 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "152" "0"
608 2961 mdecorde
  StrCmp $0 "" 0 strtokerror
609 2961 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "" "0"
610 2961 mdecorde
  StrCmp $0 "example" 0 strtokerror
611 2961 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "L" "0"
612 2961 mdecorde
  StrCmp $0 "example" 0 strtokerror
613 2961 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "0" "0"
614 2961 mdecorde
  StrCmp $0 "This" 0 strtokerror
615 2961 mdecorde
  !insertmacro StackVerificationEnd
616 2961 mdecorde
  IfErrors strtokerror
617 2961 mdecorde
618 2961 mdecorde
  DetailPrint "PASSED StrTok test"
619 2961 mdecorde
  Goto +2
620 2961 mdecorde
strtokerror:
621 2961 mdecorde
  DetailPrint "FAILED StrTok test"
622 2961 mdecorde
623 2961 mdecorde
  # Test trim new lines
624 2961 mdecorde
  !insertmacro StackVerificationStart
625 2961 mdecorde
  ${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
626 2961 mdecorde
  StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
627 2961 mdecorde
  !insertmacro StackVerificationEnd
628 2961 mdecorde
  IfErrors strtrimnewlineserror
629 2961 mdecorde
630 2961 mdecorde
  DetailPrint "PASSED StrTrimNewLines test"
631 2961 mdecorde
  Goto +2
632 2961 mdecorde
strtrimnewlineserror:
633 2961 mdecorde
  DetailPrint "FAILED StrTrimNewLines test"
634 2961 mdecorde
635 2961 mdecorde
SectionEnd