Old 22nd March 2005, 18:28   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
VersionCheckNew testing

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:
http://nsis.sourceforge.net/archive/...nstances=0,757

If you find one that fails, post it here so I can see it.

Cheers

-Stu
Afrow UK is offline   Reply With Quote
Old 23rd March 2005, 08:10   #2
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Probably Afrow UK mean:
http://nsis.sourceforge.net/archive/...s=0,11,122,754

Last edited by Instructor; 23rd March 2005 at 08:32.
Instructor is offline   Reply With Quote
Old 23rd March 2005, 08:58   #3
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Quote:
(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).
Instructor is offline   Reply With Quote
Old 23rd March 2005, 11:55   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Ah yeh, sorry I posted link to edit

-Stu
Afrow UK is offline   Reply With Quote
Old 28th March 2005, 10:10   #5
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
code:
${VersionCheckNew} "91.1.1.1" "101.1.1.1" $R0
$R0="1"
Instructor is offline   Reply With Quote
Old 28th March 2005, 20:02   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 29th March 2005, 09:22   #7
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Very bad that you don't trying to see what do others


P.S.
code:
${VersionCheckV5} "1.001" "1.0" $R0
$R0="2"
Instructor is offline   Reply With Quote
Old 29th March 2005, 11:15   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Thanks fixed.

-Stu
Afrow UK is offline   Reply With Quote
Old 7th June 2005, 12:08   #9
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Version "1.00" is newer than "1.0". Is it supposed to be?
glory_man is offline   Reply With Quote
Old 7th June 2005, 12:11   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I'd just use Instructors VersionCompare

-Stu
Afrow UK is offline   Reply With Quote
Old 7th June 2005, 12:33   #11
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Another question (general).
Why "1.1.1.1" not equal to "1.1.1.01"?
glory_man is offline   Reply With Quote
Old 7th June 2005, 12:57   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Because 01 is older than 1, as we go up in 01, 02, 03, to 1. 1 would be counted as "10".

-Stu
Afrow UK is offline   Reply With Quote
Old 7th June 2005, 13:12   #13
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Than, if I include in script
code:
VIProductVersion "1.1.0.001"
VIAddVersionKey "LegalCopyright" 'Ltd.'
VIAddVersionKey "FileDescription" "Test file"
VIAddVersionKey "FileVersion" "1.1.0.001"


And use GetDllVersion - version will be 1.1.0.1. Why?
glory_man is offline   Reply With Quote
Old 7th June 2005, 13:17   #14
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
NSIS treats 001 in a variable as 1 (when using IntOp)

-Stu
Afrow UK is offline   Reply With Quote
Old 7th June 2005, 19:15   #15
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
Quote:
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).

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 8th June 2005, 07:30   #16
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Quote:
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 )
Instructor is offline   Reply With Quote
Old 8th June 2005, 10:43   #17
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Quote:
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
Quote:
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 )
I don't agree. NSIS 2.01 has full version number 2.0.1, NSIS 2.1 wil be - 2.1.0.
In your words 1 kg 1000 times greater than 0001 kg.
glory_man is offline   Reply With Quote
Old 8th June 2005, 11:23   #18
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
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
Instructor is offline   Reply With Quote
Old 8th June 2005, 11:37   #19
onad
Senior Member
 
onad's Avatar
 
Join Date: Dec 2004
Location: Turkey
Posts: 447
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

"Just do it"
onad is offline   Reply With Quote
Old 10th June 2005, 15:06   #20
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
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.
Comm@nder21 is offline   Reply With Quote
Old 10th June 2005, 22:46   #21
NHOCSUNG
Guest
 
Posts: n/a
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
  Reply With Quote
Old 11th June 2005, 03:10   #22
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
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.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 24th August 2005, 20:50   #23
NHOCSUNG
Guest
 
Posts: n/a
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
  Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump