소스 검색

New verrevcmp() from Anthony Towns

Wichert Akkerman 25 년 전
부모
커밋
dba844bd36
4개의 변경된 파일52개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 36 0
      lib/vercmp.c
  4. 10 0
      main/dpkg.8

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Mon Jul 16 14:10:18 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
+
+  * lib/vercmp.c: New verrevcmp() from Anthony Towns
+
 Mon Jul 16 13:27:44 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
 Mon Jul 16 13:27:44 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
 
 
   * Merge a modified patch from Josip Rodin:
   * Merge a modified patch from Josip Rodin:

+ 2 - 0
debian/changelog

@@ -24,6 +24,8 @@ dpkg (1.10) unstable; urgency=low
     consistent with the package list
     consistent with the package list
   * Fix test for nice(2) failure in start-stop-daemon. Closes: Bug#104561
   * Fix test for nice(2) failure in start-stop-daemon. Closes: Bug#104561
   * Improve the dselect helpscreen a bit. Closes: Bug#72634
   * Improve the dselect helpscreen a bit. Closes: Bug#72634
+  * New version comparison routine that can handle arbitrarily large numbers
+    and accepts `~' as a low-sorting character. Closes: Bug#93386
 
 
  -- Wichert Akkerman <wakkerma@debian.org>  UNRELEASED
  -- Wichert Akkerman <wakkerma@debian.org>  UNRELEASED
 
 

+ 36 - 0
lib/vercmp.c

@@ -32,6 +32,41 @@ int epochsdiffer(const struct versionrevision *a,
   return a->epoch != b->epoch;
   return a->epoch != b->epoch;
 }
 }
 
 
+/* assume ascii; warning: evaluates x multiple times! */
+#define order(x) ((x) == '~' ? -1 \
+		: isdigit((x)) ? 0 \
+		: !(x) ? 0 \
+		: isalpha((x)) ? (x) \
+		: (x) + 256)
+
+static int verrevcmp(const char *val, const char *ref) {
+  if (!val) val= "";
+  if (!ref) ref= "";
+
+  while (*val || *ref) {
+    int first_diff= 0;
+
+    while ( (*val && !isdigit(*val)) || (*ref && !isdigit(*ref)) ) {
+      int vc= order(*val), rc= order(*ref);
+      if (vc != rc) return vc - rc;
+      val++; ref++;
+    }
+
+    while ( *val == '0' ) val++;
+    while ( *ref == '0' ) ref++;
+    while (isdigit(*val) && isdigit(*ref)) {
+      if (!first_diff) first_diff= *val - *ref;
+      val++; ref++;
+    }
+    if (isdigit(*val)) return 1;
+    if (isdigit(*ref)) return -1;
+    if (first_diff) return first_diff;
+  }
+  return 0;
+}
+
+
+#if 0
 static int verrevcmp(const char *ival, const char *iref) {
 static int verrevcmp(const char *ival, const char *iref) {
   static char empty[] = "";
   static char empty[] = "";
   int vc, rc;
   int vc, rc;
@@ -64,6 +99,7 @@ static int verrevcmp(const char *ival, const char *iref) {
     if (!*ref) return +1;
     if (!*ref) return +1;
   }
   }
 }
 }
+#endif
 
 
 int versioncompare(const struct versionrevision *version,
 int versioncompare(const struct versionrevision *version,
                    const struct versionrevision *refversion) {
                    const struct versionrevision *refversion) {

+ 10 - 0
main/dpkg.8

@@ -507,6 +507,16 @@ The program \fBdpkg\fP will execute while starting a new shell.
 .B COLUMNS
 .B COLUMNS
 Sets the number of columns \fBdpkg\fP should use when displaying formatted
 Sets the number of columns \fBdpkg\fP should use when displaying formatted
 text.  Currently only used by -l.
 text.  Currently only used by -l.
+.TP
+.B DPKG_OLD_CONFFILE
+Set by \fBdpkg\fP to the filename of the old configuration file 
+when you start a shell to examine a changed configuration.
+file.
+.TP
+.B DPKG_NEW_CONFFILE
+Set by \fBdpkg\fP to the filename of the newversion of a configuration file
+when you start a shell to examine a changed configuration.
+file.
 
 
 .SH EXAMPLES
 .SH EXAMPLES
 To list packages related to the editor vi:
 To list packages related to the editor vi: