Hash :
8abf0894
Author :
Date :
2022-02-20T13:28:48
automake: support embedded \# in variable appends Fixes automake bug https://bugs.gnu.org/7610. Use of \# is not portable. POSIX does not provide any way of retaining the # marker in variables. There is wide spread support for \# though in GNU & BSD Make implementations. Today, with plain variable assignments, Automake leaves the line alone: foo = blah\#blah This will leave it to the implementation to decide what to do. But if you try to append to it, Automake follows POSIX and strips it: foo = blah\#blah foo += what -> foo = blah\ what Instead, let's issue a portability warning whenever \# is used, even if it isn't being appended, and do not strip the \# when appending. Now: foo = blah\#blah foo += what -> warning: escaping \# comment markers is not portable -> foo = blah\#blah what * NEWS: Mention change in \# handling. * lib/Automake/VarDef.pm: Do not strip # if escaped. * lib/Automake/Variable.pm: Warn if \# is used. * t/comment12.sh: New test. * t/comments-escaped-in-var.sh: New test. * t/list-of-tests.mk: Add comment12.sh & comments-escaped-in-var.sh.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#! /bin/sh
# Copyright (C) 2022 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Make sure Automake preserves escaped comments in the output.
. test-init.sh
cat >> configure.ac <<'END'
AC_OUTPUT
END
cat > Makefile.am << 'END'
# This value should be preserved.
var = -DVAL='"\#xxx\#"' # this should be stripped
var += -DX=1 # this should be kept
END
$ACLOCAL
# This should fail due to -Werror.
$AUTOMAKE && exit 1
# This should pass though.
$AUTOMAKE -Wno-portability
# For debugging.
grep ^var Makefile.in
# The full flag should be retained.
grep '^var.*\\#xxx\\#.*DX=1' Makefile.in
# Only the 2nd comment should be retained.
grep '^var.*stripped' Makefile.in && exit 1 || :
grep '^var.*should be kept' Makefile.in