2005-08-26 Stepan Kasal * lib/m4sugar/m4sh.m4 (_AS_VERSION_COMPARE_PREPARE): Fix the awk script so that it works with /usr/xpg4/bin/awk on Solaris 8 (and newer?). Index: lib/m4sugar/m4sh.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v retrieving revision 1.149 diff -u -r1.149 m4sh.m4 --- lib/m4sugar/m4sh.m4 25 Aug 2005 21:29:54 -0000 1.149 +++ lib/m4sugar/m4sh.m4 26 Aug 2005 15:32:03 -0000 @@ -1026,9 +1026,12 @@ # --------------------------- # Output variables for comparing version numbers. m4_defun([_AS_VERSION_COMPARE_PREPARE], -[[as_awk_strverscmp=' +[[ # Use only awk features that work with 7th edition Unix awk (1978). # My, what an old awk you have, Mr. Solaris! + # Moreover, avoid comparisons with empty strings, because of the bug + # in Solaris' /usr/xpg4/bin/awk. (See the manual for details.) + as_awk_strverscmp=' END { while (length(v1) || length(v2)) { # Set d1 to be the next thing to compare from v1, and likewise for d2. @@ -1074,8 +1077,14 @@ } } 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 + + # Treat empty string here, to avoiding problems with + # /usr/xpg4/bin/awk on Solaris. + if (length(v1) == 0) exit 1 + if (length(v2) == 0) exit 2 + + 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