Fixed StrFunc parameter order.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7100 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2019-06-25 20:29:04 +00:00
parent a46a79cb46
commit 21c7679ed6
3 changed files with 67 additions and 144 deletions

View file

@ -32,6 +32,29 @@ ${UnStrTok}
${UnStrTrimNewLines}
${UnStrSort}
Var SFPass
Var SFTotl
!macro EndStrFuncTestEx lbl name
IfErrors ${lbl}
DetailPrint "PASSED ${name} test"
IntOp $SFPass $SFPass + 1
IntOp $SFTotl $SFTotl + 1
Goto +3
${lbl}:
DetailPrint "FAILED ${name} test"
IntOp $SFTotl $SFTotl + 1
!macroend
!macro EndStrFuncTest name
!insertmacro EndStrFuncTestEx "${name}error" "${name}"
!macroend
CompletedText "Passed $SFPass of $SFTotl tests"
!macro CompletedAllTests
StrCmp $SFPass $SFTotl +2
SetErrorLevel 42
!macroend
!macro StackVerificationStart
StrCpy $0 S0
StrCpy $1 S1
@ -103,16 +126,13 @@ Section
${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
!insertmacro StackVerificationEnd
IfErrors strcaseerror
DetailPrint "PASSED StrCase test"
Goto +2
strcaseerror:
DetailPrint "FAILED StrCase test"
!insertmacro EndStrFuncTest StrCase
# Test clipboard function
!insertmacro StackVerificationStart
!verbose push 4
${StrClb} $0 "StrFunc clipboard test" ">"
!verbose pop
StrCmp $0 "" 0 strclberror
${StrClb} $0 "StrFunc clipboard test #2" "<>"
StrCmp $0 "StrFunc clipboard test" 0 strclberror
@ -121,12 +141,7 @@ strcaseerror:
${StrClb} $0 "" ""
StrCmp $0 "" 0 strclberror
!insertmacro StackVerificationEnd
IfErrors strclberror
DetailPrint "PASSED StrClb test"
Goto +2
strclberror:
DetailPrint "FAILED StrClb test"
!insertmacro EndStrFuncTest StrClb
# Test IO functions
!insertmacro StackVerificationStart
@ -144,13 +159,8 @@ strclberror:
!insertmacro testio ""
!insertmacro testio " "
!insertmacro StackVerificationEnd
IfErrors ioerror
DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
Goto +2
ioerror:
DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
!insertmacro EndStrFuncTestEx ioerror "StrNSISToIO/StrIOToNSIS"
# Test string search functions
!insertmacro StackVerificationStart
${StrLoc} $0 "This is just an example" "just" "<"
@ -174,12 +184,7 @@ ioerror:
${StrLoc} $0 abc d <
StrCmp $0 "" 0 strlocerror
!insertmacro StackVerificationEnd
IfErrors strlocerror
DetailPrint "PASSED StrLoc test"
Goto +2
strlocerror:
DetailPrint "FAILED StrLoc test"
!insertmacro EndStrFuncTest StrLoc
# Test string replacement
!insertmacro StackVerificationStart
@ -198,12 +203,7 @@ strlocerror:
${StrRep} $0 "test" "" ""
StrCmp $0 "test" 0 strreperror
!insertmacro StackVerificationEnd
IfErrors strreperror
DetailPrint "PASSED StrRep test"
Goto +2
strreperror:
DetailPrint "FAILED StrRep test"
!insertmacro EndStrFuncTest StrRep
# Test sorting
!insertmacro StackVerificationStart
@ -246,12 +246,7 @@ strreperror:
${StrSort} $0 "" " " "something" " " "1" "0" "1"
StrCmp $0 "" 0 strsorterror
!insertmacro StackVerificationEnd
IfErrors strsorterror
DetailPrint "PASSED StrSort test"
Goto +2
strsorterror:
DetailPrint "FAILED StrSort test"
!insertmacro EndStrFuncTest StrSort
!insertmacro StackVerificationStart
${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
@ -263,12 +258,7 @@ strsorterror:
${StrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
StrCmp $0 "" 0 strstrerror
!insertmacro StackVerificationEnd
IfErrors strstrerror
DetailPrint "PASSED StrStr test"
Goto +2
strstrerror:
DetailPrint "FAILED StrStr test"
!insertmacro EndStrFuncTest StrStr
!insertmacro StackVerificationStart
${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
@ -312,12 +302,7 @@ strstrerror:
${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
StrCmp $0 "abc" 0 strstradverror
!insertmacro StackVerificationEnd
IfErrors strstradverror
DetailPrint "PASSED StrStrAdv test"
Goto +2
strstradverror:
DetailPrint "FAILED StrStrAdv test"
!insertmacro EndStrFuncTest StrStrAdv
# Test tokenizer
!insertmacro StackVerificationStart
@ -334,29 +319,20 @@ strstradverror:
${StrTok} $0 "This is, or is not, just an example" " ," "0" "0"
StrCmp $0 "This" 0 strtokerror
!insertmacro StackVerificationEnd
IfErrors strtokerror
DetailPrint "PASSED StrTok test"
Goto +2
strtokerror:
DetailPrint "FAILED StrTok test"
!insertmacro EndStrFuncTest StrTok
# Test trim new lines
!insertmacro StackVerificationStart
${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
!insertmacro StackVerificationEnd
IfErrors strtrimnewlineserror
!insertmacro EndStrFuncTest StrTrimNewlines
DetailPrint "PASSED StrTrimNewLines test"
Goto +2
strtrimnewlineserror:
DetailPrint "FAILED StrTrimNewLines test"
WriteUninstaller $EXEDIR\UnStrFunc.exe
Exec $EXEDIR\UnStrFunc.exe
InitPluginsDir
WriteUninstaller $PluginsDir\UnStrFunc.exe
ExecWait '"$PluginsDir\UnStrFunc.exe" _?=$PluginsDir'
!insertmacro CompletedAllTests
SectionEnd
Section Uninstall
@ -382,12 +358,7 @@ Section Uninstall
${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
!insertmacro StackVerificationEnd
IfErrors strcaseerror
DetailPrint "PASSED StrCase test"
Goto +2
strcaseerror:
DetailPrint "FAILED StrCase test"
!insertmacro EndStrFuncTest StrCase
# Test clipboard function
!insertmacro StackVerificationStart
@ -400,12 +371,7 @@ strcaseerror:
${UnStrClb} $0 "" ""
StrCmp $0 "" 0 strclberror
!insertmacro StackVerificationEnd
IfErrors strclberror
DetailPrint "PASSED StrClb test"
Goto +2
strclberror:
DetailPrint "FAILED StrClb test"
!insertmacro EndStrFuncTest StrClb
# Test IO functions
!insertmacro StackVerificationStart
@ -423,12 +389,7 @@ strclberror:
!insertmacro untestio ""
!insertmacro untestio " "
!insertmacro StackVerificationEnd
IfErrors ioerror
DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
Goto +2
ioerror:
DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
!insertmacro EndStrFuncTestEx ioerror "StrNSISToIO/StrIOToNSIS"
# Test string search functions
!insertmacro StackVerificationStart
@ -453,12 +414,7 @@ ioerror:
${UnStrLoc} $0 abc d <
StrCmp $0 "" 0 strlocerror
!insertmacro StackVerificationEnd
IfErrors strlocerror
DetailPrint "PASSED StrLoc test"
Goto +2
strlocerror:
DetailPrint "FAILED StrLoc test"
!insertmacro EndStrFuncTest StrLoc
# Test string replacement
!insertmacro StackVerificationStart
@ -477,12 +433,7 @@ strlocerror:
${UnStrRep} $0 "test" "" ""
StrCmp $0 "test" 0 strreperror
!insertmacro StackVerificationEnd
IfErrors strreperror
DetailPrint "PASSED StrRep test"
Goto +2
strreperror:
DetailPrint "FAILED StrRep test"
!insertmacro EndStrFuncTest StrRep
# Test sorting
!insertmacro StackVerificationStart
@ -525,12 +476,7 @@ strreperror:
${UnStrSort} $0 "" " " "something" " " "1" "0" "1"
StrCmp $0 "" 0 strsorterror
!insertmacro StackVerificationEnd
IfErrors strsorterror
DetailPrint "PASSED StrSort test"
Goto +2
strsorterror:
DetailPrint "FAILED StrSort test"
!insertmacro EndStrFuncTest StrSort
!insertmacro StackVerificationStart
${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
@ -542,12 +488,7 @@ strsorterror:
${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
StrCmp $0 "" 0 strstrerror
!insertmacro StackVerificationEnd
IfErrors strstrerror
DetailPrint "PASSED StrStr test"
Goto +2
strstrerror:
DetailPrint "FAILED StrStr test"
!insertmacro EndStrFuncTest StrStr
!insertmacro StackVerificationStart
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
@ -591,12 +532,7 @@ strstrerror:
${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
StrCmp $0 "abc" 0 strstradverror
!insertmacro StackVerificationEnd
IfErrors strstradverror
DetailPrint "PASSED StrStrAdv test"
Goto +2
strstradverror:
DetailPrint "FAILED StrStrAdv test"
!insertmacro EndStrFuncTest StrStrAdv
# Test tokenizer
!insertmacro StackVerificationStart
@ -613,23 +549,14 @@ strstradverror:
${UnStrTok} $0 "This is, or is not, just an example" " ," "0" "0"
StrCmp $0 "This" 0 strtokerror
!insertmacro StackVerificationEnd
IfErrors strtokerror
DetailPrint "PASSED StrTok test"
Goto +2
strtokerror:
DetailPrint "FAILED StrTok test"
!insertmacro EndStrFuncTest StrTok
# Test trim new lines
!insertmacro StackVerificationStart
${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
!insertmacro StackVerificationEnd
IfErrors strtrimnewlineserror
DetailPrint "PASSED StrTrimNewLines test"
Goto +2
strtrimnewlineserror:
DetailPrint "FAILED StrTrimNewLines test"
!insertmacro EndStrFuncTest StrTrimNewLines
!insertmacro CompletedAllTests
SectionEnd

View file

@ -321,12 +321,12 @@ o-----------------------------------------------------------------------------o
# StrClb
!insertmacro STRFUNC_DEFFUNC StrClb `ResultVar|String|Action` `Output|Text|Option > < <>`
!macro STRFUNC_CALL_StrClb un ResultVar String Type
!macro STRFUNC_CALL_StrClb un ResultVar String Action
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrClb} "${ResultVar}" "${String}" "${Action}"`
!verbose 2
Push `${String}`
Push `${Type}`
Push `${Action}`
!insertmacro STRFUNC_CALL StrClb "${un}"
Pop ${ResultVar}
!verbose pop
@ -458,12 +458,11 @@ o-----------------------------------------------------------------------------o
# StrIOToNSIS
!insertmacro STRFUNC_DEFFUNC StrIOToNSIS `ResultVar|String` `Output|Text`
!macro STRFUNC_CALL_StrIOToNSIS un ResultVar String Type
!macro STRFUNC_CALL_StrIOToNSIS un ResultVar String
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrIOToNSIS} "${ResultVar}" "${String}"`
!verbose 2
Push `${String}`
Push `${Type}`
!insertmacro STRFUNC_CALL StrIOToNSIS "${un}"
Pop ${ResultVar}
!verbose pop
@ -531,7 +530,7 @@ o-----------------------------------------------------------------------------o
# StrLoc
!insertmacro STRFUNC_DEFFUNC StrLoc `ResultVar|String|StrToSearchFor|CounterDirection` `Output|Text|Text|Option > <`
!macro STRFUNC_CALL_StrLoc un ResultVar String Type
!macro STRFUNC_CALL_StrLoc un ResultVar String StrToSearchFor OffsetDirection
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrLoc} "${ResultVar}" "${String}" "${StrToSearchFor}" "${OffsetDirection}"`
!verbose 2
@ -614,7 +613,7 @@ o-----------------------------------------------------------------------------o
# StrNSISToIO
!insertmacro STRFUNC_DEFFUNC StrNSISToIO `ResultVar|String` `Output|Text`
!macro STRFUNC_CALL_StrNSISToIO un ResultVar String Type
!macro STRFUNC_CALL_StrNSISToIO un ResultVar String
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrNSISToIO} "${ResultVar}" "${String}"`
!verbose 2
@ -687,7 +686,7 @@ o-----------------------------------------------------------------------------o
# StrRep
!insertmacro STRFUNC_DEFFUNC StrRep `ResultVar|String|StrToReplace|ReplacementString` `Output|Text|Text|Text`
!macro STRFUNC_CALL_StrRep un ResultVar String Type
!macro STRFUNC_CALL_StrRep un ResultVar String StringToReplace ReplacementString
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrRep} "${ResultVar}" "${String}" "${StringToReplace}" "${ReplacementString}"`
!verbose 2
@ -790,9 +789,9 @@ o-----------------------------------------------------------------------------o
############################################################################
# StrSort
!insertmacro STRFUNC_DEFFUNC StrSort `ResultVar|String|LeftStr|CenterStr|RightStr|IncludeLeftStr|IncludeCenterStr|IncludeRightStr` `Output|Text|Text|Text|Text|Option 1 0|Option 1 0|Option 1 0`
!insertmacro STRFUNC_DEFFUNC StrSort `ResultVar|String|CenterStr|LeftStr|RightStr|IncludeLeftStr|IncludeCenterStr|IncludeRightStr` `Output|Text|Text|Text|Text|Option 1 0|Option 1 0|Option 1 0`
!macro STRFUNC_CALL_StrSort un ResultVar String Type
!macro STRFUNC_CALL_StrSort un ResultVar String CenterStr LeftStr RightStr IncludeCenterStr IncludeLeftStr IncludeRightStr
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrSort} "${ResultVar}" "${String}" "${CenterStr}" "${LeftStr}" "${RightStr}" "${IncludeCenterStr}" "${IncludeLeftStr}" "${IncludeRightStr}"`
!verbose 2
@ -1016,7 +1015,7 @@ o-----------------------------------------------------------------------------o
# StrStr
!insertmacro STRFUNC_DEFFUNC StrStr `ResultVar|String|StrToSearchFor` `Output|Text|Text`
!macro STRFUNC_CALL_StrStr un ResultVar String Type
!macro STRFUNC_CALL_StrStr un ResultVar String StrToSearchFor
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrStr} "${ResultVar}" "${String}" "${StrToSearchFor}"`
!verbose 2
@ -1089,7 +1088,7 @@ o-----------------------------------------------------------------------------o
# StrStrAdv
!insertmacro STRFUNC_DEFFUNC StrStrAdv `ResultVar|String|StrToSearchFor|SearchDirection|ResultStrDirection|DisplayStrToSearch|Loops|CaseSensitive` `Output|Text|Text|Option > <|Option > <|Option 1 0|Text|Option 0 1`
!macro STRFUNC_CALL_StrStrAdv un ResultVar String Type
!macro STRFUNC_CALL_StrStrAdv un ResultVar String StrToSearchFor SearchDirection ResultStrDirection DisplayStrToSearch Loops CaseSensitive
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrStrAdv} "${ResultVar}" "${String}" "${StrToSearchFor}" "${SearchDirection}" "${ResultStrDirection}" "${DisplayStrToSearch}" "${Loops}" "${CaseSensitive}"`
!verbose 2
@ -1369,7 +1368,7 @@ o-----------------------------------------------------------------------------o
# StrTok
!insertmacro STRFUNC_DEFFUNC StrTok `ResultVar|String|Separators|ResultPart|SkipEmptyParts` `Output|Text|Text|Mixed L|Option 1 0`
!macro STRFUNC_CALL_StrTok un ResultVar String Type
!macro STRFUNC_CALL_StrTok un ResultVar String Separators ResultPart SkipEmptyParts
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrTok} "${ResultVar}" "${String}" "${Separators}" "${ResultPart}" "${SkipEmptyParts}"`
!verbose 2
@ -1529,14 +1528,11 @@ o-----------------------------------------------------------------------------o
# StrTrimNewLines
!insertmacro STRFUNC_DEFFUNC StrTrimNewLines `ResultVar|String` `Output|Text`
!macro STRFUNC_CALL_StrTrimNewLines un ResultVar String Type
!macro STRFUNC_CALL_StrTrimNewLines un ResultVar String
!verbose push ${STRFUNC_VERBOSITY}
!echo `${U+24}{${un}StrTrimNewLines} "${ResultVar}" "${String}"`
!verbose 2
Push `${String}`
Push `${Separators}`
Push `${ResultPart}`
Push `${SkipEmptyParts}`
!insertmacro STRFUNC_CALL StrTrimNewLines "${un}"
Pop ${ResultVar}
!verbose pop

View file

@ -328,7 +328,7 @@ How to use
=========================================================================
*** ${StrSort}
-------------------------------------------------------------------------
ResultVar String LeftStr CenterStr RightStr IncludeLeftStr(1|0)
ResultVar String CenterStr LeftStr RightStr IncludeLeftStr(1|0)
IncludeCenterStr(1|0) IncludeRightStr(1|0)
=========================================================================
Searches for "CenterStr" in "String", and returns only the value
@ -344,14 +344,14 @@ How to use
String
String where to search "CenterStr".
CenterStr
String to search in "String".
LeftStr
The first occurrence of "LeftStr" on the left of "CenterStr".
If it is an empty value, or was not found, will return
everything on the left of "CenterStr".
CenterStr
String to search in "String".
RightStr
The first occurrence of "RightStr" on the right of "CenterStr".
If it is an empty value, or was not found, will return