[fpc-pascal] Comparing version numbers
aj at getopenlab.com
Sat Jun 3 00:02:35 CEST 2006
Actually I found my answer just now after asking a friend who is a debian
Turns out debian documents the pseudocode for their method in the manpages.
So I am just busy translating the pseudo to pascal now.
1. take any initial string of non-digits from each, remove, and compare
If there's a difference, terminate. If not:
2. Take any initial string of digits from each, remove, and compare
If there's a difference, terminate. If not, goto 1.
(Oh and I'm using while, not goto :p )
On Friday 02 June 2006 23:11, Vincent Snijders wrote:
> A.J. Venter wrote:
> > So the question is:
> > 1) does somebody HAVE an algorithm for this already ?
> > 2) If not, can somebody give me a hint about what approach to take ?
> Split the version string in several numbers:
> version := '4.0.12';
> major := 4
> minor := 0;
> patch := 12;
> versionnumber := major * 10000 + minor * 100 + patch
> then you can numerically compare version numbers.
> the 100 (a) and 10000 (b) can be adjusted for your needs.
> a must be bigger than the max number of patches
> b must be bigger that the max numer of patches times the max numer of
> minor versions.
> So this algorithm can not 4.194.299
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
"there's nothing as inspirational for a hacker as a cat obscuring a bug
by sitting in front of the monitor" - Boudewijn Rempt
Chief Software Architect
+27 82 726 5103
More information about the fpc-pascal