Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Examples / TextFuncTest.nsi @ 3098

Historique | Voir | Annoter | Télécharger (8,87 ko)

1 728 mdecorde
;_____________________________________________________________________________
2 728 mdecorde
;
3 728 mdecorde
;                          Text Functions Test
4 728 mdecorde
;_____________________________________________________________________________
5 728 mdecorde
;
6 728 mdecorde
; 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
7 728 mdecorde
8 728 mdecorde
Name "Text Functions Test"
9 728 mdecorde
OutFile "TextFuncTest.exe"
10 728 mdecorde
Caption "$(^Name)"
11 728 mdecorde
ShowInstDetails show
12 728 mdecorde
XPStyle on
13 728 mdecorde
RequestExecutionLevel user
14 728 mdecorde
15 728 mdecorde
Var FUNCTION
16 728 mdecorde
Var TEMPFILE1
17 728 mdecorde
Var TEMPFILE2
18 728 mdecorde
Var TEMPFILE3
19 728 mdecorde
Var HANDLE
20 728 mdecorde
Var OUT
21 728 mdecorde
22 728 mdecorde
!include "TextFunc.nsh"
23 728 mdecorde
24 728 mdecorde
;############### INSTALL ###############
25 728 mdecorde
26 728 mdecorde
!define StackVerificationStart `!insertmacro StackVerificationStart`
27 728 mdecorde
!macro StackVerificationStart _FUNCTION
28 728 mdecorde
	StrCpy $FUNCTION ${_FUNCTION}
29 728 mdecorde
	Call StackVerificationStart
30 728 mdecorde
!macroend
31 728 mdecorde
32 728 mdecorde
!define StackVerificationEnd `!insertmacro StackVerificationEnd`
33 728 mdecorde
!macro StackVerificationEnd
34 728 mdecorde
	Call StackVerificationEnd
35 728 mdecorde
!macroend
36 728 mdecorde
37 728 mdecorde
Function StackVerificationStart
38 728 mdecorde
	StrCpy $0 !0
39 728 mdecorde
	StrCpy $1 !1
40 728 mdecorde
	StrCpy $2 !2
41 728 mdecorde
	StrCpy $3 !3
42 728 mdecorde
	StrCpy $4 !4
43 728 mdecorde
	StrCpy $5 !5
44 728 mdecorde
	StrCpy $6 !6
45 728 mdecorde
	StrCpy $7 !7
46 728 mdecorde
	StrCpy $8 !8
47 728 mdecorde
	StrCpy $9 !9
48 728 mdecorde
	StrCpy $R0 !R0
49 728 mdecorde
	StrCpy $R1 !R1
50 728 mdecorde
	StrCpy $R2 !R2
51 728 mdecorde
	StrCpy $R3 !R3
52 728 mdecorde
	StrCpy $R4 !R4
53 728 mdecorde
	StrCpy $R5 !R5
54 728 mdecorde
	StrCpy $R6 !R6
55 728 mdecorde
	StrCpy $R7 !R7
56 728 mdecorde
	StrCpy $R8 !R8
57 728 mdecorde
	StrCpy $R9 !R9
58 728 mdecorde
FunctionEnd
59 728 mdecorde
60 728 mdecorde
Function StackVerificationEnd
61 728 mdecorde
	IfErrors +3
62 728 mdecorde
	DetailPrint 'PASSED $FUNCTION no errors'
63 728 mdecorde
	goto +2
64 728 mdecorde
	DetailPrint 'FAILED   $FUNCTION error'
65 728 mdecorde
66 728 mdecorde
	StrCmp $0 '!0' 0 error
67 728 mdecorde
	StrCmp $1 '!1' 0 error
68 728 mdecorde
	StrCmp $2 '!2' 0 error
69 728 mdecorde
	StrCmp $3 '!3' 0 error
70 728 mdecorde
	StrCmp $4 '!4' 0 error
71 728 mdecorde
	StrCmp $5 '!5' 0 error
72 728 mdecorde
	StrCmp $6 '!6' 0 error
73 728 mdecorde
	StrCmp $7 '!7' 0 error
74 728 mdecorde
	StrCmp $8 '!8' 0 error
