Move rpmVersionCompare() into a more logical place
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 9 Feb 2010 09:35:47 +0000 (11:35 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 9 Feb 2010 09:35:47 +0000 (11:35 +0200)
- it has nothing to do with psm so no point having it there

lib/psm.c
lib/rpmvercmp.c

index e56b1e6..fbfb4af 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -60,27 +60,6 @@ struct rpmpsm_s {
     int nrefs;                 /*!< Reference count. */
 };
 
-int rpmVersionCompare(Header first, Header second)
-{
-    /* Missing epoch becomes zero here, which is what we want */
-    uint32_t epochOne = headerGetNumber(first, RPMTAG_EPOCH);
-    uint32_t epochTwo = headerGetNumber(second, RPMTAG_EPOCH);
-    int rc;
-
-    if (epochOne < epochTwo)
-       return -1;
-    else if (epochOne > epochTwo)
-       return 1;
-
-    rc = rpmvercmp(headerGetString(first, RPMTAG_VERSION),
-                  headerGetString(second, RPMTAG_VERSION));
-    if (rc)
-       return rc;
-
-    return rpmvercmp(headerGetString(first, RPMTAG_RELEASE),
-                    headerGetString(second, RPMTAG_RELEASE));
-}
-
 /**
  * Macros to be defined from per-header tag values.
  * @todo Should other macros be added from header when installing a package?
index 65dafee..f5ae092 100644 (file)
@@ -108,3 +108,24 @@ int rpmvercmp(const char * a, const char * b)
     /* whichever version still has characters left over wins */
     if (!*one) return -1; else return 1;
 }
+
+int rpmVersionCompare(Header first, Header second)
+{
+    /* Missing epoch becomes zero here, which is what we want */
+    uint32_t epochOne = headerGetNumber(first, RPMTAG_EPOCH);
+    uint32_t epochTwo = headerGetNumber(second, RPMTAG_EPOCH);
+    int rc;
+
+    if (epochOne < epochTwo)
+       return -1;
+    else if (epochOne > epochTwo)
+       return 1;
+
+    rc = rpmvercmp(headerGetString(first, RPMTAG_VERSION),
+                  headerGetString(second, RPMTAG_VERSION));
+    if (rc)
+       return rc;
+
+    return rpmvercmp(headerGetString(first, RPMTAG_RELEASE),
+                    headerGetString(second, RPMTAG_RELEASE));
+}