]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
(_AS_VERSION_COMPARE_PREPARE):
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 26 Aug 2005 18:49:23 +0000 (18:49 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 26 Aug 2005 18:49:23 +0000 (18:49 +0000)
The previous patch didn't work, so try a better one.

lib/m4sugar/m4sh.m4

index 7884303a8afcab3f562c5ec5c3821b4e3e54847b..ef5ccef1fed89e44b3e92ea09fd9d3e253424dc8 100644 (file)
@@ -1030,7 +1030,7 @@ m4_defun([_AS_VERSION_COMPARE_PREPARE],
   # Use only awk features that work with 7th edition Unix awk (1978).
   # My, what an old awk you have, Mr. Solaris!
   END {
-    while (length(v1) || length(v2)) {
+    while (length(v1) && length(v2)) {
       # Set d1 to be the next thing to compare from v1, and likewise for d2.
       # Normally this is a single character, but if v1 and v2 contain digits,
       # compare them as integers and fractions as strverscmp does.
@@ -1074,12 +1074,16 @@ m4_defun([_AS_VERSION_COMPARE_PREPARE],
        }
       } else {
        # The normal case, without worrying about digits.
-       if (length(v1)) { d1 = substr(v1, 1, 1); v1 = substr(v1,2) } else d1=v1
-       if (length(v2)) { d2 = substr(v2, 1, 1); v2 = substr(v2,2) } else d2=v2
+       d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
+       d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
       }
       if (d1 < d2) exit 1
       if (d1 > d2) exit 2
     }
+    # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
+    # which mishandles some comparisons of empty strings to integers.
+    if (length(v2)) exit 1
+    if (length(v1)) exit 2
   }
 ']])