75 728 mdecorde
	StrCmp $9 '!9' 0 error
76 728 mdecorde
	StrCmp $R0 '!R0' 0 error
77 728 mdecorde
	StrCmp $R1 '!R1' 0 error
78 728 mdecorde
	StrCmp $R2 '!R2' 0 error
79 728 mdecorde
	StrCmp $R3 '!R3' 0 error
80 728 mdecorde
	StrCmp $R4 '!R4' 0 error
81 728 mdecorde
	StrCmp $R5 '!R5' 0 error
82 728 mdecorde
	StrCmp $R6 '!R6' 0 error
83 728 mdecorde
	StrCmp $R7 '!R7' 0 error
84 728 mdecorde
	StrCmp $R8 '!R8' 0 error
85 728 mdecorde
	StrCmp $R9 '!R9' 0 error
86 728 mdecorde
	DetailPrint 'PASSED $FUNCTION stack'
87 728 mdecorde
	goto end
88 728 mdecorde
89 728 mdecorde
	error:
90 728 mdecorde
	DetailPrint 'FAILED   $FUNCTION stack'
91 728 mdecorde
;	MessageBox MB_OKCANCEL '$$0={$0}$\n$$1={$1}$\n$$2={$2}$\n$$3={$3}$\n$$4={$4}$\n$$5={$5}$\n$$6={$6}$\n$$7={$7}$\n$$8={$8}$\n$$9={$9}$\n$$R0={$R0}$\n$$R1={$R1}$\n$$R2={$R2}$\n$$R3={$R3}$\n$$R4={$R4}$\n$$R5={$R5}$\n$$R6={$R6}$\n$$R7={$R7}$\n$$R8={$R8}$\n$$R9={$R9}' IDOK +2
92 728 mdecorde
;	quit
93 728 mdecorde
94 728 mdecorde
	end:
95 728 mdecorde
FunctionEnd
96 728 mdecorde
97 728 mdecorde
98 728 mdecorde
99 728 mdecorde
Section CreateTestFile
100 728 mdecorde
	GetTempFileName $TEMPFILE1
101 728 mdecorde
	FileOpen $HANDLE $TEMPFILE1 w
102 728 mdecorde
	FileWrite $HANDLE '1A=a$\r$\n'
103 728 mdecorde
	FileWrite $HANDLE '2B=b$\r$\n'
104 728 mdecorde
	FileWrite $HANDLE '3C=c$\r$\n'
105 728 mdecorde
	FileWrite $HANDLE '4D=d$\r$\n'
106 728 mdecorde
	FileWrite $HANDLE '5E=e$\r$\n'
107 728 mdecorde
	FileClose $HANDLE
108 728 mdecorde
	GetTempFileName $TEMPFILE2
109 728 mdecorde
	GetTempFileName $TEMPFILE3
110 728 mdecorde
SectionEnd
111 728 mdecorde
112 728 mdecorde
113 728 mdecorde
Section LineFind
114 728 mdecorde
	${StackVerificationStart} LineFind
115 728 mdecorde
116 728 mdecorde
	${LineFind} '$TEMPFILE1' '/NUL' '1:-4 3 -1' 'LineFindCallback1'
117 728 mdecorde
	IfErrors error
118 728 mdecorde
	StrCmp $OUT '|1:2|-5|1|1A=a$\r$\n|1:2|-4|2|2B=b$\r$\n|3:3|-3|3|3C=c$\r$\n' 0 error
119 728 mdecorde
120 728 mdecorde
	StrCpy $OUT ''
121 728 mdecorde
	SetDetailsPrint none
122 728 mdecorde
	${LineFind} '$TEMPFILE1' '$TEMPFILE2' '1:-1' 'LineFindCallback2'
123 728 mdecorde
	SetDetailsPrint both
124 728 mdecorde
	IfErrors error
125 728 mdecorde
	StrCmp $OUT '|1:-1||1|1A=a$\r$\n|1:-1||2|4D=d$\r$\n|1:-1||3|3C=c$\r$\n|1:-1||4|2B=B$\r$\n|1:-1||5|5E=e$\r$\n' 0 error
126 728 mdecorde
127 728 mdecorde
	goto +2
