Hello Paul,
regarding the test failures reported by Ralf Wildenhues in
http://lists.gnu.org/archive/html/autoconf-patches/2005-08/msg00055.html
As Ralf has already told you, we have a solution for them.
(Yes, we have also analyzed the problem with test 66, and I'll send a mail
about it soon.)
I apologize that I haven't published our results earlier.
On Thu, Aug 25, 2005 at 02:31:30PM -0700, Paul Eggert wrote:
> Ralf Wildenhues writes:
> > + if (v1"" == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 =
> > substr(v1,2) }
> > + if (v2"" == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 =
> > substr(v2,2) }
>
> That looks fairly safe, but even safer would be to use the length function,
> since earlier bits of the code already do that. I installed this:
[...]
> + 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
But your fix also induces the failure reported by Ralf:
| 21. m4sh.at:252: testing ...
| ../../autoconf-2.59c/tests/m4sh.at:285: autom4te --language=m4sh script.as -o
script
| ../../autoconf-2.59c/tests/m4sh.at:286: ./script
| 0a1
| > script: error: version = 000; should be < 000
| ../../autoconf-2.59c/tests/m4sh.at:286: exit code was 1, expected 0
| 21. m4sh.at:252: 21. AS_VERSION_COMPARE (m4sh.at:252): FAILED (m4sh.at:286)
The problem is that /usr/xpg4/bin/awk on Solaris 8 (and probably also the above
versions) thinks that empty string might be a numerical string.
Moreover, substr propagates the "numerical string" flag.
So we have:
/usr/xpg4/bin/awk 'END{d1=v1;d2=substr(v2,1,1); if(v1==v2) print "error"}' \
v1= v2=000 /dev/null
This is why the script compares versions "" and "000" as being equal, hence
the error quoted above.
I don't have access to any Solaris. If you could verify that the above bug,
and hence the failure of test 21, is still present on Solaris 10, it would
be nice.
I plan to document these bugs, but they cannot be described by one sentence,
so it'll take some time until I fond time to do it.
(I hesitated to submit the patch without the corresponding doc. Sorry again.)
Attached please find a patch which fixes the problem. Ralf verified it
works with /usr/xpg4/bin/awk and /bin/awk on Solaris 8 and 9.
(The patch applies to current CVS.)
OK to commit?
Stepan
2005-08-26 Stepan Kasal <[EMAIL PROTECTED]>
* 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