]> git.draconx.ca Git - dxcommon.git/commitdiff
at-compat.at: Add patch to avoid DJGPP date issue.
authorNick Bowler <nbowler@draconx.ca>
Fri, 22 Dec 2023 05:28:08 +0000 (00:28 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 22 Dec 2023 05:31:16 +0000 (00:31 -0500)
DJGPP's "date +%s" does not actually work like GNU, although it probably
was supposed to.  It can return a string which begins with zero.  The
testsuite only checks that the output is all digits, so accepts this as
being a working GNU-like date output.

This is then used in an arithmetic expansion, and the shell interprets
this string as octal digits, crapping out if any of those digits are 8
or 9.  If this happens (perhaps depending on the phase of the moon)
then the testsuite crashes before printing the final summary.

snippet/at-compat.at

index 5e111b4269250e933c651b3777f4269bd4213985..01cfc886440b2e4a3d9c8f95ace19ebecfb2fe8c 100644 (file)
@@ -1,20 +1,25 @@
 # Copyright © 2023 Nick Bowler
 #
-# Compatibility helper for Autotest test suites.  This should be included
-# before expanding AT_INIT
+# Autotest monkey patches to fix some issues.  This should be included before
+# expanding AT_INIT.
 #
 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
-# Redefine AT_INIT to work around nonportable constructs in current
-# (as of 2023) Autoconf releases:
+# In a shell function, redirections on : are not correctly handled
+# by Solaris /bin/sh.  See the following Autoconf patch for details:
 #
-#   - In a shell function, redirections on : are not correctly handled
-#     by Solaris /bin/sh.  See the following Autoconf patch for details:
-#
-#       https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html
-
+#   https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html
 m4_define([AT_INIT],
   m4_bpatsubst(m4_dquote(m4_defn([AT_INIT])),
     [^\( *\)\(: >"\$at_stdout".*$\)], [\1eval '\2']))
+
+# The computation of the elapsed time can crash the testsuite on DJGPP because
+# in this environment date +%s can return a string that starts with a 0, which
+# bash interprets as octal digits in arithmetic expansions.  With a working
+# GNU-like date +%s the output should never start with a 0 so just reject
+# anything that does.
+m4_define([AT_INIT],
+  m4_bpatsubst(m4_dquote(m4_defn([AT_INIT])),
+    [\[0-9]\*,\[0-9]\*], [[1-9][0-9]*,[1-9][0-9]*]))