128 728 mdecorde
	error:
129 728 mdecorde
	SetErrors
130 728 mdecorde
131 728 mdecorde
	${StackVerificationEnd}
132 728 mdecorde
SectionEnd
133 728 mdecorde
134 728 mdecorde
Function LineFindCallback1
135 728 mdecorde
	StrCpy $OUT '$OUT|$R6|$R7|$R8|$R9'
136 728 mdecorde
	StrCmp $R8 3 0 +2
137 728 mdecorde
	StrCpy $0 StopLineFind
138 728 mdecorde
139 728 mdecorde
	Push $0
140 728 mdecorde
FunctionEnd
141 728 mdecorde
142 728 mdecorde
Function LineFindCallback2
143 728 mdecorde
	StrCmp $R8 2 0 +2
144 728 mdecorde
	StrCpy $R9 '4D=d$\r$\n'
145 728 mdecorde
	StrCmp $R8 4 0 +2
146 728 mdecorde
	StrCpy $R9 '2B=B$\r$\n'
147 728 mdecorde
148 728 mdecorde
	StrCpy $OUT '$OUT|$R6|$R7|$R8|$R9'
149 728 mdecorde
150 728 mdecorde
	Push $0
151 728 mdecorde
FunctionEnd
152 728 mdecorde
153 728 mdecorde
154 728 mdecorde
Section LineRead
155 728 mdecorde
	${StackVerificationStart} LineRead
156 728 mdecorde
157 728 mdecorde
	${LineRead} '$TEMPFILE1' '-1' $OUT
158 728 mdecorde
	IfErrors error
159 728 mdecorde
	StrCmp $OUT '5E=e$\r$\n' 0 error
160 728 mdecorde
161 728 mdecorde
	goto +2
162 728 mdecorde
	error:
163 728 mdecorde
	SetErrors
164 728 mdecorde
165 728 mdecorde
	${StackVerificationEnd}
166 728 mdecorde
SectionEnd
167 728 mdecorde
168 728 mdecorde
169 728 mdecorde
Section FileReadFromEnd
170 728 mdecorde
	${StackVerificationStart} FileReadFromEnd
171 728 mdecorde
172 728 mdecorde
	StrCpy $OUT ''
173 728 mdecorde
	${FileReadFromEnd} '$TEMPFILE1' 'FileReadFromEndCallback'
174 728 mdecorde
	IfErrors error
175 728 mdecorde
	StrCmp $OUT '|-1|5|5E=e$\r$\n|-2|4|4D=d$\r$\n|-3|3|3C=c$\r$\n|-4|2|2B=b$\r$\n' 0 error
176 728 mdecorde
177 728 mdecorde
	goto +2
178 728 mdecorde
	error:
179 728 mdecorde
	SetErrors
180 728 mdecorde
181 728 mdecorde
	${StackVerificationEnd}
182 728 mdecorde
SectionEnd
183 728 mdecorde
184 728 mdecorde
Function FileReadFromEndCallback
185 728 mdecorde
	StrCpy $OUT '$OUT|$7|$8|$9'
186 728 mdecorde
	StrCmp $8 2 0 +2
187 728 mdecorde
	StrCpy $0 StopFileReadFromEnd
188 728 mdecorde
189 728 mdecorde
	Push $0
190 728 mdecorde
FunctionEnd
191 728 mdecorde
192 728 mdecorde
193 728 mdecorde
Section LineSum
194 728 mdecorde
	${StackVerificationStart} LineSum
195 728 mdecorde
196 728 mdecorde
	${LineSum} '$TEMPFILE1' $OUT
197 728 mdecorde
	IfErrors error
198 728 mdecorde
	StrCmp $OUT '5' 0 error
199 728 mdecorde
200 728 mdecorde
	goto +2
201 728 mdecorde
	error:
202 728 mdecorde
	SetErrors
203 728 mdecorde
204 728 mdecorde
	${StackVerificationEnd}
205 728 mdecorde
SectionEnd
206 728 mdecorde
207 728 mdecorde
208 728 mdecorde
Section FileJoin
209 728 mdecorde
	${StackVerificationStart} FileJoin
210 728 mdecorde
211 728 mdecorde
	SetDetailsPrint none
212 728 mdecorde
	${FileJoin} '$TEMPFILE1' '$TEMPFILE2' '$TEMPFILE3'
213 728 mdecorde
	SetDetailsPrint both
214 728 mdecorde
215 728 mdecorde
	${StackVerificationEnd}
216 728 mdecorde
SectionEnd
217 728 mdecorde
218 728 mdecorde
219 728 mdecorde
Section TextCompare
220 728 mdecorde
	${StackVerificationStart} TextCompare
221 728 mdecorde
222 728 mdecorde
	StrCpy $OUT ''
223 728 mdecorde
	${TextCompare} '$TEMPFILE1' '$TEMPFILE2' 'FastDiff' 'TextCompareCallback'
224 728 mdecorde
	StrCmp $OUT '|2|4D=d$\r$\n|2|2B=b$\r$\n|4|2B=B$\r$\n|4|4D=d$\r$\n' 0 error
225 728 mdecorde
226 728 mdecorde
	StrCpy $OUT ''
227 728 mdecorde
	${TextCompare} '$TEMPFILE1' '$TEMPFILE2' 'FastEqual' 'TextCompareCallback'
228 728 mdecorde
	StrCmp $OUT '|1|1A=a$\r$\n|1|1A=a$\r$\n|3|3C=c$\r$\n|3|3C=c$\r$\n|5|5E=e$\r$\n|5|5E=e$\r$\n' 0 error
229 728 mdecorde
230 728 mdecorde
	StrCpy $OUT ''
231 728 mdecorde
	${TextCompare} '$TEMPFILE1' '$TEMPFILE2' 'SlowDiff' 'TextCompareCallback'
232 728 mdecorde
	StrCmp $OUT '' 0 error
233 728 mdecorde
234 728 mdecorde
	StrCpy $OUT ''
235 728 mdecorde
	${TextCompare} '$TEMPFILE1' '$TEMPFILE2' 'SlowEqual' 'TextCompareCallback'
236 728 mdecorde
	StrCmp $OUT '|1|1A=a$\r$\n|1|1A=a$\r$\n|4|2B=B$\r$\n|2|2B=b$\r$\n|3|3C=c$\r$\n|3|3C=c$\r$\n|2|4D=d$\r$\n|4|4D=d$\r$\n|5|5E=e$\r$\n|5|5E=e$\r$\n' 0 error
237 728 mdecorde
238 728 mdecorde
	goto +2
239 728 mdecorde
	error:
240 728 mdecorde
	SetErrors
241 728 mdecorde
242 728 mdecorde
	${StackVerificationEnd}
243 728 mdecorde
SectionEnd
244 728 mdecorde
245 728 mdecorde
Section TextCompareS
246 728 mdecorde
	${StackVerificationStart} TextCompareS
247 728 mdecorde
248 728 mdecorde
	StrCpy $OUT ''
249 728 mdecorde
	${TextCompareS} '$TEMPFILE1' '$TEMPFILE2' 'SlowDiff' 'TextCompareCallback'
250 728 mdecorde
	StrCmp $OUT '|||2|2B=b$\r$\n' 0 error
251 728 mdecorde
252 728 mdecorde
	StrCpy $OUT ''
253 728 mdecorde
	${TextCompareS} '$TEMPFILE1' '$TEMPFILE2' 'SlowEqual' 'TextCompareCallback'
254 728 mdecorde
	StrCmp $OUT '|1|1A=a$\r$\n|1|1A=a$\r$\n|3|3C=c$\r$\n|3|3C=c$\r$\n|2|4D=d$\r$\n|4|4D=d$\r$\n|5|5E=e$\r$\n|5|5E=e$\r$\n' 0 error
255 728 mdecorde
256 728 mdecorde
	goto +2
257 728 mdecorde
	error:
258 728 mdecorde
	SetErrors
259 728 mdecorde
260 728 mdecorde
	${StackVerificationEnd}
261 728 mdecorde
SectionEnd
262 728 mdecorde
263 728 mdecorde
Function TextCompareCallback
264 728 mdecorde
	StrCpy $OUT '$OUT|$6|$7|$8|$9'
