# Copyright © 2023-2024 Nick Bowler # # 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. m4_define([DX_PATCH_MACRO], [m4_ifdef([$1], [m4_define([$1], m4_bpatsubst(m4_dquote(m4_defn([$1])), [$2], [$3]))])]) # In a shell function, redirections on : are not correctly handled by some # shells, including Solaris 10 /bin/sh. Work around the problem using 'eval'. # See the following Autoconf patch description for further details: # # https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html DX_PATCH_MACRO([AT_INIT], [^\( *\)\(: >"\$at_stdout".*$\)], [\1eval '\2']) # Parsing of command-line options with arguments is busted in the two-argument # form if the option name contains a hyphen. Apply a fix for this bug. See # the following Autoconf patch description for further details: # # https://lists.gnu.org/archive/html/autoconf-patches/2020-02/msg00000.html DX_PATCH_MACRO([_AT_ARG_OPTION], [at_prev=--AT_first_option_tr], [at_prev=--AT_first_option]) # 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. DX_PATCH_MACRO([AT_INIT], [\[0-9]\*,\[0-9]\*], [[1-9][0-9]*,[1-9][0-9]*]) # When testing DOS/Windows applications we cannot assume that the line endings # actually output by the programs under test will match the output of the shell. # # For example, the MSYS bash shell and most utilities generate UNIX-style line # endings while programs output DOS-style. A similar situation occurs when # running the test suite on a POSIX host while the tested applications are run # using something like wine. # # So on DOS-like hosts, if a trailing CR is seen by 'sed' from the test output, # remove it. The "left" file, which is the expected output, is left unchanged. # # For this to work, the package must arrange for host_os to be defined in the # test suite (e.g., via atlocal). DX_PATCH_MACRO([AT_INIT], [at_diff=.* fi], [\& at_fn_diff_dosnl () { sed 's/ $//' "$[2]" >"$[2].nl" && $at_diff_ "$[1]" "$[2].nl" && rm -f "$[2].nl" } AS_CASE([$host_os], [mingw*|msdos*], [at_diff_=$at_diff; at_diff=at_fn_diff_dosnl])])