X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/6a19558e1ef1c3ac6aff4af435c9d13a3405ca08..fbdccabb17963090e21e3b02bc72dda68f34d524:/apt-pkg/version.cc diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc index 4e2e61312..4aad581f8 100644 --- a/apt-pkg/version.cc +++ b/apt-pkg/version.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: version.cc,v 1.7 1998/11/28 20:50:24 jgg Exp $ +// $Id: version.cc,v 1.9 1999/04/19 06:03:09 jgg Exp $ /* ###################################################################### Version - Version string @@ -59,7 +59,6 @@ int pkgVersionCompare(string A,string B) static int iVersionCompare(const char *A, const char *AEnd, const char *B, const char *BEnd) { - // cout << string(A,AEnd) << ',' << string(B,BEnd) << endl; if (A >= AEnd && B >= BEnd) return 0; if (A >= AEnd) @@ -182,9 +181,9 @@ int pkgVersionCompare(const char *A, const char *AEnd, const char *B, for (;dlhs > lhs && *dlhs != '-'; dlhs--); for (;drhs > rhs && *drhs != '-'; drhs--); - if (dlhs == A) + if (dlhs == lhs) dlhs = AEnd; - if (drhs == B) + if (drhs == rhs) drhs = BEnd; // Compare the main version @@ -249,3 +248,24 @@ bool pkgCheckDep(const char *DepVer,const char *PkgVer,int Op) return false; } /*}}}*/ +// BaseVersion - Return the upstream version string /*{{{*/ +// --------------------------------------------------------------------- +/* This strips all the debian specific information from the version number */ +string pkgBaseVersion(const char *Ver) +{ + // Strip off the bit before the first colon + const char *I = Ver; + for (; *I != 0 && *I != ':'; I++); + if (*I == ':') + Ver = I + 1; + + // Chop off the trailing - + I = Ver; + unsigned Last = strlen(Ver); + for (; *I != 0; I++) + if (*I == '-') + Last = I - Ver; + + return string(Ver,Last); +} + /*}}}*/