[fpc-pascal] Comparing version numbers
Marco van de Voort
marcov at stack.nl
Fri Jun 2 23:09:59 CEST 2006
> I have tried about a dozen different algorithms now, and I admit to being
> stumped because everyone I've tried fails SOMEWHERE.
> The task before me is to compare version numbers of software packages and
> determine which is higher.
> First try was to simply do a string comparison.
> This almost worked, except that
> Is asciibeticallly smaller than
String based: rework till you have a fixed pattern like 0004.0000.0012
Problem: the first 5 digit version nr (e.g. perl minor) breaks. If you take
5 digits, the first 6 digit will fail etc.
number based: a version is a (small) array of integers. Better than string,
but a string is variable length allowing in theory infinite subversions. So
make it a dyn array to achieve the same.
More information about the fpc-pascal