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