I've tried and tested the function so many times, but there's always one version string comparison kind that gets through with false results.
The last update to the function was to compare each digit of the numbers between the dots one by one. However, recently Daijoubu reported that it would fail on 7 & 10. This is because it would compare 7 with 1 and immediately think the 1st one was larger! I've fixed the problem now (which has made the function even bigger!)
I was wondering if anyone could test the function more for me, which is here:
If you find one that fails, post it here so I can see it.
Cheers
-Stu
VersionCheckNew testing
23 posts
Probably Afrow UK mean:
(which has made the function even bigger!)It's because there is check per digit per number and many exceptions. I choose other way - digits capacity in VersionCompare. I don't found any false results in VersionCheckNew (v4).
Ah yeh, sorry I posted link to edit 🙂
-Stu
-Stu
${VersionCheckNew} "91.1.1.1" "101.1.1.1" $R0$R0="1"Thanks Instructor. I found that problem a few days ago too and I think it's fixed now. It took me a few hours, but I thought of a new solution which should fix all the problems.
Uploaded as v5
-Stu
Uploaded as v5
-Stu
Very bad that you don't trying to see what do others 🙁
P.S.
P.S.
${VersionCheckV5} "1.001" "1.0" $R0$R0="2"Thanks fixed.
-Stu
-Stu
Version "1.00" is newer than "1.0". Is it supposed to be?
I'd just use Instructors VersionCompare 😛
-Stu
-Stu
Another question (general).
Why "1.1.1.1" not equal to "1.1.1.01"?
Why "1.1.1.1" not equal to "1.1.1.01"?
Because 01 is older than 1, as we go up in 01, 02, 03, to 1. 1 would be counted as "10".
-Stu
-Stu
Than, if I include in script
And use GetDllVersion - version will be 1.1.0.1. Why?VIProductVersion "1.1.0.001"
VIAddVersionKey "LegalCopyright" 'Ltd.'
VIAddVersionKey "FileDescription" "Test file"
VIAddVersionKey "FileVersion" "1.1.0.001"
NSIS treats 001 in a variable as 1 (when using IntOp)
-Stu
-Stu
Because 01 is older than 1, as we go up in 01, 02, 03, to 1. 1 would be counted as "10".My opinion is that, the extra zeros in versions are just to show how the author organizes his versions. I think, zeros should be ignored if they are on the left of the number. Example: 1.01 = 1.00001. By this reasoning, I think Afrow UK is wrong in saying that 1.01 is older than 1.1, because it's like giving the extra digit a separation mark, like the ".". With Afrow's idea, what would be newer: 1.00, 1.0 or 1?
To make a version comparasion with only numbers, it's a matter of comparing the numbers inside the four groups w/ IntCmp, nothing more (and logically converting those numbers to be supported as decimal by NSIS, because 001 is considered as an octal number).
I think, zeros should be ignored if they are on the left of the number. Example: 1.01 = 1.00001. By this reasoning, I think Afrow UK is wrong in saying that 1.01 is older than 1.1, because it's like giving the extra digit a separation mark, like the ".".Afrow UK isn't wrong:
1.01 != 1.00001, because 1.01 != 1.10
In your words NSIS 2.01 = NSIS 2.1 (it will be I hope 🙂 )
My opinion is that, the extra zeros in versions are just to show how the author organizes his versions. I think, zeros should be ignored if they are on the left of the number. Example: 1.01 = 1.00001. By this reasoning, I think Afrow UK is wrong in saying that 1.01 is older than 1.1, because it's like giving the extra digit a separation mark, like the ".".I am subscribe to this opinion.
2Instructor
Afrow UK isn't wrong:I don't agree. NSIS 2.01 has full version number 2.0.1, NSIS 2.1 wil be - 2.1.0.
1.01 != 1.00001, because 1.01 != 1.10
In your words NSIS 2.01 = NSIS 2.1 (it will be I hope 🙂)
In your words 1 kg 1000 times greater than 0001 kg.🙂😁
What sense give to the program version 1.01, if the same is 1.1? I saw only one reason: if number 1.01 compared with 1.1 it will be older 🙂
TIP: Versioning scheme as I see it...
I agree there is IMHO no sense in versioning 1.02
This is for me v1.0.2.x
Versioning scheme as I see it...
A.B.C.D
A = Product Major Version
B = Product Feature Release
C = Product Release incrementeal ID
D = Fix/Test/Debug/ for short the Build number
Example for a e.g. wordprocessor:
0.x = Initial development
1.0.0.0 = Initial Debug Release
1.0.0.57 = 57th testing build
1.0.1.1 = Initial "official" build
1.0.1.33 = 33rd fix for the official build
1.0.2.1 = Second "official" build including all bug fixes
1.1.1.278 = Now we have a spell checker
1.2.1.45 = And a thesaurus.
2.0.1.352 = And we introduced Linux compatibility because we built it with Kylix 🙂
Use this structure internally, it works very well. A customer needs to know A.B for features, A.B.C for fixes to features, and we use D internally for testing/debugging and emergency fixes for when taxes don't add up.
Success to everyone to streamline the versioning of your releases.
Emin
I agree there is IMHO no sense in versioning 1.02
This is for me v1.0.2.x
Versioning scheme as I see it...
A.B.C.D
A = Product Major Version
B = Product Feature Release
C = Product Release incrementeal ID
D = Fix/Test/Debug/ for short the Build number
Example for a e.g. wordprocessor:
0.x = Initial development
1.0.0.0 = Initial Debug Release
1.0.0.57 = 57th testing build
1.0.1.1 = Initial "official" build
1.0.1.33 = 33rd fix for the official build
1.0.2.1 = Second "official" build including all bug fixes
1.1.1.278 = Now we have a spell checker
1.2.1.45 = And a thesaurus.
2.0.1.352 = And we introduced Linux compatibility because we built it with Kylix 🙂
Use this structure internally, it works very well. A customer needs to know A.B for features, A.B.C for fixes to features, and we use D internally for testing/debugging and emergency fixes for when taxes don't add up.
Success to everyone to streamline the versioning of your releases.
Emin
normally its used this way:
major.minor.release.build
for most open source projects:
1.0.0.xxx - first public release
1.1.0.1 - first beta for 1.2 release
1.2.0.xxx - second public release
1.9.xx.xxx - beta releases for 2.0 RC
2.0.0.xxx - second major version, means bigger changes.
and so on ...
the last number ("build") is increased everytime a new beta/release is build and reset everytime the releasenumber changes.
major.minor.release.build
for most open source projects:
1.0.0.xxx - first public release
1.1.0.1 - first beta for 1.2 release
1.2.0.xxx - second public release
1.9.xx.xxx - beta releases for 2.0 RC
2.0.0.xxx - second major version, means bigger changes.
and so on ...
the last number ("build") is increased everytime a new beta/release is build and reset everytime the releasenumber changes.
you try this ... i didn't find any problem
!insertmacro STRFUNC_DEFFUNC VersionCheck
!define VersionCheck_List `ResultVar|CurVersion|CmpVersion`
!define VersionCheck_TypeList `Output 0 1 2|Text|Text`
!macro `FUNCTION_STRING_UnVersionCheck`
!undef UnVersionCheck
!insertmacro FUNCTION_STRING_VersionCheck
!macroend
!macro FUNCTION_STRING_VersionCheck
!insertmacro STRFUNC_FUNC `VersionCheck` `2004 - 2005 Tu Tong - Based on functions by Tu Tong`
Exch $R0
Exch
Exch $R1
Exch
Push $R2
Push $R3
Push $R4
Push $R5
Push $R6
Push $R7
StrCmp $R0 "" error 0
StrCmp $R1 "" error 0
StrCmp $R0 $R1 sameversion 0
ClearErrors
loop:
IfErrors sameversion
StrCmp $R0 "" sameversion
StrCmp $R1 "" sameversion
StrCpy $R4 $R0
GetLabelAddress $R7 return
Goto parse
return:
StrCpy $R6 $R3
StrCpy $R0 $R4
StrCpy $R4 $R1
GetLabelAddress $R7 return1
Goto parse
return1:
StrCpy $R5 $R3
StrCpy $R1 $R4
IntCmp $R6 $R5 0 olderversion newerversion
Goto loop
parse:
StrCpy $R2 0
StrLen $R5 $R4
parseloop:
StrCpy $R3 $R4 1 $R2
StrCmp $R3 "." parsecpy 0
IntCmp $R5 $R2 parsecpy parsecpy 0
IntOp $R2 $R2 + 1
Goto parseloop
parsecpy:
StrCpy $R3 $R4 $R2
IntOp $R5 $R5 - $R2
IntOp $R2 $R2 + 1
StrCpy $R4 $R4 $R5 $R2
Goto $R7
newerversion:
StrCpy $R0 "2"
Goto checkdone
sameversion:
StrCpy $R0 "0"
Goto checkdone
olderversion:
StrCpy $R0 "1"
Goto checkdone
error:
StrCpy $R0 ""
checkdone:
ClearErrors
Pop $R7
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
;------------------------
;End
FunctionEnd
!macro FUNCTION_STRING_VersionCheck_Call ResultVar CurVersion CmpVersion
!verbose push
!verbose 4
!echo `$ {VersionCheck} "${ResultVar}" "${CurVersion}" "${CmpVersion}"`
!verbose pop
Push `${CurVersion}`
Push `${CmpVersion}`
Call VersionCheck
Pop `${ResultVar}`
!macroend
!macro FUNCTION_STRING_UnVersionCheck_Call ResultVar CurVersion CmpVersion
!verbose push
!verbose 4
!echo `$ {UnVersionCheck} "${ResultVar}" "${CurVersion}" "${CmpVersion}"`
!verbose pop
Push `${CurVersion}`
Push `${CmpVersion}`
Call un.VersionCheck
Pop `${ResultVar}`
!macroend
!macroend
!insertmacro STRFUNC_DEFFUNC VersionCheck
!define VersionCheck_List `ResultVar|CurVersion|CmpVersion`
!define VersionCheck_TypeList `Output 0 1 2|Text|Text`
!macro `FUNCTION_STRING_UnVersionCheck`
!undef UnVersionCheck
!insertmacro FUNCTION_STRING_VersionCheck
!macroend
!macro FUNCTION_STRING_VersionCheck
!insertmacro STRFUNC_FUNC `VersionCheck` `2004 - 2005 Tu Tong - Based on functions by Tu Tong`
Exch $R0
Exch
Exch $R1
Exch
Push $R2
Push $R3
Push $R4
Push $R5
Push $R6
Push $R7
StrCmp $R0 "" error 0
StrCmp $R1 "" error 0
StrCmp $R0 $R1 sameversion 0
ClearErrors
loop:
IfErrors sameversion
StrCmp $R0 "" sameversion
StrCmp $R1 "" sameversion
StrCpy $R4 $R0
GetLabelAddress $R7 return
Goto parse
return:
StrCpy $R6 $R3
StrCpy $R0 $R4
StrCpy $R4 $R1
GetLabelAddress $R7 return1
Goto parse
return1:
StrCpy $R5 $R3
StrCpy $R1 $R4
IntCmp $R6 $R5 0 olderversion newerversion
Goto loop
parse:
StrCpy $R2 0
StrLen $R5 $R4
parseloop:
StrCpy $R3 $R4 1 $R2
StrCmp $R3 "." parsecpy 0
IntCmp $R5 $R2 parsecpy parsecpy 0
IntOp $R2 $R2 + 1
Goto parseloop
parsecpy:
StrCpy $R3 $R4 $R2
IntOp $R5 $R5 - $R2
IntOp $R2 $R2 + 1
StrCpy $R4 $R4 $R5 $R2
Goto $R7
newerversion:
StrCpy $R0 "2"
Goto checkdone
sameversion:
StrCpy $R0 "0"
Goto checkdone
olderversion:
StrCpy $R0 "1"
Goto checkdone
error:
StrCpy $R0 ""
checkdone:
ClearErrors
Pop $R7
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
;------------------------
;End
FunctionEnd
!macro FUNCTION_STRING_VersionCheck_Call ResultVar CurVersion CmpVersion
!verbose push
!verbose 4
!echo `$ {VersionCheck} "${ResultVar}" "${CurVersion}" "${CmpVersion}"`
!verbose pop
Push `${CurVersion}`
Push `${CmpVersion}`
Call VersionCheck
Pop `${ResultVar}`
!macroend
!macro FUNCTION_STRING_UnVersionCheck_Call ResultVar CurVersion CmpVersion
!verbose push
!verbose 4
!echo `$ {UnVersionCheck} "${ResultVar}" "${CurVersion}" "${CmpVersion}"`
!verbose pop
Push `${CurVersion}`
Push `${CmpVersion}`
Call un.VersionCheck
Pop `${ResultVar}`
!macroend
!macroend
It's better for you to post a normal function, because UseFunc (old StrFunc) is being developed, so this function would need to be changed to adapt to future newer versions.
okay deguix i'll post normal function
here my update
Function VersionCheck
Exch $R1
Exch
Exch $R0
Exch
Push $R2
Push $R3
Push $R4
Push $R5
Push $R6
${If} $R0 == ""
${OrIf} $R1 == ""
Goto Error
${EndIf}
StrCmp $R0 $R1 sameversion
StrCpy $R4 $R0
Call :complete
StrCpy $R0 $R4
StrCpy $R4 $R1
Call :complete
StrCpy $R1 $R4
Goto compare
complete:
StrCpy $R6 0
StrCpy $R2 0
StrLen $R5 $R4
${Do}
StrCpy $R3 $R4 1 $R2
${If} $R3 == "."
IntOp $R6 $R6 + 1
${EndIf}
${IfThen} $R2 >= $R5 ${|} ${ExitDo} ${|}
IntOp $R2 $R2 + 1
${Loop}
${Select} $R6
${Case} 0
StrCpy $R4 "$R4.0.0.0"
${Case} 1
StrCpy $R4 "$R4.0.0"
${Case} 2
StrCpy $R4 "$R4.0"
${CaseElse}
StrCpy $R4 "$R4"
${EndSelect}
Return
compare:
ClearErrors
Loop:
IfErrors sameversion
StrCmp $R0 "" sameversion
StrCmp $R1 "" sameversion
StrCpy $R4 $R0
Call 😛arse
StrCpy $R6 $R3
StrCpy $R0 $R4
StrCpy $R4 $R1
Call 😛arse
StrCpy $R5 $R3
StrCpy $R1 $R4
IntCmp $R6 $R5 0 olderversion newerversion
Goto Loop
parse:
StrCpy $R2 0
StrLen $R5 $R4
${Do}
StrCpy $R3 $R4 1 $R2
${IfThen} $R3 == "." ${|} ${ExitDo} ${|}
${IfThen} $R2 >= $R5 ${|} ${ExitDo} ${|}
IntOp $R2 $R2 + 1
${Loop}
StrCpy $R3 $R4 $R2
IntOp $R5 $R5 - $R2
IntOp $R2 $R2 + 1
StrCpy $R4 $R4 $R5 $R2
Return
olderversion:
StrCpy $R0 "2"
Goto checkdone
newerversion:
StrCpy $R0 "1"
Goto checkdone
sameversion:
StrCpy $R0 "0"
Goto checkdone
error:
StrCpy $R0 ""
checkdone:
ClearErrors
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
here my update
Function VersionCheck
Exch $R1
Exch
Exch $R0
Exch
Push $R2
Push $R3
Push $R4
Push $R5
Push $R6
${If} $R0 == ""
${OrIf} $R1 == ""
Goto Error
${EndIf}
StrCmp $R0 $R1 sameversion
StrCpy $R4 $R0
Call :complete
StrCpy $R0 $R4
StrCpy $R4 $R1
Call :complete
StrCpy $R1 $R4
Goto compare
complete:
StrCpy $R6 0
StrCpy $R2 0
StrLen $R5 $R4
${Do}
StrCpy $R3 $R4 1 $R2
${If} $R3 == "."
IntOp $R6 $R6 + 1
${EndIf}
${IfThen} $R2 >= $R5 ${|} ${ExitDo} ${|}
IntOp $R2 $R2 + 1
${Loop}
${Select} $R6
${Case} 0
StrCpy $R4 "$R4.0.0.0"
${Case} 1
StrCpy $R4 "$R4.0.0"
${Case} 2
StrCpy $R4 "$R4.0"
${CaseElse}
StrCpy $R4 "$R4"
${EndSelect}
Return
compare:
ClearErrors
Loop:
IfErrors sameversion
StrCmp $R0 "" sameversion
StrCmp $R1 "" sameversion
StrCpy $R4 $R0
Call 😛arse
StrCpy $R6 $R3
StrCpy $R0 $R4
StrCpy $R4 $R1
Call 😛arse
StrCpy $R5 $R3
StrCpy $R1 $R4
IntCmp $R6 $R5 0 olderversion newerversion
Goto Loop
parse:
StrCpy $R2 0
StrLen $R5 $R4
${Do}
StrCpy $R3 $R4 1 $R2
${IfThen} $R3 == "." ${|} ${ExitDo} ${|}
${IfThen} $R2 >= $R5 ${|} ${ExitDo} ${|}
IntOp $R2 $R2 + 1
${Loop}
StrCpy $R3 $R4 $R2
IntOp $R5 $R5 - $R2
IntOp $R2 $R2 + 1
StrCpy $R4 $R4 $R5 $R2
Return
olderversion:
StrCpy $R0 "2"
Goto checkdone
newerversion:
StrCpy $R0 "1"
Goto checkdone
sameversion:
StrCpy $R0 "0"
Goto checkdone
error:
StrCpy $R0 ""
checkdone:
ClearErrors
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd