severity 387220 serious
thanks

This bugs makes quinn-diff unusable. I'll NMU this in three days with
the attached patch.

Bastian

-- 
Women professionals do tend to over-compensate.
                -- Dr. Elizabeth Dehaver, "Where No Man Has Gone Before",
                   stardate 1312.9.
diff -urN quinn-diff-0.65/debian/changelog quinn-diff-0.65.1/debian/changelog
--- quinn-diff-0.65/debian/changelog    2003-06-08 15:40:43.000000000 +0200
+++ quinn-diff-0.65.1/debian/changelog  2006-10-09 12:12:49.000000000 +0200
@@ -1,3 +1,10 @@
+quinn-diff (0.65.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Update version compare code from dpkg. (closes: #387220)
+
+ -- Bastian Blank <[EMAIL PROTECTED]>  Mon,  9 Oct 2006 12:08:04 +0200
+
 quinn-diff (0.65) unstable; urgency=low
 
   * src/init.c (usage): don't use multi-line string literals as they're
diff -urN quinn-diff-0.65/src/vercmp.c quinn-diff-0.65.1/src/vercmp.c
--- quinn-diff-0.65/src/vercmp.c        2003-01-30 18:59:50.000000000 +0100
+++ quinn-diff-0.65.1/src/vercmp.c      2006-10-09 12:15:00.000000000 +0200
@@ -44,34 +44,45 @@
 
 const char *parseversion(struct versionrevision *rversion, const char *string);
 
-static int verrevcmp(const char *val, const char *ref)
-{
-  int vc, rc;
-  long vl, rl;
-  const char *vp, *rp;
+/* assume ascii; warning: evaluates x multiple times! */
+#define order(x) ((x) == '~' ? -1 \
+               : cisdigit((x)) ? 0 \
+               : !(x) ? 0 \
+               : cisalpha((x)) ? (x) \
+               : (x) + 256)
+
+int cisdigit(int c) {
+       return (c>='0') && (c<='9');
+}
+
+int cisalpha(int c) {
+       return ((c>='a') && (c<='z')) || ((c>='A') && (c<='Z'));
+}
 
+static int verrevcmp(const char *val, const char *ref) {
   if (!val) val= "";
   if (!ref) ref= "";
-  for (;;) {
-    vp= val;  while (*vp && !isdigit(*vp)) vp++;
-    rp= ref;  while (*rp && !isdigit(*rp)) rp++;
-    for (;;) {
-      vc= val == vp ? 0 : *val++;
-      rc= ref == rp ? 0 : *ref++;
-      if (!rc && !vc) break;
-      if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
-      if (rc && !isalpha(rc)) rc += 256;
+
+  while (*val || *ref) {
+    int first_diff= 0;
+
+    while ( (*val && !cisdigit(*val)) || (*ref && !cisdigit(*ref)) ) {
+      int vc= order(*val), rc= order(*ref);
       if (vc != rc) return vc - rc;
+      val++; ref++;
     }
-    val= vp;
-    ref= rp;
-    vl=0;  if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
-    rl=0;  if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
-    if (vl != rl) return vl - rl;
-    if (!*val && !*ref) return 0;
-    if (!*val) return -1;
-    if (!*ref) return +1;
+
+    while ( *val == '0' ) val++;
+    while ( *ref == '0' ) ref++;
+    while (cisdigit(*val) && cisdigit(*ref)) {
+      if (!first_diff) first_diff= *val - *ref;
+      val++; ref++;
+    }
+    if (cisdigit(*val)) return 1;
+    if (cisdigit(*ref)) return -1;
+    if (first_diff) return first_diff;
   }
+  return 0;
 }
 
 int versioncompare(const struct versionrevision *version,

Reply via email to