]> git.draconx.ca Git - dxcommon.git/blob - snippet/at-compat.at
6eb6d97042a6dcd5f4d5bbbeda055c206fc4550a
[dxcommon.git] / snippet / at-compat.at
1 # Copyright © 2023 Nick Bowler
2 #
3 # Autotest monkey patches to fix some issues.  This should be included before
4 # expanding AT_INIT.
5 #
6 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7 # This is free software: you are free to do what the fuck you want to.
8 # There is NO WARRANTY, to the extent permitted by law.
9
10 # In a shell function, redirections on : are not correctly handled by some
11 # shells, including Solaris 10 /bin/sh.  Work around the problem using 'eval'.
12 # See the following Autoconf patch description for further details:
13 #
14 #   https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html
15 m4_define([AT_INIT],
16   m4_bpatsubst(m4_dquote(m4_defn([AT_INIT])),
17     [^\( *\)\(: >"\$at_stdout".*$\)], [\1eval '\2']))
18
19 # Parsing of command-line options with arguments is busted in the two-argument
20 # form if the option name contains a hyphen.  Apply a fix for this bug.  See
21 # the following Autoconf patch description for further details:
22 #
23 #   https://lists.gnu.org/archive/html/autoconf-patches/2020-02/msg00000.html
24 m4_define([_AT_ARG_OPTION],
25   m4_bpatsubst(m4_dquote(m4_defn([_AT_ARG_OPTION])),
26     [at_prev=--AT_first_option_tr], [at_prev=--AT_first_option]))
27
28 # The computation of the elapsed time can crash the testsuite on DJGPP because
29 # in this environment date +%s can return a string that starts with a 0, which
30 # bash interprets as octal digits in arithmetic expansions.  With a working
31 # GNU-like date +%s the output should never start with a 0 so just reject
32 # anything that does.
33 m4_define([AT_INIT],
34   m4_bpatsubst(m4_dquote(m4_defn([AT_INIT])),
35     [\[0-9]\*,\[0-9]\*], [[1-9][0-9]*,[1-9][0-9]*]))