265 728 mdecorde
266 728 mdecorde
	Push $0
267 728 mdecorde
FunctionEnd
268 728 mdecorde
269 728 mdecorde
270 728 mdecorde
Section ConfigRead
271 728 mdecorde
	${StackVerificationStart} ConfigRead
272 728 mdecorde
273 728 mdecorde
	${ConfigRead} '$TEMPFILE1' '3c=' $OUT
274 728 mdecorde
	StrCmp $OUT 'c' 0 error
275 728 mdecorde
276 728 mdecorde
	${ConfigRead} '$TEMPFILE1' '6F=' $OUT
277 728 mdecorde
	StrCmp $OUT '' 0 error
278 728 mdecorde
279 728 mdecorde
	${ConfigRead} '$TEMPFILE1' 'FF=' $OUT
280 728 mdecorde
	IfErrors 0 error
281 728 mdecorde
282 728 mdecorde
	goto +2
283 728 mdecorde
	error:
284 728 mdecorde
	SetErrors
285 728 mdecorde
286 728 mdecorde
	${StackVerificationEnd}
287 728 mdecorde
SectionEnd
288 728 mdecorde
289 728 mdecorde
290 728 mdecorde
Section ConfigReadS
291 728 mdecorde
	${StackVerificationStart} ConfigReadS
292 728 mdecorde
293 728 mdecorde
	${ConfigReadS} '$TEMPFILE1' '3C=' $OUT
294 728 mdecorde
	StrCmp $OUT 'c' 0 error
295 728 mdecorde
296 728 mdecorde
	${ConfigReadS} '$TEMPFILE1' '3c=' $OUT
297 728 mdecorde
	IfErrors 0 error
298 728 mdecorde
	StrCmp $OUT '' 0 error
299 728 mdecorde
300 728 mdecorde
	goto +2
301 728 mdecorde
	error:
302 728 mdecorde
	SetErrors
303 728 mdecorde
304 728 mdecorde
	${StackVerificationEnd}
305 728 mdecorde
SectionEnd
306 728 mdecorde
307 728 mdecorde
308 728 mdecorde
Section ConfigWrite
309 728 mdecorde
	${StackVerificationStart} ConfigWrite
310 728 mdecorde
311 728 mdecorde
	${ConfigWrite} '$TEMPFILE1' '5E=' 'e**' $OUT
312 728 mdecorde
	StrCmp $OUT 'CHANGED' 0 error
313 728 mdecorde
314 728 mdecorde
	${ConfigWrite} '$TEMPFILE1' '2B=' '' $OUT
315 728 mdecorde
	StrCmp $OUT 'DELETED' 0 error
316 728 mdecorde
317 728 mdecorde
	${ConfigWrite} '$TEMPFILE1' '3c=' 'c' $OUT
318 728 mdecorde
	StrCmp $OUT 'SAME' 0 error
319 728 mdecorde
320 728 mdecorde
	${ConfigWrite} '$TEMPFILE1' '6F=' '*' $OUT
321 728 mdecorde
	StrCmp $OUT 'ADDED' 0 error
322 728 mdecorde
323 728 mdecorde
	goto +2
324 728 mdecorde
	error:
325 728 mdecorde
	SetErrors
326 728 mdecorde
327 728 mdecorde
	${StackVerificationEnd}
328 728 mdecorde
SectionEnd
329 728 mdecorde
330 728 mdecorde
331 728 mdecorde
Section ConfigWriteS
332 728 mdecorde
	${StackVerificationStart} ConfigWriteS
333 728 mdecorde
334 728 mdecorde
	${ConfigWriteS} '$TEMPFILE1' '5e=' 'e**' $OUT
335 728 mdecorde
	StrCmp $OUT 'ADDED' 0 error
336 728 mdecorde
337 728 mdecorde
	goto +2
338 728 mdecorde
	error:
339 728 mdecorde
	SetErrors
340 728 mdecorde
341 728 mdecorde
	${StackVerificationEnd}
342 728 mdecorde
SectionEnd
343 728 mdecorde
344 728 mdecorde
345 728 mdecorde
Section FileRecode
346 728 mdecorde
	${StackVerificationStart} FileRecode
