On Thu, Nov 25, 2010 at 12:55:17PM +0200, Panu Matilainen wrote: > On Thu, 25 Nov 2010, Michael Schroeder wrote: > > > On Thu, Nov 25, 2010 at 10:48:08AM +0200, Panu Matilainen wrote: > > > If you have time to look at the more than one tilde-case, then please do. > > > > Okey, I'll send a patch later this day. > > Cool.
Patch attached. Seems to work well, but a couple of testcases in rpmvercmp.at would be nice. Oh, I just noticed that it changes the semantics a bit: old: rpm.vercmp("1.", "1") -> 1 rpm.vercmp("1..", "1.") -> 0 new: rpm.vercmp("1.", "1") -> 0 rpm.vercmp("1..", "1.") -> 0 That's because I changed the loop from "while (*one && *two)" to "while (*one || *two)". The results are much saner with the change, but we probably need to stay bug compatible. What do you think? Cheers, Michael. -- Michael Schroeder m...@suse.de SUSE LINUX Products GmbH, GF Markus Rex, HRB 16746 AG Nuernberg main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
--- lib/rpmvercmp.c.orig 2010-11-25 10:53:01.000000000 +0000 +++ lib/rpmvercmp.c 2010-11-25 11:45:02.000000000 +0000 @@ -32,9 +32,18 @@ int rpmvercmp(const char * a, const char two = str2; /* loop through each version segment of str1 and str2 and compare them */ - while (*one && *two) { - while (*one && !risalnum(*one)) one++; - while (*two && !risalnum(*two)) two++; + while (*one || *two) { + while (*one && !risalnum(*one) && *one != '~') one++; + while (*two && !risalnum(*two) && *two != '~') two++; + + /* handle the tilde separator, it sorts before everthing else */ + if (*one == '~' || *two == '~') { + if (*one != '~') return 1; + if (*two != '~') return -1; + one++; + two++; + continue; + } /* If we ran to the end of either, we are finished with the loop */ if (!(*one && *two)) break;
_______________________________________________ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint