]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* libm4.m4 (m4_sign, m4_cmp, m4_list_cmp): New macros.
authorAkim Demaille <akim@epita.fr>
Wed, 9 Feb 2000 11:59:24 +0000 (11:59 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 9 Feb 2000 11:59:24 +0000 (11:59 +0000)
* acgeneral.m4 (AC_UNGNITS): Renamed as...
(_AC_VERSION_UNLETTER): this.  All callers changed.
Implement the scheme proposed by Alexandre Oliva:
Nl -> (N+1).-1.(l#)
(_AC_VERSION_COMPARE): New macro.
(AC_PREREQ): Use it.

ChangeLog
acgeneral.m4
lib/autoconf/general.m4
libm4.m4

index d32a9313ed3f0dafdd674eb08fc7d212d651b3b5..e76548d25b939a90efab61f7f567c416caa0a468 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-02-09  Akim Demaille  <akim@epita.fr>
+
+       * libm4.m4 (m4_sign, m4_cmp, m4_list_cmp): New macros.
+       * acgeneral.m4 (AC_UNGNITS): Renamed as...
+       (_AC_VERSION_UNLETTER): this.  All callers changed.
+       Implement the scheme proposed by Alexandre Oliva:
+               Nl -> (N+1).-1.(l#)
+       (_AC_VERSION_COMPARE): New macro.
+       (AC_PREREQ): Use it.
+
 2000-02-09  Akim Demaille  <akim@epita.fr>
 
        * tests/base.m4: Really added to the CVS repository.
index e75b3b2b1e9dd16e17ce353c6981032efd5c7c8d..6524ec86c3bb10ecdd5975e66d83339fbe619463 100644 (file)
@@ -1303,51 +1303,41 @@ AC_DIVERT_POP()dnl to KILL
 
 # Subroutines of AC_PREREQ.
 
-# m4_compare(VERSION-1, VERSION-2)
-# --------------------------------
-# Compare the two version numbers and expand into
-#  -1 if VERSION-1 < VERSION-2
-#   0 if           =
-#   1 if           >
-# The handling of the special values [[]] is a pain, but seems necessary.
-# This macro is a excellent tutorial on the order of evaluation of ifelse.
-define(m4_compare,
-[ifelse([$1],,      [ifelse([$2],,      0,
-                            [$2], [[]], 0,
-                            1)],
-        [$1], [[]], [ifelse([$2],, 0,
-                            [$2], [[]], 0,
-                            1)],
-        [$2],,      -1,
-        [$2], [[]], -1,
-        [ifelse(m4_eval(m4_car($1) < m4_car($2)), 1, 1,
-                [ifelse(m4_eval(m4_car($1) > m4_car($2)), 1, -1,
-                        [m4_compare(m4_quote(m4_shift($1)),
-                                    m4_quote(m4_shift($2)))])])])])
-
-
-# AC_UNGNITS(VERSION)
-# -------------------
-# Replace .a, .b etc. by .0.1, .0.2 in VERSION.  For instance, version
-# 2.14a is understood as 2.14.0.1 for version comparison.
+# _AC_VERSION_UNLETTER(VERSION)
+# -----------------------------
+# Normalize beta version numbers with letters to numbers only for comparison.
+#
+#   Nl -> (N+1).-1.(l#)
+#
+#i.e., 2.14a -> 2.15.-1.1, 2.14b -> 2.15.-1.2, etc.
 # This macro is absolutely not robust to active macro, it expects
-# reasonable version numbers.
-# Warning: Valid up to `z', no double letters.
-define(AC_UNGNITS,
+# reasonable version numbers and is valid up to `z', no double letters.
+define(_AC_VERSION_UNLETTER,
 [translit(patsubst(patsubst(patsubst([$1],
-                                     [\([abcdefghi]\)], [.0.\1]),
-                            [\([jklmnopqrs]\)], [.0.1\1]),
-          [\([tuvwxyz]\)], [.0.2\1]),
+                                     [\([0-9]+\)\([abcdefghi]\)],
+                                     [m4_eval(\1 + 1).-1.\2]),
+                            [\([0-9]+\)\([jklmnopqrs]\)],
+                            [m4_eval(\1 + 1).-1.1\2]),
+          [\([0-9]+\)\([tuvwxyz]\)],
+          [m4_eval(\1 + 1).-1.2\2]),
           abcdefghijklmnopqrstuvwxyz,
           12345678901234567890123456)])
 
+# _AC_VERSION_COMPARE(VERSION-1, VERSION-2)
+# -----------------------------------------
+# Compare the two version numbers and expand into
+#  -1 if VERSION-1 < VERSION-2
+#   0 if           =
+#   1 if           >
+define(_AC_VERSION_COMPARE,
+[m4_list_cmp((m4_split(_AC_VERSION_UNLETTER([$1]), [\.])),
+             (m4_split(_AC_VERSION_UNLETTER([$2]), [\.])))])
 
 # AC_PREREQ(VERSION)
 # ------------------
 # Complain and exit if the Autoconf version is less than VERSION.
 define(AC_PREREQ,
-[ifelse(m4_compare(m4_split(AC_UNGNITS([$1]),         [\.]),
-                   m4_split(AC_UNGNITS(AC_ACVERSION), [\.])), -1,
+[ifelse(_AC_VERSION_COMPARE([AC_ACVERSION], [$1]), -1,
        [AC_FATAL(Autoconf version $1 or higher is required for this script)])])
 
 
index e75b3b2b1e9dd16e17ce353c6981032efd5c7c8d..6524ec86c3bb10ecdd5975e66d83339fbe619463 100644 (file)
@@ -1303,51 +1303,41 @@ AC_DIVERT_POP()dnl to KILL
 
 # Subroutines of AC_PREREQ.
 
-# m4_compare(VERSION-1, VERSION-2)
-# --------------------------------
-# Compare the two version numbers and expand into
-#  -1 if VERSION-1 < VERSION-2
-#   0 if           =
-#   1 if           >
-# The handling of the special values [[]] is a pain, but seems necessary.
-# This macro is a excellent tutorial on the order of evaluation of ifelse.
-define(m4_compare,
-[ifelse([$1],,      [ifelse([$2],,      0,
-                            [$2], [[]], 0,
-                            1)],
-        [$1], [[]], [ifelse([$2],, 0,
-                            [$2], [[]], 0,
-                            1)],
-        [$2],,      -1,
-        [$2], [[]], -1,
-        [ifelse(m4_eval(m4_car($1) < m4_car($2)), 1, 1,
-                [ifelse(m4_eval(m4_car($1) > m4_car($2)), 1, -1,
-                        [m4_compare(m4_quote(m4_shift($1)),
-                                    m4_quote(m4_shift($2)))])])])])
-
-
-# AC_UNGNITS(VERSION)
-# -------------------
-# Replace .a, .b etc. by .0.1, .0.2 in VERSION.  For instance, version
-# 2.14a is understood as 2.14.0.1 for version comparison.
+# _AC_VERSION_UNLETTER(VERSION)
+# -----------------------------
+# Normalize beta version numbers with letters to numbers only for comparison.
+#
+#   Nl -> (N+1).-1.(l#)
+#
+#i.e., 2.14a -> 2.15.-1.1, 2.14b -> 2.15.-1.2, etc.
 # This macro is absolutely not robust to active macro, it expects
-# reasonable version numbers.
-# Warning: Valid up to `z', no double letters.
-define(AC_UNGNITS,
+# reasonable version numbers and is valid up to `z', no double letters.
+define(_AC_VERSION_UNLETTER,
 [translit(patsubst(patsubst(patsubst([$1],
-                                     [\([abcdefghi]\)], [.0.\1]),
-                            [\([jklmnopqrs]\)], [.0.1\1]),
-          [\([tuvwxyz]\)], [.0.2\1]),
+                                     [\([0-9]+\)\([abcdefghi]\)],
+                                     [m4_eval(\1 + 1).-1.\2]),
+                            [\([0-9]+\)\([jklmnopqrs]\)],
+                            [m4_eval(\1 + 1).-1.1\2]),
+          [\([0-9]+\)\([tuvwxyz]\)],
+          [m4_eval(\1 + 1).-1.2\2]),
           abcdefghijklmnopqrstuvwxyz,
           12345678901234567890123456)])
 
+# _AC_VERSION_COMPARE(VERSION-1, VERSION-2)
+# -----------------------------------------
+# Compare the two version numbers and expand into
+#  -1 if VERSION-1 < VERSION-2
+#   0 if           =
+#   1 if           >
+define(_AC_VERSION_COMPARE,
+[m4_list_cmp((m4_split(_AC_VERSION_UNLETTER([$1]), [\.])),
+             (m4_split(_AC_VERSION_UNLETTER([$2]), [\.])))])
 
 # AC_PREREQ(VERSION)
 # ------------------
 # Complain and exit if the Autoconf version is less than VERSION.
 define(AC_PREREQ,
-[ifelse(m4_compare(m4_split(AC_UNGNITS([$1]),         [\.]),
-                   m4_split(AC_UNGNITS(AC_ACVERSION), [\.])), -1,
+[ifelse(_AC_VERSION_COMPARE([AC_ACVERSION], [$1]), -1,
        [AC_FATAL(Autoconf version $1 or higher is required for this script)])])
 
 
index db15d7b28834c8ffd08f5581386142910ba7a32f..df84ed36761742e9a8f3195d10055e374b1dadca 100644 (file)
--- a/libm4.m4
+++ b/libm4.m4
@@ -458,9 +458,9 @@ define(_m4_foreach,
                                                     [$3])])])
 
 
