Fix for PR automake/280:
authorAlexandre Duret-Lutz <adl@gnu.org>
Wed, 2 Jan 2002 16:01:23 +0000 (16:01 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Wed, 2 Jan 2002 16:01:23 +0000 (16:01 +0000)
* 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.

ChangeLog
automake.in
tests/Makefile.am
tests/Makefile.in
tests/comment5.test [new file with mode: 0755]

index abbcce8..cd9681a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,13 @@
-2001-12-29  Alexandre Duret-Lutz  <duret_g@epita.fr>
+2002-01-02  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       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  <duret_g@epita.fr>
 
        * tests/comment4.test: New file.
        * tests/Makefile.am (TESTS): Add command4.test.
index b2e0c3e..9dfed8e 100755 (executable)
@@ -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)
        {
index b57a1ef..bcbed9f 100644 (file)
@@ -55,6 +55,7 @@ comment.test \
 comment2.test \
 comment3.test \
 comment4.test \
+comment5.test \
 compile_f_c_cxx.test \
 cond.test \
 cond2.test \
index a906d27..53ca118 100644 (file)
@@ -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 (executable)
index 0000000..2eca8d1
--- /dev/null
@@ -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
+: