autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: m4_version_compare and new version numbering [was: distcheck fails w


From: Eric Blake
Subject: Re: m4_version_compare and new version numbering [was: distcheck fails with autotest...]
Date: Sat, 03 Nov 2007 07:25:29 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 11/2/2007 10:26 PM:
> Hmm.  Maybe it's time to rewrite m4_version_compare to treat `-' the same
> as `.' when it occurs in the original version strings.
>
> I'll throw together a patch when I have more time.

Done as follows:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHLHbI84KuGfSFAYARAqiiAJ4xftuMzuDm63DFE8zOdUYvP7XVngCfVkVJ
Ayf9CduzOgo6ezdLoCrAhxc=
=kyuV
-----END PGP SIGNATURE-----
>From dd3c3f2e27013fd1fb87bd1f2ad8989b17f39727 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Sat, 3 Nov 2007 07:20:47 -0600
Subject: [PATCH] Adjust version comparison to account for git snapshot numbers.

* lib/m4sugar/m4sugar.m4 (_m4_version_unletter): Also treat - as a
component separator.
* doc/autoconf.texi (Number processing Macros)
<m4_version_compare>: Document this change.
* tests/m4sugar.at (m4@&address@hidden): Test it.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    9 +++++++++
 doc/autoconf.texi      |   21 +++++++++++++++++----
 lib/m4sugar/m4sugar.m4 |   16 +++++++++-------
 tests/m4sugar.at       |    6 +++++-
 4 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e48da1f..8124d3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-11-03  Eric Blake  <address@hidden>
+
+       Adjust version comparison to account for git snapshot numbers.
+       * lib/m4sugar/m4sugar.m4 (_m4_version_unletter): Also treat - as a
+       component separator.
+       * doc/autoconf.texi (Number processing Macros)
+       <m4_version_compare>: Document this change.
+       * tests/m4sugar.at (m4@&address@hidden): Test it.
+
 2007-10-30  Bruno Haible  <address@hidden>
 
        * lib/autoconf/types.m4 (_AC_TYPE_LONG_LONG_SNIPPET): New macro,
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index f05b2ec..73077a0 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -11182,10 +11182,19 @@ usability limitations that were not lifted until 
Autoconf 2.62.  Compare
 the version strings @var{version-1} and @var{version-2}, and expand to
 @samp{-1} if @var{version-1} is smaller, @samp{0} if they are the same,
 or @samp{1} @var{version-2} is smaller.  Version strings must be a list
-of elements separated by @samp{.}, where each element is a number along
-with optional case-insensitive letters designating beta releases.  The
-comparison stops at the leftmost element that contains a difference,
-although a 0 element compares equal to a missing element.
+of elements separated by @samp{.}, @samp{,} or @samp{-}, where each
+element is a number along with optional case-insensitive letters
+designating beta releases.  The comparison stops at the leftmost element
+that contains a difference, although a 0 element compares equal to a
+missing element.
+
+It is permissible to include commit identifiers in @var{version}, such
+as an abbreviated SHA1 of the commit, provided there is still a
+monotonically increasing prefix to allow for accurate version-based
+comparisons.  For example, this paragraph was written when the
+development snapshot of autoconf claimed to be at version
address@hidden, or 248 commits after the 2.61a release, with an
+abbreviated commit identification of @samp{dc51}.
 
 @example
 m4_version_compare([1.1], [2.0])
@@ -11202,6 +11211,10 @@ m4_version_compare([1.1pre], [1.1PRE])
 @result{}0
 m4_version_compare([1.1a], [1,10])
 @result{}-1
+m4_version_compare([2.61a], [2.61a-248-dc51])
address@hidden
+m4_version_compare([2.61b], [2.61a-248-dc51])
address@hidden
 @end example
 @end defmac
 
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index e4bf9b2..e048dc2 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2129,18 +2129,20 @@ m4_define([m4_sign],
 #   [2.61aa.b] -> [2.61+1.-1.[0r36:aa],+1.-1.[0r36:b]] -> 2.62.-1.370.1.-1.11
 #
 # This macro expects reasonable version numbers, but can handle double
-# letters and does not expand one-letter macros.  Inline constant expansions,
-# to avoid m4_defn overhead.  _m4_version_unletter is the real workhorse
-# used by m4_version_compare, but since [0r36:a] is less readable than 10,
-# we provide a wrapper for human use.
+# letters and does not expand any macros.  Original version strings can
+# use both `.' and `-' separators.
+#
+# Inline constant expansions, to avoid m4_defn overhead.
+# _m4_version_unletter is the real workhorse used by m4_version_compare,
+# but since [0r36:a] is less readable than 10, we provide a wrapper for
+# human use.
 m4_define([m4_version_unletter],
 [m4_map_sep([m4_eval], [.],
            m4_dquote(m4_dquote_elt(m4_unquote(_$0([$1])))))])
 m4_define([_m4_version_unletter],
-[m4_translit(m4_bpatsubst([[[$1]]], ]dnl
+[m4_bpatsubst(m4_translit([[[$1]]], [.-], [,,]),]dnl
 m4_dquote(m4_dquote(m4_defn([m4_cr_Letters])))[[+],
-                         [+1.-1.[0r36:\&]]),
-            [.], [,])])
+             [+1,-1,[0r36:\&]])])
 
 
 # m4_version_compare(VERSION-1, VERSION-2)
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 9b1dc0e..163dea1 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -368,10 +368,12 @@ m4_version_compare([1.0], [1])
 m4_version_compare([1.0a], [1.0a])
 m4_version_compare([1.1a], [1.1a.1])
 m4_version_compare([1.10], [1.1a])
-m4_version_compare([1.1a], [1.1A])
+m4_version_compare([1-1a], [1,1A])
 m4_define([a], [oops])dnl
 m4_version_compare([1.1a], [1.1A])
 m4_version_compare([1z], [1aa])
+m4_version_compare([2.61a], [2.61a-248-dc51])
+m4_version_compare([2.61b], [2.61a-248-dc51])
 ]],
 [[-1
 1
@@ -385,6 +387,8 @@ m4_version_compare([1z], [1aa])
 0
 0
 -1
+-1
+1
 ]])
 
 AT_CLEANUP
-- 
1.5.3.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]