This file is indexed.

/usr/share/nsis/Include/TextFunc.nsh is in nsis-common 2.50-1.

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
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
/*
_____________________________________________________________________________

                       Text Functions Header v2.4
_____________________________________________________________________________

 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)

 See documentation for more information about the following functions.

 Usage in script:
 1. !include "TextFunc.nsh"
 2. [Section|Function]
      ${TextFunction} "File" "..."  $var
    [SectionEnd|FunctionEnd]


 TextFunction=[LineFind|LineRead|FileReadFromEnd|LineSum|FileJoin|
               TextCompare|TextCompareS|ConfigRead|ConfigReadS|
               ConfigWrite|ConfigWriteS|FileRecode|TrimNewLines]

_____________________________________________________________________________

                       Thanks to:
_____________________________________________________________________________

LineRead
	Afrow UK (Based on his idea of Function "ReadFileLine")
LineSum
	Afrow UK (Based on his idea of Function "LineCount")
FileJoin
	Afrow UK (Based on his idea of Function "JoinFiles")
ConfigRead
	vbgunz (His idea)
ConfigWrite
	vbgunz (His idea)
TrimNewLines
	sunjammer (Based on his Function "TrimNewLines")
*/


;_____________________________________________________________________________
;
;                                   Macros
;_____________________________________________________________________________
;
; Change log window verbosity (default: 3=no script)
;
; Example:
; !include "TextFunc.nsh"
; !insertmacro LineFind
; ${TEXTFUNC_VERBOSE} 4   # all verbosity
; !insertmacro LineSum
; ${TEXTFUNC_VERBOSE} 3   # no script

!ifndef TEXTFUNC_INCLUDED
!define TEXTFUNC_INCLUDED

!include FileFunc.nsh
!include Util.nsh

!verbose push
!verbose 3
!ifndef _TEXTFUNC_VERBOSE
	!define _TEXTFUNC_VERBOSE 3
!endif
!verbose ${_TEXTFUNC_VERBOSE}
!define TEXTFUNC_VERBOSE `!insertmacro TEXTFUNC_VERBOSE`
!verbose pop

!macro TEXTFUNC_VERBOSE _VERBOSE
	!verbose push
	!verbose 3
	!undef _TEXTFUNC_VERBOSE
	!define _TEXTFUNC_VERBOSE ${_VERBOSE}
	!verbose pop
!macroend

!macro LineFindCall _INPUT _OUTPUT _RANGE _FUNC
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push $0
	Push `${_INPUT}`
	Push `${_OUTPUT}`
	Push `${_RANGE}`
	GetFunctionAddress $0 `${_FUNC}`
	Push `$0`
	${CallArtificialFunction} LineFind_
	Pop $0
	!verbose pop
!macroend

!macro LineReadCall _FILE _NUMBER _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	Push `${_NUMBER}`
	${CallArtificialFunction} LineRead_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro FileReadFromEndCall _FILE _FUNC
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push $0
	Push `${_FILE}`
	GetFunctionAddress $0 `${_FUNC}`
	Push `$0`
	${CallArtificialFunction} FileReadFromEnd_
	Pop $0
	!verbose pop
!macroend

