Jeff, I'm building a test suite to prove my algorithm. Can you give me some corner cases you expect would be commonly gotten wrong?
My code passes the in as e:v-R in as one string then splits them up on it's own afterwards. Examples I'm looking for that some algorithms might get wrong. 1.2:2.5.3-1a > 2:2.5.3-1a The test call would be something like this: my $truth = compare('1.2:2.5.3-1a', '>', '2:2.5.3-1a'); Todd On Mar 11, 2010, at 11:24 AM, Jeff Johnson wrote: > you will see lots of references to "rpmvercmp" around. > What is always missed is that rpmvercmp needs to be applied > _THREE_ times to each of Epoch/Version/Release, in that order, > not once to the concatenated E:V-R string. Epoch: is always > a digit string followed by ':', so rpmvercmp is overkill, but > will give the right answer when fed a digit string. > > 3) While the basic segmented string algorithm of > Compare digit strings with digit strings > Compare alpha strings with alpha strings > Ignore everything else > is easy to grasp, the "mixed-mode" comparisons are > not what one naively expects. What tends to be expoected > is that digits are compared to alphas using ASCII collating > order and that is _NOT_ what RPM does. What RPM actually > does is compare, say, a digit string with "", not with the > (say) alpha character in the original string. > > 4) One tends also to read > 1.23 > as a decimal number, where there are actually 3 components > 1 digit string > . punctuation is ignored > 23 digit string > that are compared serially by rpmvercmp. > > But rpmvercmp has been re-implemented zillions of times > in perl and almost every other language known. Search > a bit and find one that does the job correctly. > > hth