From: Alexandre Duret-Lutz Date: Wed, 2 Jan 2002 16:01:23 +0000 (+0000) Subject: Fix for PR automake/280: X-Git-Tag: Release-1-5d~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb47c698fcf76e6b4f606d34f44dc878b5e0fa99;p=thirdparty%2Fautomake.git Fix for PR automake/280: * automake.in (read_am_file): Warn about trailing backslashes in comments. * tests/comment5.test: New file. * tests/Makefile.am (TESTS): Add comment5.test. Reported by Enrico Scholz. --- diff --git a/ChangeLog b/ChangeLog index abbcce833..cd9681ad7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ -2001-12-29 Alexandre Duret-Lutz +2002-01-02 Alexandre Duret-Lutz + + Fix for PR automake/280: + * automake.in (read_am_file): Warn about trailing backslashes + in comments. + * tests/comment5.test: New file. + * tests/Makefile.am (TESTS): Add comment5.test. + Reported by Enrico Scholz. + +2002-01-02 Alexandre Duret-Lutz * tests/comment4.test: New file. * tests/Makefile.am (TESTS): Add command4.test. diff --git a/automake.in b/automake.in index b2e0c3e25..9dfed8e3b 100755 --- a/automake.in +++ b/automake.in @@ -6790,6 +6790,7 @@ sub read_am_file ($) my $spacing = ''; my $comment = ''; my $blank = 0; + my $saw_bk = 0; while ($_ = $am_file->getline) { @@ -6799,6 +6800,9 @@ sub read_am_file ($) } elsif (/$WHITE_PATTERN/o) { + file_error ("$amfile:$.", + "blank line following trailing backslash") + if $saw_bk; # Stick a single white line before the incoming macro or rule. $spacing = "\n"; $blank = 1; @@ -6822,6 +6826,7 @@ sub read_am_file ($) { last; } + $saw_bk = /\\$/ && ! /$IGNORE_PATTERN/o; } # We save the conditional stack on entry, and then check to make @@ -6830,7 +6835,6 @@ sub read_am_file ($) my @saved_cond_stack = @cond_stack; my $cond = conditional_string (@cond_stack); - my $saw_bk = 0; my $was_rule = 0; my $last_var_name = ''; my $last_var_type = ''; @@ -6849,7 +6853,7 @@ sub read_am_file ($) $_ =~ s/\@MAINT\@//g unless $seen_maint_mode; - my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o; + my $new_saw_bk = /\\$/ && ! /$IGNORE_PATTERN/o; if (/$IGNORE_PATTERN/o) { @@ -6868,7 +6872,7 @@ sub read_am_file ($) $comment .= $spacing . $_; $spacing = ''; file_error ($here, "comment following trailing backslash") - if $saw_bk; + if $saw_bk && $comment ne ''; } elsif ($saw_bk) { diff --git a/tests/Makefile.am b/tests/Makefile.am index b57a1ef4b..bcbed9f20 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -55,6 +55,7 @@ comment.test \ comment2.test \ comment3.test \ comment4.test \ +comment5.test \ compile_f_c_cxx.test \ cond.test \ cond2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index a906d27a7..53ca11814 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -127,6 +127,7 @@ comment.test \ comment2.test \ comment3.test \ comment4.test \ +comment5.test \ compile_f_c_cxx.test \ cond.test \ cond2.test \ diff --git a/tests/comment5.test b/tests/comment5.test new file mode 100755 index 000000000..2eca8d1eb --- /dev/null +++ b/tests/comment5.test @@ -0,0 +1,40 @@ +#! /bin/sh +# Test for PR/280. +# (Automake should complain about trailing backslashes in comments.) + +. $srcdir/defs || exit 1 + +set -e + +cat >> configure.in <<'EOF' +AC_OUTPUT +EOF + +cat > Makefile.am << 'EOF' +all-local: + @echo ${var} + +# a comment with backslash \ + + +var = foo +EOF + +$ACLOCAL +$AUTOMAKE && exit 1 + +## Here is a second test because head comments are +## handled differently in Automake 1.5. + +cat > Makefile.am << 'EOF' +# a comment with backslash \ + + +all-local: + @echo ${var} + +var = foo +EOF + +$AUTOMAKE && exit 1 +: