+2007-11-03 Eric Blake <ebb9@byu.net>
+
+ 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@&t@_version_compare): Test it.
+
2007-10-30 Bruno Haible <bruno@clisp.org>
* lib/autoconf/types.m4 (_AC_TYPE_LONG_LONG_SNIPPET): New macro,
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
+@samp{2.61a-248-dc51}, or 248 commits after the 2.61a release, with an
+abbreviated commit identification of @samp{dc51}.
@example
m4_version_compare([1.1], [2.0])
@result{}0
m4_version_compare([1.1a], [1,10])
@result{}-1
+m4_version_compare([2.61a], [2.61a-248-dc51])
+@result{}-1
+m4_version_compare([2.61b], [2.61a-248-dc51])
+@result{}1
@end example
@end defmac
# [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)
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
0
0
-1
+-1
+1
]])
AT_CLEANUP