From c5635fa68f25ea688578daed8ac503b718761206 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sun, 19 Apr 2009 02:19:20 +0200 Subject: [PATCH] Correctly treat all assignments with bogus trailing comments. Before this patch, automake would silently fail to diagnose and to copy into the output those variable assignments which are preceded by a comment, and end in backslash newline comment. * automake.in (read_am_file): When determining whether an escaped newline followed by a comment is an error, correctly use the parser state, not the contents of a saved comment, which could still be carried over from a comment before an assignment. * NEWS: Update. * tests/commen11.test: New test. * tests/Makefile.am: Update. Report by Karl Berry. Signed-off-by: Ralf Wildenhues --- ChangeLog | 15 +++++++++++++++ NEWS | 5 +++++ automake.in | 2 +- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/commen11.test | 42 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 tests/commen11.test diff --git a/ChangeLog b/ChangeLog index 15adab4a2..8be052c1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-04-19 Ralf Wildenhues + + Correctly treat all assignments with bogus trailing comments. + Before this patch, automake would silently fail to diagnose and + to copy into the output those variable assignments which are + preceded by a comment, and end in backslash newline comment. + * automake.in (read_am_file): When determining whether an + escaped newline followed by a comment is an error, correctly use + the parser state, not the contents of a saved comment, which + could still be carried over from a comment before an assignment. + * NEWS: Update. + * tests/commen11.test: New test. + * tests/Makefile.am: Update. + Report by Karl Berry. + 2009-04-14 Karl Berry manual: improve markup: itemize list in `Extending'. diff --git a/NEWS b/NEWS index 2c69e460a..e806cf638 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,11 @@ Bugs fixed in 1.10c: - Renamed objects also work with the `subdir-objects' option and source file languages which Automake does not know itself. + - `automake' now correctly complains about variable assignments which are + preceded by a comment, extend over multiple lines with backslash-escaped + newlines, and end in a comment sign. Previous versions would silently + and wrongly ignore such assignments completely. + * Bugs introduced by 1.10: - The `parallel-tests' driver also works on systems with a nonempty diff --git a/automake.in b/automake.in index d4949075c..fe2ff3d78 100755 --- a/automake.in +++ b/automake.in @@ -6704,7 +6704,7 @@ sub read_am_file ($$) elsif (/$COMMENT_PATTERN/o) { error $where, "comment following trailing backslash" - if $saw_bk && $comment eq ''; + if $saw_bk && $prev_state != IN_COMMENT; # Stick comments before the incoming macro or rule. $comment .= $spacing . $_; diff --git a/tests/Makefile.am b/tests/Makefile.am index c36237e00..093dde532 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -137,6 +137,7 @@ comment7.test \ comment8.test \ comment9.test \ commen10.test \ +commen11.test \ compile.test \ compile2.test \ compile_f90_c_cxx.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index b339664b7..54422bf1d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -369,6 +369,7 @@ comment7.test \ comment8.test \ comment9.test \ commen10.test \ +commen11.test \ compile.test \ compile2.test \ compile_f90_c_cxx.test \ diff --git a/tests/commen11.test b/tests/commen11.test new file mode 100755 index 000000000..7596723ba --- /dev/null +++ b/tests/commen11.test @@ -0,0 +1,42 @@ +#! /bin/sh +# Copyright (C) 2005, 2009 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 3, 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 . + +# Make sure backslash-newline-hash combinations are diagnosed as +# comments following a trailing backslash, even when the combination +# follows a variable assignment that is preceded by a comment. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +# initial comment +variable = value-before-comment \ +# + +# comment +SUBDIRS = foo \ +# bar + +END + +mkdir foo + +$ACLOCAL +AUTOMAKE_fails +grep 3.*backslash stderr +grep 7.*backslash stderr +: -- 2.47.2