]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/version.cc
Fixed ordering error for unpacked things
[apt.git] / apt-pkg / version.cc
index cdfad3fd75d206516d38c2d92d2f00d1e7f722e4..4aad581f8e597c495dfabaa4041eaa5972664581 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: version.cc,v 1.6 1998/11/26 23:29:42 jgg Exp $
+// $Id: version.cc,v 1.9 1999/04/19 06:03:09 jgg Exp $
 /* ######################################################################
 
    Version - Version string 
@@ -180,6 +180,11 @@ int pkgVersionCompare(const char *A, const char *AEnd, const char *B,
    const char *drhs = BEnd-1;
    for (;dlhs > lhs && *dlhs != '-'; dlhs--);
    for (;drhs > rhs && *drhs != '-'; drhs--);
+
+   if (dlhs == lhs)
+      dlhs = AEnd;
+   if (drhs == rhs)
+      drhs = BEnd;
    
    // Compare the main version
    Res = iVersionCompare(lhs,dlhs,rhs,drhs);
@@ -243,4 +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);
+}
+                                                                       /*}}}*/