-## ----------------------- ##
-## Text processing in m4.  ##
-## ----------------------- ##
+## ----------------- ##
+## Text processing.  ##
+## ----------------- ##
 
 # m4_quote(STRING)
 # ----------------
@@ -676,3 +676,50 @@ popdef([m4_Width])dnl
 popdef([m4_Prefix1])dnl
 popdef([m4_Prefix])dnl
 ])
+
+
+
+## ------------------- ##
+## Number processing.  ##
+## ------------------- ##
+
+# m4_sign(A)
+# ----------
+#
+# The sign of the integer A.
+define(m4_sign,
+[m4_match([$1],
+          [^-], -1,
+          [^0+], 0,
+                 1)])
+
+# m4_cmp(A, B)
+# ------------
+#
+# Compare two integers.
+# A < B -> -1
+# A = B ->  0
+# A > B ->  1
+define(m4_cmp,
+[m4_sign(m4_eval([$1 - $2]))])
+
+
+# m4_list_cmp(A, B)
+# -----------------
+#
+# Compare the two lists of integers A and B.  For instance:
+#   m4_list_cmp((1, 0),     (1))    ->  0
+#   m4_list_cmp((1, 0),     (1, 0)) ->  0
+#   m4_list_cmp((1, 2),     (1, 0)) ->  1
+#   m4_list_cmp((1, 2, 3),  (1, 2)) ->  1
+#   m4_list_cmp((1, 2, -3), (1, 2)) -> -1
+#   m4_list_cmp((1, 0),     (1, 2)) -> -1
+#   m4_list_cmp((1),        (1, 2)) -> -1
+define(m4_list_cmp,
+[ifelse([$1$2], [()()], 0,
+        [$1], [()], [m4_list_cmp((0), [$2])],
+        [$2], [()], [m4_list_cmp([$1], (0))],
+        [m4_case(m4_cmp(m4_car$1, m4_car$2),
+                 -1, -1,
+                  1, 1,
+                  0, [m4_list_cmp((m4_shift$1), (m4_shift$2))])])])