347 728 mdecorde
348 728 mdecorde
	${FileRecode} '$TEMPFILE1' 'CharToOem'
349 728 mdecorde
350 728 mdecorde
	${StackVerificationEnd}
351 728 mdecorde
SectionEnd
352 728 mdecorde
353 728 mdecorde
354 728 mdecorde
Section TrimNewLines
355 728 mdecorde
	${StackVerificationStart} TrimNewLines
356 728 mdecorde
357 728 mdecorde
	${TrimNewLines} 'Text Line$\r$\n' $OUT
358 728 mdecorde
	StrCmp $OUT 'Text Line' 0 error
359 728 mdecorde
360 728 mdecorde
	${TrimNewLines} 'Text Line' $OUT
361 728 mdecorde
	StrCmp $OUT 'Text Line' 0 error
362 728 mdecorde
363 728 mdecorde
	${TrimNewLines} 'Text Line$\n' $OUT
364 728 mdecorde
	StrCmp $OUT 'Text Line' 0 error
365 728 mdecorde
366 728 mdecorde
	goto +2
367 728 mdecorde
	error:
368 728 mdecorde
	SetErrors
369 728 mdecorde
370 728 mdecorde
	${StackVerificationEnd}
371 728 mdecorde
SectionEnd
372 728 mdecorde
373 728 mdecorde
374 728 mdecorde
Section WriteUninstaller
375 728 mdecorde
	SetDetailsPrint none
376 728 mdecorde
	Delete $TEMPFILE1
377 728 mdecorde
	Delete $TEMPFILE2
378 728 mdecorde
	Delete $TEMPFILE3
379 728 mdecorde
	SetDetailsPrint both
380 728 mdecorde
	goto +2
381 728 mdecorde
	WriteUninstaller '$EXEDIR\un.TextFuncTest.exe'
382 728 mdecorde
SectionEnd
383 728 mdecorde
384 728 mdecorde
385 728 mdecorde
386 728 mdecorde
;############### UNINSTALL ###############
387 728 mdecorde
388 728 mdecorde
Section un.Uninstall
389 728 mdecorde
	${LineFind} '$TEMPFILE1' '/NUL' '1:-1' 'un.LineFindCallback'
390 728 mdecorde
	${LineRead} '$TEMPFILE1' '-1' $OUT
391 728 mdecorde
	${FileReadFromEnd} '$TEMPFILE1' 'un.FileReadFromEndCallback'
392 728 mdecorde
	${LineSum} '$TEMPFILE1' $OUT
393 728 mdecorde
	${FileJoin} '$TEMPFILE1' '$TEMPFILE2' '$TEMPFILE3'
394 728 mdecorde
	${TextCompare} '$TEMPFILE1' '$TEMPFILE2' 'FastDiff' 'un.TextCompareCallback'
395 728 mdecorde
	${TextCompareS} '$TEMPFILE1' '$TEMPFILE2' 'FastDiff' 'un.TextCompareCallback'
396 728 mdecorde
	${ConfigRead} '$TEMPFILE1' '3c=' $OUT
397 728 mdecorde
	${ConfigReadS} '$TEMPFILE1' '3c=' $OUT
398 728 mdecorde
	${ConfigWrite} '$TEMPFILE1' '5E=' 'e**' $OUT
399 728 mdecorde
	${ConfigWriteS} '$TEMPFILE1' '5E=' 'e**' $OUT
400 728 mdecorde
	${FileRecode} '$TEMPFILE1' 'CharToOem'
401 728 mdecorde
	${TrimNewLines} 'Text Line$\r$\n' $OUT
402 728 mdecorde
SectionEnd
403 728 mdecorde
404 728 mdecorde
Function un.LineFindCallback
405 728 mdecorde
	Push $0
406 728 mdecorde
FunctionEnd
407 728 mdecorde
408 728 mdecorde
Function un.FileReadFromEndCallback
409 728 mdecorde
	Push $0
410 728 mdecorde
FunctionEnd
411 728 mdecorde
412 728 mdecorde
Function un.TextCompareCallback
413 728 mdecorde
	Push $0
414 728 mdecorde
FunctionEnd