-m4_define([AT_INIT],
- m4_bpatsubst(m4_dquote(m4_defn([AT_INIT])),
- [\[0-9]\*,\[0-9]\*], [[1-9][0-9]*,[1-9][0-9]*]))
+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/\r$//' "$[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])])