]> git.ipfire.org Git - thirdparty/autoconf.git/commit
config.status: handle CRLF line endings in AC_CONFIG_HEADERS input
authorZack Weinberg <zack@owlfolio.org>
Fri, 15 Dec 2023 15:59:38 +0000 (10:59 -0500)
committerZack Weinberg <zack@owlfolio.org>
Fri, 15 Dec 2023 15:59:38 +0000 (10:59 -0500)
commitbfd3894367e4d1c36c514e02c62173cde157f06b
treecd32a554672615828b83bce5d524eba07cd93299
parentdec7b457b6771588d79190f3f6bd007310fc7fe7
config.status: handle CRLF line endings in AC_CONFIG_HEADERS input

On systems that normally use Unix line endings, if config.h.in has
somehow been generated with DOS line endings, then awk will treat
each CR character as part of the line.  This breaks the regular
expressions used to edit config.h.in into config.h

To fix, manually strip trailing CRs from each “input record” before
any other processing.  For consistency I also made this change to the
code dealing with AC_CONFIG_FILES substitutions.  On systems that use
DOS line endings, both changes should be no-ops.

Reported by David Allsopp in <https://savannah.gnu.org/support/?110554>.
He offered a different patch, which also worked on my machine, but it
used a regular expression as the third argument to ‘split’, which
might not be portable across awk implementations (the gawk manual is
unclear).  Also, it could produce a config.h with _inconsistent_ line
endings.

* lib/autoconf/status.m4 (_AC_OUTPUT_HEADERS_PREPARE): In the awk
  script, strip a trailing CR from each record as the first action.
  (_AC_OUTPUT_FILES_PREPARE): Likewise.
* tests/torture.at (CRLF line endings in .in files): New test.

Co-authored-by: David Allsopp <david@davidallsopp.com>
lib/autoconf/status.m4
tests/torture.at