StrFunc 1.09 by deguix:

- Fixed stack problems involving: StrCase, StrRep, StrSort, StrTok.
 - Fixed StrClb: When "Action" = "<>", handle was wrongly outputed as text.
 - Fixed StrSort, StrStrAdv documentation examples.
 - Fixed StrIOToNSIS, StrLoc, StrNSISToIO, StrRep, StrStr: sometimes didn't find "StrToSearch" at all.


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3746 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-10-22 23:52:01 +00:00
parent 42af15470f
commit eb00ff12cc
3 changed files with 288 additions and 153 deletions

View file

@ -31,12 +31,60 @@ ${UnStrTok}
${UnStrTrimNewLines}
${UnStrSort}
!macro StackVerificationStart
StrCpy $0 S0
StrCpy $1 S1
StrCpy $2 S2
StrCpy $3 S3
StrCpy $4 S4
StrCpy $5 S5
StrCpy $6 S6
StrCpy $7 S7
StrCpy $8 S8
StrCpy $9 S9
StrCpy $R0 SR0
StrCpy $R1 SR1
StrCpy $R2 SR2
StrCpy $R3 SR3
StrCpy $R4 SR4
StrCpy $R5 SR5
StrCpy $R6 SR6
StrCpy $R7 SR7
StrCpy $R8 SR8
StrCpy $R9 SR9
!macroend
!macro StackVerificationEnd
ClearErrors
${If} $1 != "S1"
${OrIf} $2 != "S2"
${OrIf} $3 != "S3"
${OrIf} $4 != "S4"
${OrIf} $5 != "S5"
${OrIf} $6 != "S6"
${OrIf} $7 != "S7"
${OrIf} $8 != "S8"
${OrIf} $9 != "S9"
${OrIf} $R0 != "SR0"
${OrIf} $R1 != "SR1"
${OrIf} $R2 != "SR2"
${OrIf} $R3 != "SR3"
${OrIf} $R4 != "SR4"
${OrIf} $R5 != "SR5"
${OrIf} $R6 != "SR6"
${OrIf} $R7 != "SR7"
${OrIf} $R8 != "SR8"
${OrIf} $R9 != "SR9"
SetErrors
${EndIf}
!macroend
Section
# Test case conversion
!insertmacro StackVerificationStart
${StrCase} $0 "This is just an example. A very simple one." ""
StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
${StrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
${StrCase} $0 "This is just an example. A very simple one." "L"
@ -47,15 +95,14 @@ Section
StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
${StrCase} $0 "This is just an example. A very simple one." "<>"
StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
${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
@ -63,16 +110,25 @@ strcaseerror:
DetailPrint "FAILED StrCase test"
# Test clipboard function
!insertmacro StackVerificationStart
${StrClb} $0 "StrFunc clipboard test" ">"
${StrClb} $0 "" "<"
StrCmp $0 "" 0 strclberror
${StrClb} $0 "StrFunc clipboard test #2" "<>"
StrCmp $0 "StrFunc clipboard test" 0 strclberror
${StrClb} $0 "" "<"
StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
${StrClb} $0 "" ""
StrCmp $0 "" 0 strclberror
!insertmacro StackVerificationEnd
IfErrors strclberror
DetailPrint "PASSED StrClb test"
Goto +2
strclberror:
DetailPrint "FAILED StrClb test"
# Test IO functions
!insertmacro StackVerificationStart
!macro testio str
${StrNSISToIO} $0 "${str}"
${StrIOToNSIS} $0 $0
@ -86,12 +142,16 @@ strclberror:
!insertmacro testio "$\r \ $\t $\n $$"
!insertmacro testio ""
!insertmacro testio " "
!insertmacro StackVerificationEnd
IfErrors ioerror
DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
Goto +2
ioerror:
DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
# Test string search functions
!insertmacro StackVerificationStart
${StrLoc} $0 "This is just an example" "just" "<"
StrCmp $0 "11" 0 strlocerror
${StrLoc} $0 a abc <
@ -112,12 +172,16 @@ ioerror:
StrCmp $0 "0" 0 strlocerror
${StrLoc} $0 abc d <
StrCmp $0 "" 0 strlocerror
!insertmacro StackVerificationEnd
IfErrors strlocerror
DetailPrint "PASSED StrLoc test"
Goto +2
strlocerror:
DetailPrint "FAILED StrLoc test"
# Test string replacement
!insertmacro StackVerificationStart
${StrRep} $0 "This is just an example" "an" "one"
StrCmp $0 "This is just one example" 0 strreperror
${StrRep} $0 "test... test... 1 2 3..." "test" "testing"
@ -132,12 +196,16 @@ strlocerror:
StrCmp $0 "test" 0 strreperror
${StrRep} $0 "test" "" ""
StrCmp $0 "test" 0 strreperror
!insertmacro StackVerificationEnd
IfErrors strreperror
DetailPrint "PASSED StrRep test"
Goto +2
strreperror:
DetailPrint "FAILED StrRep test"
# Test sorting
!insertmacro StackVerificationStart
${StrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
StrCmp $0 "This is an exam" 0 strsorterror
${StrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
@ -176,11 +244,15 @@ strreperror:
StrCmp $0 " rror " 0 strsorterror
${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 StackVerificationStart
${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
@ -189,11 +261,15 @@ strsorterror:
StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
${StrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
StrCmp $0 "" 0 strstrerror
!insertmacro StackVerificationEnd
IfErrors strstrerror
DetailPrint "PASSED StrStr test"
Goto +2
strstrerror:
DetailPrint "FAILED StrStr test"
!insertmacro StackVerificationStart
${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
StrCmp $0 "abcabcabc" 0 strstradverror
${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
@ -214,7 +290,6 @@ strstrerror:
StrCmp $0 "" 0 strstradverror
${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
StrCmp $0 "abc" 0 strstradverror
${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
StrCmp $0 "abcabc" 0 strstradverror
${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
@ -235,12 +310,16 @@ strstrerror:
StrCmp $0 "" 0 strstradverror
${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"
# Test tokenizer
!insertmacro StackVerificationStart
${StrTok} $0 "This is, or is not, just an example" " ," "4" "1"
StrCmp $0 "not" 0 strtokerror
${StrTok} $0 "This is, or is not, just an example" " ," "4" "0"
@ -253,17 +332,25 @@ strstradverror:
StrCmp $0 "example" 0 strtokerror
${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"
# Test trim new lines
!insertmacro StackVerificationStart
${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
StrCmp $0 "$\r$\ntest$\r$\ntest" +3
DetailPrint "FAILED StrTrimNewLines test"
Goto +2
DetailPrint "PASSED StrTrimNewLines test"
StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
!insertmacro StackVerificationEnd
IfErrors strtrimnewlineserror
DetailPrint "PASSED StrTrimNewLines test"
Goto +2
strtrimnewlineserror:
DetailPrint "FAILED StrTrimNewLines test"
WriteUninstaller $EXEDIR\UnStrFunc.exe
@ -274,9 +361,9 @@ SectionEnd
Section Uninstall
# Test case conversion
!insertmacro StackVerificationStart
${UnStrCase} $0 "This is just an example. A very simple one." ""
StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
${UnStrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
${UnStrCase} $0 "This is just an example. A very simple one." "L"
@ -287,15 +374,14 @@ Section Uninstall
StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
${UnStrCase} $0 "This is just an example. A very simple one." "<>"
StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
${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
@ -303,9 +389,17 @@ strcaseerror:
DetailPrint "FAILED StrCase test"
# Test clipboard function
!insertmacro StackVerificationStart
${UnStrClb} $0 "StrFunc clipboard test" ">"
${UnStrClb} $0 "" "<"
StrCmp $0 "" 0 strclberror
${UnStrClb} $0 "StrFunc clipboard test #2" "<>"
StrCmp $0 "StrFunc clipboard test" 0 strclberror
${UnStrClb} $0 "" "<"
StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
${UnStrClb} $0 "" ""
StrCmp $0 "" 0 strclberror
!insertmacro StackVerificationEnd
IfErrors strclberror
DetailPrint "PASSED StrClb test"
Goto +2
@ -313,6 +407,7 @@ strclberror:
DetailPrint "FAILED StrClb test"
# Test IO functions
!insertmacro StackVerificationStart
!macro untestio str
${UnStrNSISToIO} $0 "${str}"
${UnStrIOToNSIS} $0 $0
@ -326,12 +421,16 @@ strclberror:
!insertmacro untestio "$\r \ $\t $\n $$"
!insertmacro untestio ""
!insertmacro untestio " "
!insertmacro StackVerificationEnd
IfErrors ioerror
DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
Goto +2
ioerror:
DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
# Test string search functions
!insertmacro StackVerificationStart
${UnStrLoc} $0 "This is just an example" "just" "<"
StrCmp $0 "11" 0 strlocerror
${UnStrLoc} $0 a abc <
@ -352,12 +451,16 @@ ioerror:
StrCmp $0 "0" 0 strlocerror
${UnStrLoc} $0 abc d <
StrCmp $0 "" 0 strlocerror
!insertmacro StackVerificationEnd
IfErrors strlocerror
DetailPrint "PASSED StrLoc test"
Goto +2
strlocerror:
DetailPrint "FAILED StrLoc test"
# Test string replacement
!insertmacro StackVerificationStart
${UnStrRep} $0 "This is just an example" "an" "one"
StrCmp $0 "This is just one example" 0 strreperror
${UnStrRep} $0 "test... test... 1 2 3..." "test" "testing"
@ -372,12 +475,16 @@ strlocerror:
StrCmp $0 "test" 0 strreperror
${UnStrRep} $0 "test" "" ""
StrCmp $0 "test" 0 strreperror
!insertmacro StackVerificationEnd
IfErrors strreperror
DetailPrint "PASSED StrRep test"
Goto +2
strreperror:
DetailPrint "FAILED StrRep test"
# Test sorting
!insertmacro StackVerificationStart
${UnStrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
StrCmp $0 "This is an exam" 0 strsorterror
${UnStrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
@ -416,11 +523,15 @@ strreperror:
StrCmp $0 " rror " 0 strsorterror
${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 StackVerificationStart
${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
@ -429,11 +540,15 @@ strsorterror:
StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
StrCmp $0 "" 0 strstrerror
!insertmacro StackVerificationEnd
IfErrors strstrerror
DetailPrint "PASSED StrStr test"
Goto +2
strstrerror:
DetailPrint "FAILED StrStr test"
!insertmacro StackVerificationStart
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
StrCmp $0 "abcabcabc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
@ -454,7 +569,6 @@ strstrerror:
StrCmp $0 "" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
StrCmp $0 "abc" 0 strstradverror
${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
StrCmp $0 "abcabc" 0 strstradverror
${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
@ -475,12 +589,16 @@ strstrerror:
StrCmp $0 "" 0 strstradverror
${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"
# Test tokenizer
!insertmacro StackVerificationStart
${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "1"
StrCmp $0 "not" 0 strtokerror
${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "0"
@ -493,16 +611,24 @@ strstradverror:
StrCmp $0 "example" 0 strtokerror
${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"
# Test trim new lines
!insertmacro StackVerificationStart
${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
StrCmp $0 "$\r$\ntest$\r$\ntest" +3
DetailPrint "FAILED StrTrimNewLines test"
Goto +2
DetailPrint "PASSED StrTrimNewLines test"
StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
!insertmacro StackVerificationEnd
IfErrors strtrimnewlineserror
DetailPrint "PASSED StrTrimNewLines test"
Goto +2
strtrimnewlineserror:
DetailPrint "FAILED StrTrimNewLines test"
SectionEnd