!macro LineSumCall _FILE _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	${CallArtificialFunction} LineSum_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro FileJoinCall _FILE1 _FILE2 _FILE3
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE1}`
	Push `${_FILE2}`
	Push `${_FILE3}`
	${CallArtificialFunction} FileJoin_
	!verbose pop
!macroend

!macro TextCompareCall _FILE1 _FILE2 _OPTION _FUNC
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push $0
	Push `${_FILE1}`
	Push `${_FILE2}`
	Push `${_OPTION}`
	GetFunctionAddress $0 `${_FUNC}`
	Push `$0`
	${CallArtificialFunction} TextCompare_
	Pop $0
	!verbose pop
!macroend

!macro TextCompareSCall _FILE1 _FILE2 _OPTION _FUNC
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push $0
	Push `${_FILE1}`
	Push `${_FILE2}`
	Push `${_OPTION}`
	GetFunctionAddress $0 `${_FUNC}`
	Push `$0`
	${CallArtificialFunction} TextCompareS_
	Pop $0
	!verbose pop
!macroend

!macro ConfigReadCall _FILE _ENTRY _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	Push `${_ENTRY}`
	${CallArtificialFunction} ConfigRead_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro ConfigReadSCall _FILE _ENTRY _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	Push `${_ENTRY}`
	${CallArtificialFunction} ConfigReadS_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro ConfigWriteCall _FILE _ENTRY _VALUE _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	Push `${_ENTRY}`
	Push `${_VALUE}`
	${CallArtificialFunction} ConfigWrite_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro ConfigWriteSCall _FILE _ENTRY _VALUE _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	Push `${_ENTRY}`
	Push `${_VALUE}`
	${CallArtificialFunction} ConfigWriteS_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro FileRecodeCall _FILE _FORMAT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	Push `${_FORMAT}`
	${CallArtificialFunction} FileRecode_
	!verbose pop
!macroend

!macro TrimNewLinesCall _FILE _RESULT
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}
	Push `${_FILE}`
	${CallArtificialFunction} TrimNewLines_
	Pop ${_RESULT}
	!verbose pop
!macroend

!macro _TextFunc_TempFileForFile _FILE _RESULT
	# XXX replace with GetParent
	Push `${_FILE}`
	Exch $0
	Push $1
	Push $2

	StrCpy $2 $0 1 -1
	StrCmp $2 '\' 0 +3
	StrCpy $0 $0 -1
	goto -3

	StrCpy $1 0
	IntOp $1 $1 - 1
	StrCpy $2 $0 1 $1
	StrCmp $2 '\' +2
	StrCmp $2 '' 0 -3
	StrCpy $0 $0 $1

	Pop $2
	Pop $1
	Exch $0
	Pop ${_RESULT}
	# XXX
	StrCmp ${_RESULT} "" 0 +2
		StrCpy ${_RESULT} $EXEDIR
	GetTempFileName ${_RESULT} ${_RESULT}
	StrCmp ${_RESULT} "" 0 +2
		GetTempFileName ${_RESULT}
	ClearErrors
!macroend

!define LineFind `!insertmacro LineFindCall`
!define un.LineFind `!insertmacro LineFindCall`

!macro LineFind
!macroend

!macro un.LineFind
!macroend

!macro LineFind_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $3
	Exch
	Exch $2
	Exch
	Exch 2
	Exch $1
	Exch 2
	Exch 3
	Exch $0
	Exch 3
	Push $4
	Push $5
	Push $6
	Push $7
	Push $8
	Push $9
	Push $R4
	Push $R5
	Push $R6
	Push $R7
	Push $R8
	Push $R9
	ClearErrors

	IfFileExists '$0' 0 TextFunc_LineFind_error
	StrCmp $1 '/NUL' TextFunc_LineFind_begin
	StrCpy $8 0
	IntOp $8 $8 - 1
	StrCpy $9 $1 1 $8
	StrCmp $9 \ +2
	StrCmp $9 '' +3 -3
	StrCpy $9 $1 $8
	IfFileExists '$9\*.*' 0 TextFunc_LineFind_error

	TextFunc_LineFind_begin:
	StrCpy $4 1
	StrCpy $5 -1
	StrCpy $6 0
	StrCpy $7 0
	StrCpy $R4 ''
	StrCpy $R6 ''
	StrCpy $R7 ''
	StrCpy $R8 0

	StrCpy $8 $2 1
	StrCmp $8 '{' 0 TextFunc_LineFind_delspaces
	StrCpy $2 $2 '' 1
	StrCpy $8 $2 1 -1
	StrCmp $8 '}' 0 TextFunc_LineFind_delspaces
	StrCpy $2 $2 -1
	StrCpy $R6 TextFunc_LineFind_cut

	TextFunc_LineFind_delspaces:
	StrCpy $8 $2 1
	StrCmp $8 ' ' 0 +3
	StrCpy $2 $2 '' 1
	goto -3
	StrCmp $2$7 '0' TextFunc_LineFind_file
	StrCpy $4 ''
	StrCpy $5 ''
	StrCmp $2 '' TextFunc_LineFind_writechk

	TextFunc_LineFind_range:
	StrCpy $8 0
	StrCpy $9 $2 1 $8
	StrCmp $9 '' +5
	StrCmp $9 ' ' +4
	StrCmp $9 ':' +3
	IntOp $8 $8 + 1
	goto -5
	StrCpy $5 $2 $8
	IntOp $5 $5 + 0
	IntOp $8 $8 + 1
	StrCpy $2 $2 '' $8
	StrCmp $4 '' 0 +2
	StrCpy $4 $5
	StrCmp $9 ':' TextFunc_LineFind_range

	IntCmp $4 0 0 +2
	IntCmp $5 -1 TextFunc_LineFind_goto 0 TextFunc_LineFind_growthcmp
	StrCmp $R7 '' 0 TextFunc_LineFind_minus2plus
	StrCpy $R7 0
	FileOpen $8 $0 r
	FileRead $8 $9
	IfErrors +3
	IntOp $R7 $R7 + 1
	Goto -3
	FileClose $8

	TextFunc_LineFind_minus2plus:
	IntCmp $4 0 +5 0 +5
	IntOp $4 $R7 + $4
	IntOp $4 $4 + 1
	IntCmp $4 0 +2 0 +2
	StrCpy $4 0
	IntCmp $5 -1 TextFunc_LineFind_goto 0 TextFunc_LineFind_growthcmp
	IntOp $5 $R7 + $5
	IntOp $5 $5 + 1
	TextFunc_LineFind_growthcmp:
	IntCmp $4 $5 TextFunc_LineFind_goto TextFunc_LineFind_goto
	StrCpy $5 $4
	TextFunc_LineFind_goto:
	goto $7

	TextFunc_LineFind_file:
	StrCmp $1 '/NUL' TextFunc_LineFind_notemp
	!insertmacro _TextFunc_TempFileForFile $1 $R4
	Push $R4
	FileOpen $R4 $R4 w
	TextFunc_LineFind_notemp:
	FileOpen $R5 $0 r
	IfErrors TextFunc_LineFind_preerror

	TextFunc_LineFind_loop:
	IntOp $R8 $R8 + 1
	FileRead $R5 $R9
	IfErrors TextFunc_LineFind_handleclose

	TextFunc_LineFind_cmp:
	StrCmp $2$4$5 '' TextFunc_LineFind_writechk
	IntCmp $4 $R8 TextFunc_LineFind_call 0 TextFunc_LineFind_writechk
	StrCmp $5 -1 TextFunc_LineFind_call
	IntCmp $5 $R8 TextFunc_LineFind_call 0 TextFunc_LineFind_call

	GetLabelAddress $7 TextFunc_LineFind_cmp
	goto TextFunc_LineFind_delspaces

	TextFunc_LineFind_call:
	StrCpy $7 $R9
	Push $0
	Push $1
	Push $2
	Push $3
	Push $4
	Push $5
	Push $6
	Push $7
	Push $R4
	Push $R5
	Push $R6
	Push $R7
	Push $R8
	StrCpy $R6 '$4:$5'
	StrCmp $R7 '' +3
	IntOp $R7 $R8 - $R7
	IntOp $R7 $R7 - 1
	Call $3
	Pop $9
	Pop $R8
	Pop $R7
	Pop $R6
	Pop $R5
	Pop $R4
	Pop $7
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Pop $0
	IfErrors TextFunc_LineFind_preerror
	StrCmp $9 'StopLineFind' 0 +3
	IntOp $6 $6 + 1
	goto TextFunc_LineFind_handleclose
	StrCmp $1 '/NUL' TextFunc_LineFind_loop
	StrCmp $9 'SkipWrite' 0 +3
	IntOp $6 $6 + 1
	goto TextFunc_LineFind_loop
	StrCmp $7 $R9 TextFunc_LineFind_write
	IntOp $6 $6 + 1
	goto TextFunc_LineFind_write

	TextFunc_LineFind_writechk:
	StrCmp $1 '/NUL' TextFunc_LineFind_loop
	StrCmp $R6 TextFunc_LineFind_cut 0 TextFunc_LineFind_write
	IntOp $6 $6 + 1
	goto TextFunc_LineFind_loop

	TextFunc_LineFind_write:
	FileWrite $R4 $R9
	goto TextFunc_LineFind_loop

	TextFunc_LineFind_preerror:
	SetErrors

	TextFunc_LineFind_handleclose:
	StrCmp $1 '/NUL' +3
	FileClose $R4
	Pop $R4
	FileClose $R5
	IfErrors TextFunc_LineFind_error

	StrCmp $1 '/NUL' TextFunc_LineFind_end
	StrCmp $1 '' 0 +2
	StrCpy $1 $0
	StrCmp $6 0 0 TextFunc_LineFind_rename
	FileOpen $7 $0 r
	FileSeek $7 0 END $8
	FileClose $7
	FileOpen $7 $R4 r
	FileSeek $7 0 END $9
	FileClose $7
	IntCmp $8 $9 0 TextFunc_LineFind_rename
	Delete $R4
	StrCmp $1 $0 TextFunc_LineFind_end
	CopyFiles /SILENT $0 $1
	goto TextFunc_LineFind_end

	TextFunc_LineFind_rename:
	Delete '$EXEDIR\$1'
	Rename $R4 '$EXEDIR\$1'
	IfErrors 0 TextFunc_LineFind_end
	Delete $1
	Rename $R4 $1
	IfErrors 0 TextFunc_LineFind_end

	TextFunc_LineFind_error:
	SetErrors

	TextFunc_LineFind_end:
	Pop $R9
	Pop $R8
	Pop $R7
	Pop $R6
	Pop $R5
	Pop $R4
	Pop $9
	Pop $8
	Pop $7
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Pop $0

	!verbose pop
!macroend

!define LineRead `!insertmacro LineReadCall`
!define un.LineRead `!insertmacro LineReadCall`

!macro LineRead
!macroend

!macro un.LineRead
!macroend

!macro LineRead_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $1
	Exch
	Exch $0
	Exch
	Push $2
	Push $3
	Push $4
	ClearErrors

	IfFileExists $0 0 TextFunc_LineRead_error
	IntOp $1 $1 + 0
	IntCmp $1 0 TextFunc_LineRead_error 0 TextFunc_LineRead_plus
	StrCpy $4 0
	FileOpen $2 $0 r
	IfErrors TextFunc_LineRead_error
	FileRead $2 $3
	IfErrors +3
	IntOp $4 $4 + 1
	Goto -3
	FileClose $2
	IntOp $1 $4 + $1
	IntOp $1 $1 + 1
	IntCmp $1 0 TextFunc_LineRead_error TextFunc_LineRead_error

	TextFunc_LineRead_plus:
	FileOpen $2 $0 r
	IfErrors TextFunc_LineRead_error
	StrCpy $3 0
	IntOp $3 $3 + 1
	FileRead $2 $0
	IfErrors +4
	StrCmp $3 $1 0 -3
	FileClose $2
	goto TextFunc_LineRead_end
	FileClose $2

	TextFunc_LineRead_error:
	SetErrors
	StrCpy $0 ''

	TextFunc_LineRead_end:
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Exch $0

	!verbose pop
!macroend

!define FileReadFromEnd `!insertmacro FileReadFromEndCall`
!define un.FileReadFromEnd `!insertmacro FileReadFromEndCall`

!macro FileReadFromEnd
!macroend

!macro un.FileReadFromEnd
!macroend

!macro FileReadFromEnd_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $1
	Exch
	Exch $0
	Exch
	Push $7
	Push $8
	Push $9
	ClearErrors

	StrCpy $7 -1
	StrCpy $8 0
	IfFileExists $0 0 TextFunc_FileReadFromEnd_error
	FileOpen $0 $0 r
	IfErrors TextFunc_FileReadFromEnd_error
	FileRead $0 $9
	IfErrors +4
	Push $9
	IntOp $8 $8 + 1
	goto -4
	FileClose $0

	TextFunc_FileReadFromEnd_nextline:
	StrCmp $8 0 TextFunc_FileReadFromEnd_end
	Pop $9
	Push $1
	Push $7
	Push $8
	Call $1
	Pop $0
	Pop $8
	Pop $7
	Pop $1
	IntOp $7 $7 - 1
	IntOp $8 $8 - 1
	IfErrors TextFunc_FileReadFromEnd_error
	StrCmp $0 'StopFileReadFromEnd' TextFunc_FileReadFromEnd_clearstack TextFunc_FileReadFromEnd_nextline

	TextFunc_FileReadFromEnd_error:
	SetErrors

	TextFunc_FileReadFromEnd_clearstack:
	StrCmp $8 0 TextFunc_FileReadFromEnd_end
	Pop $9
	IntOp $8 $8 - 1
	goto TextFunc_FileReadFromEnd_clearstack

	TextFunc_FileReadFromEnd_end:
	Pop $9
	Pop $8
	Pop $7
	Pop $1
	Pop $0

	!verbose pop
!macroend

!define LineSum `!insertmacro LineSumCall`
!define un.LineSum `!insertmacro LineSumCall`

!macro LineSum
!macroend

!macro un.LineSum
!macroend

!macro LineSum_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $0
	Push $1
	Push $2
	ClearErrors

	IfFileExists $0 0 TextFunc_LineSum_error
	StrCpy $2 0
	FileOpen $0 $0 r
	IfErrors TextFunc_LineSum_error
	FileRead $0 $1
	IfErrors +3
	IntOp $2 $2 + 1
	Goto -3
	FileClose $0
	StrCpy $0 $2
	goto TextFunc_LineSum_end

	TextFunc_LineSum_error:
	SetErrors
	StrCpy $0 ''

	TextFunc_LineSum_end:
	Pop $2
	Pop $1
	Exch $0

	!verbose pop
!macroend

!define FileJoin `!insertmacro FileJoinCall`
!define un.FileJoin `!insertmacro FileJoinCall`

!macro FileJoin
!macroend

!macro un.FileJoin
!macroend

!macro FileJoin_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $2
	Exch
	Exch $1
	Exch
	Exch 2
	Exch $0
	Exch 2
	Push $3
	Push $4
	Push $5
	ClearErrors

	IfFileExists $0 0 TextFunc_FileJoin_error
	IfFileExists $1 0 TextFunc_FileJoin_error
	StrCpy $3 0
	IntOp $3 $3 - 1
	StrCpy $4 $2 1 $3
	StrCmp $4 \ +2
	StrCmp $4 '' +3 -3
	StrCpy $4 $2 $3
	IfFileExists '$4\*.*' 0 TextFunc_FileJoin_error

	StrCmp $2 $0 0 +2
	StrCpy $2 ''
	StrCmp $2 '' 0 +3
	StrCpy $4 $0
	Goto TextFunc_FileJoin_notemp
	!insertmacro _TextFunc_TempFileForFile $2 $4
	CopyFiles /SILENT $0 $4
	TextFunc_FileJoin_notemp:
	FileOpen $3 $4 a
	IfErrors TextFunc_FileJoin_error
	FileSeek $3 -1 END
	FileRead $3 $5
	StrCmp $5 '$\r' +3
	StrCmp $5 '$\n' +2
	FileWrite $3 '$\r$\n'

	;FileWrite $3 '$\r$\n--Divider--$\r$\n'

	FileOpen $0 $1 r
	IfErrors TextFunc_FileJoin_error
	FileRead $0 $5
	IfErrors +3
	FileWrite $3 $5
	goto -3
	FileClose $0
	FileClose $3
	StrCmp $2 '' TextFunc_FileJoin_end
	Delete '$EXEDIR\$2'
	Rename $4 '$EXEDIR\$2'
	IfErrors 0 TextFunc_FileJoin_end
	Delete $2
	Rename $4 $2
	IfErrors 0 TextFunc_FileJoin_end

	TextFunc_FileJoin_error:
	SetErrors

	TextFunc_FileJoin_end:
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Pop $0

	!verbose pop
!macroend

!macro TextCompareBody _TEXTFUNC_S
	Exch $3
	Exch
	Exch $2
	Exch
	Exch 2
	Exch $1
	Exch 2
	Exch 3
	Exch $0
	Exch 3
	Push $4
	Push $5
	Push $6
	Push $7
	Push $8
	Push $9
	ClearErrors

	IfFileExists $0 0 TextFunc_TextCompare${_TEXTFUNC_S}_error
	IfFileExists $1 0 TextFunc_TextCompare${_TEXTFUNC_S}_error
	StrCmp $2 'FastDiff' +5
	StrCmp $2 'FastEqual' +4
	StrCmp $2 'SlowDiff' +3
	StrCmp $2 'SlowEqual' +2
	goto TextFunc_TextCompare${_TEXTFUNC_S}_error

	FileOpen $4 $0 r
	IfErrors TextFunc_TextCompare${_TEXTFUNC_S}_error
	FileOpen $5 $1 r
	IfErrors TextFunc_TextCompare${_TEXTFUNC_S}_error
	SetDetailsPrint textonly

	StrCpy $6 0
	StrCpy $8 0

	TextFunc_TextCompare${_TEXTFUNC_S}_nextline:
	StrCmp${_TEXTFUNC_S} $4 '' TextFunc_TextCompare${_TEXTFUNC_S}_fast
	IntOp $8 $8 + 1
	FileRead $4 $9
	IfErrors 0 +4
	FileClose $4
	StrCpy $4 ''
	StrCmp${_TEXTFUNC_S} $5 '' TextFunc_TextCompare${_TEXTFUNC_S}_end
	StrCmp $2 'FastDiff' TextFunc_TextCompare${_TEXTFUNC_S}_fast
	StrCmp $2 'FastEqual' TextFunc_TextCompare${_TEXTFUNC_S}_fast TextFunc_TextCompare${_TEXTFUNC_S}_slow

	TextFunc_TextCompare${_TEXTFUNC_S}_fast:
	StrCmp${_TEXTFUNC_S} $5 '' TextFunc_TextCompare${_TEXTFUNC_S}_call
	IntOp $6 $6 + 1
	FileRead $5 $7
	IfErrors 0 +5
	FileClose $5
	StrCpy $5 ''
	StrCmp${_TEXTFUNC_S} $4 '' TextFunc_TextCompare${_TEXTFUNC_S}_end
	StrCmp $2 'FastDiff' TextFunc_TextCompare${_TEXTFUNC_S}_call TextFunc_TextCompare${_TEXTFUNC_S}_close
	StrCmp $2 'FastDiff' 0 +2
	StrCmp${_TEXTFUNC_S} $7 $9 TextFunc_TextCompare${_TEXTFUNC_S}_nextline TextFunc_TextCompare${_TEXTFUNC_S}_call
	StrCmp${_TEXTFUNC_S} $7 $9 TextFunc_TextCompare${_TEXTFUNC_S}_call TextFunc_TextCompare${_TEXTFUNC_S}_nextline

	TextFunc_TextCompare${_TEXTFUNC_S}_slow:
	StrCmp${_TEXTFUNC_S} $4 '' TextFunc_TextCompare${_TEXTFUNC_S}_close
	StrCpy $6 ''
	DetailPrint '$8. $9'
	FileSeek $5 0

	TextFunc_TextCompare${_TEXTFUNC_S}_slownext:
	FileRead $5 $7
	IfErrors 0 +2
	StrCmp $2 'SlowDiff' TextFunc_TextCompare${_TEXTFUNC_S}_call TextFunc_TextCompare${_TEXTFUNC_S}_nextline
	StrCmp $2 'SlowDiff' 0 +2
	StrCmp${_TEXTFUNC_S} $7 $9 TextFunc_TextCompare${_TEXTFUNC_S}_nextline TextFunc_TextCompare${_TEXTFUNC_S}_slownext
	IntOp $6 $6 + 1
	StrCmp${_TEXTFUNC_S} $7 $9 0 TextFunc_TextCompare${_TEXTFUNC_S}_slownext

	TextFunc_TextCompare${_TEXTFUNC_S}_call:
	Push $2
	Push $3
	Push $4
	Push $5
	Push $6
	Push $7
	Push $8
	Push $9
	Call $3
	Pop $0
	Pop $9
	Pop $8
	Pop $7
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	StrCmp $0 'StopTextCompare' 0 TextFunc_TextCompare${_TEXTFUNC_S}_nextline

	TextFunc_TextCompare${_TEXTFUNC_S}_close:
	FileClose $4
	FileClose $5
	goto TextFunc_TextCompare${_TEXTFUNC_S}_end

	TextFunc_TextCompare${_TEXTFUNC_S}_error:
	SetErrors

	TextFunc_TextCompare${_TEXTFUNC_S}_end:
	SetDetailsPrint both
	Pop $9
	Pop $8
	Pop $7
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Pop $0
!macroend

!define TextCompare `!insertmacro TextCompareCall`
!define un.TextCompare `!insertmacro TextCompareCall`

!macro TextCompare
!macroend

!macro un.TextCompare
!macroend

!macro TextCompare_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	!insertmacro TextCompareBody ''

	!verbose pop
!macroend

!define TextCompareS `!insertmacro TextCompareSCall`
!define un.TextCompareS `!insertmacro TextCompareSCall`

!macro TextCompareS
!macroend

!macro un.TextCompareS
!macroend

!macro TextCompareS_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	!insertmacro TextCompareBody 'S'

	!verbose pop
!macroend

!macro ConfigReadBody _TEXTFUNC_S
	Exch $1
	Exch
	Exch $0
	Exch
	Push $2
	Push $3
	Push $4
	ClearErrors

	FileOpen $2 $0 r
	IfErrors TextFunc_ConfigRead${_TEXTFUNC_S}_error
	StrLen $0 $1
	StrCmp${_TEXTFUNC_S} $0 0 TextFunc_ConfigRead${_TEXTFUNC_S}_error

	TextFunc_ConfigRead${_TEXTFUNC_S}_readnext:
	FileRead $2 $3
	IfErrors TextFunc_ConfigRead${_TEXTFUNC_S}_error
	StrCpy $4 $3 $0
	StrCmp${_TEXTFUNC_S} $4 $1 0 TextFunc_ConfigRead${_TEXTFUNC_S}_readnext
	StrCpy $0 $3 '' $0
	StrCpy $4 $0 1 -1
	StrCmp${_TEXTFUNC_S} $4 '$\r' +2
	StrCmp${_TEXTFUNC_S} $4 '$\n' 0 TextFunc_ConfigRead${_TEXTFUNC_S}_close
	StrCpy $0 $0 -1
	goto -4

	TextFunc_ConfigRead${_TEXTFUNC_S}_error:
	SetErrors
	StrCpy $0 ''

	TextFunc_ConfigRead${_TEXTFUNC_S}_close:
	FileClose $2

	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Exch $0
!macroend

!define ConfigRead `!insertmacro ConfigReadCall`
!define un.ConfigRead `!insertmacro ConfigReadCall`

!macro ConfigRead
!macroend

!macro un.ConfigRead
!macroend

!macro ConfigRead_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	!insertmacro ConfigReadBody ''

	!verbose pop
!macroend

!define ConfigReadS `!insertmacro ConfigReadSCall`
!define un.ConfigReadS `!insertmacro ConfigReadSCall`

!macro ConfigReadS
!macroend

!macro un.ConfigReadS
!macroend

!macro ConfigReadS_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	!insertmacro ConfigReadBody 'S'

	!verbose pop
!macroend

!macro ConfigWriteBody _TEXTFUNC_S
	Exch $2
	Exch
	Exch $1
	Exch
	Exch 2
	Exch $0
	Exch 2
	Push $3
	Push $4
	Push $5
	Push $6
	ClearErrors

	IfFileExists $0 0 TextFunc_ConfigWrite${_TEXTFUNC_S}_error
	FileOpen $3 $0 a
	IfErrors TextFunc_ConfigWrite${_TEXTFUNC_S}_error

	StrLen $0 $1
	StrCmp${_TEXTFUNC_S} $0 0 0 TextFunc_ConfigWrite${_TEXTFUNC_S}_readnext
	StrCpy $0 ''
	goto TextFunc_ConfigWrite${_TEXTFUNC_S}_close

	TextFunc_ConfigWrite${_TEXTFUNC_S}_readnext:
	FileRead $3 $4
	IfErrors TextFunc_ConfigWrite${_TEXTFUNC_S}_add
	StrCpy $5 $4 $0
	StrCmp${_TEXTFUNC_S} $5 $1 0 TextFunc_ConfigWrite${_TEXTFUNC_S}_readnext

	StrCpy $5 0
	IntOp $5 $5 - 1
	StrCpy $6 $4 1 $5
	StrCmp${_TEXTFUNC_S} $6 '$\r' -2
	StrCmp${_TEXTFUNC_S} $6 '$\n' -3
	StrCpy $6 $4
	StrCmp${_TEXTFUNC_S} $5 -1 +3
	IntOp $5 $5 + 1
	StrCpy $6 $4 $5

	StrCmp${_TEXTFUNC_S} $2 '' TextFunc_ConfigWrite${_TEXTFUNC_S}_change
	StrCmp${_TEXTFUNC_S} $6 '$1$2' 0 TextFunc_ConfigWrite${_TEXTFUNC_S}_change
	StrCpy $0 SAME
	goto TextFunc_ConfigWrite${_TEXTFUNC_S}_close

	TextFunc_ConfigWrite${_TEXTFUNC_S}_change:
	FileSeek $3 0 CUR $5
	StrLen $4 $4
	IntOp $4 $5 - $4
	FileSeek $3 0 END $6
	IntOp $6 $6 - $5

	System::Alloc $6
	Pop $0
	FileSeek $3 $5 SET
	System::Call 'kernel32::ReadFile(i r3, i r0, i $6, t.,)'
	FileSeek $3 $4 SET
	StrCmp${_TEXTFUNC_S} $2 '' +2
	FileWrite $3 '$1$2$\r$\n'
	System::Call 'kernel32::WriteFile(i r3, i r0, i $6, t.,)'
	System::Call 'kernel32::SetEndOfFile(i r3)'
	System::Free $0
	StrCmp${_TEXTFUNC_S} $2 '' +3
	StrCpy $0 CHANGED
	goto TextFunc_ConfigWrite${_TEXTFUNC_S}_close
	StrCpy $0 DELETED
	goto TextFunc_ConfigWrite${_TEXTFUNC_S}_close

	TextFunc_ConfigWrite${_TEXTFUNC_S}_add:
	StrCmp${_TEXTFUNC_S} $2 '' 0 +3
	StrCpy $0 SAME
	goto TextFunc_ConfigWrite${_TEXTFUNC_S}_close
	FileSeek $3 -1 END
	FileRead $3 $4
	IfErrors +4
	StrCmp${_TEXTFUNC_S} $4 '$\r' +3
	StrCmp${_TEXTFUNC_S} $4 '$\n' +2
	FileWrite $3 '$\r$\n'
	FileWrite $3 '$1$2$\r$\n'
	StrCpy $0 ADDED

	TextFunc_ConfigWrite${_TEXTFUNC_S}_close:
	FileClose $3
	goto TextFunc_ConfigWrite${_TEXTFUNC_S}_end

	TextFunc_ConfigWrite${_TEXTFUNC_S}_error:
	SetErrors
	StrCpy $0 ''

	TextFunc_ConfigWrite${_TEXTFUNC_S}_end:
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Exch $0
!macroend

!define ConfigWrite `!insertmacro ConfigWriteCall`
!define un.ConfigWrite `!insertmacro ConfigWriteCall`

!macro ConfigWrite
!macroend

!macro un.ConfigWrite
!macroend

!macro ConfigWrite_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	!insertmacro ConfigWriteBody ''

	!verbose pop
!macroend

!define ConfigWriteS `!insertmacro ConfigWriteSCall`
!define un.ConfigWriteS `!insertmacro ConfigWriteSCall`

!macro ConfigWriteS
!macroend

!macro un.ConfigWriteS
!macroend

!macro ConfigWriteS_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	!insertmacro ConfigWriteBody 'S'

	!verbose pop
!macroend

!define FileRecode `!insertmacro FileRecodeCall`
!define un.FileRecode `!insertmacro FileRecodeCall`

!macro FileRecode
!macroend

!macro un.FileRecode
!macroend

!macro FileRecode_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $1
	Exch
	Exch $0
	Exch
	Push $2
	Push $3
	Push $4

	IfFileExists $0 0 TextFunc_FileRecode_error
	StrCmp $1 OemToChar +2
	StrCmp $1 CharToOem 0 TextFunc_FileRecode_error

	FileOpen $2 $0 a
	FileSeek $2 0 END $3
	System::Alloc $3
	Pop $4
	FileSeek $2 0 SET
	System::Call 'kernel32::ReadFile(i r2, i r4, i $3, t.,)'
	System::Call 'user32::$1Buff(i r4, i r4, i $3)'
	FileSeek $2 0 SET
	System::Call 'kernel32::WriteFile(i r2, i r4, i $3, t.,)'
	System::Free $4
	FileClose $2
	goto TextFunc_FileRecode_end

	TextFunc_FileRecode_error:
	SetErrors

	TextFunc_FileRecode_end:
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Pop $0

	!verbose pop
!macroend

!define TrimNewLines `!insertmacro TrimNewLinesCall`
!define un.TrimNewLines `!insertmacro TrimNewLinesCall`

!macro TrimNewLines
!macroend

!macro un.TrimNewLines
!macroend

!macro TrimNewLines_
	!verbose push
	!verbose ${_TEXTFUNC_VERBOSE}

	Exch $0
	Push $1
	Push $2

	StrCpy $1 0
	IntOp $1 $1 - 1
	StrCpy $2 $0 1 $1
	StrCmp $2 '$\r' -2
	StrCmp $2 '$\n' -3
	StrCmp $1 -1 +3
	IntOp $1 $1 + 1
	StrCpy $0 $0 $1

	Pop $2
	Pop $1
	Exch $0

	!verbose pop
!macroend

!endif