The following commit has been merged in the master branch:
commit 60c89bac73d5a9aea0da4c38cc5e963b0d760000
Author: Guillem Jover <[email protected]>
Date:   Tue Nov 2 08:02:05 2010 +0100

    libdpkg: Switch order macro into a function

diff --git a/lib/dpkg/vercmp.c b/lib/dpkg/vercmp.c
index a52607b..e111e11 100644
--- a/lib/dpkg/vercmp.c
+++ b/lib/dpkg/vercmp.c
@@ -35,14 +35,25 @@ epochsdiffer(const struct versionrevision *a,
   return a->epoch != b->epoch;
 }
 
-/*
- * Assume ASCII; Warning: evaluates x multiple times!
+/**
+ * Give a weight to the character to order in the version comparison.
+ *
+ * @param c An ASCII character.
  */
-#define order(x) ((x) == '~' ? -1 \
-               : cisdigit((x)) ? 0 \
-               : !(x) ? 0 \
-               : cisalpha((x)) ? (x) \
-               : (x) + 256)
+static int
+order(int c)
+{
+  if (c == '~')
+    return -1;
+  else if (cisdigit(c))
+    return 0;
+  else if (!c)
+    return 0;
+  else if (cisalpha(c))
+    return c;
+  else
+    return c + 256;
+}
 
 static int verrevcmp(const char *val, const char *ref) {
   if (!val) val= "";

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to