12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- /*
- _____________________________________________________________________________
- 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
- !verbose push 3
- !define /IfNDef _TEXTFUNC_VERBOSE 3
- !verbose ${_TEXTFUNC_VERBOSE}
- !define TEXTFUNC_VERBOSE `!insertmacro TEXTFUNC_VERBOSE`
- !define TEXTFUNC_INCLUDED
- !include FileFunc.nsh
- !include Util.nsh
- !macro TEXTFUNC_VERBOSE _VERBOSE
- !verbose push 3
- !define /ReDef _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(p r3, p r0, i $6, t.,)'
- FileSeek $3 $4 SET
- StrCmp${_TEXTFUNC_S} $2 '' +2
- FileWrite $3 '$1$2$\r$\n'
- System::Call 'kernel32::WriteFile(p r3, p r0, i $6, t.,)'
- System::Call 'kernel32::SetEndOfFile(p 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(p r2, p r4, i $3, t.,)'
- System::Call 'user32::$1Buff(p r4, p r4, i $3)'
- FileSeek $2 0 SET
- System::Call 'kernel32::WriteFile(p r2, p 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
- !verbose pop
- !endif
|