Fix for PR automake/322:
authorAlexandre Duret-Lutz <adl@gnu.org>
Tue, 14 May 2002 14:12:21 +0000 (14:12 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Tue, 14 May 2002 14:12:21 +0000 (14:12 +0000)
* automake.in (read_am_file): Rename $was_rule as $prev_state, and
set it with IN_RULE_DEF, IN_VAR_DEF, or IN_COMMENT as appropriate.
Handle comments continued by backslashes.
* tests/comment6.test: New file.
* tests/Makefile.am (TESTS): Add comment6.test.
Reported by Braden N. McDaniel.

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

index ddf3aee..15ac16d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-05-14  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       Fix for PR automake/322:
+       * automake.in (read_am_file): Rename $was_rule as $prev_state, and
+       set it with IN_RULE_DEF, IN_VAR_DEF, or IN_COMMENT as appropriate.
+       Handle comments continued by backslashes.
+       * tests/comment6.test: New file.
+       * tests/Makefile.am (TESTS): Add comment6.test.
+       Reported by Braden N. McDaniel.
+
 2002-05-08  Charles Wilson  <cwilson@ece.gatech.edu>
             Alexandre Duret-Lutz  <duret_g@epita.fr>
 
diff --git a/THANKS b/THANKS
index 7fc11af..5801383 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -24,6 +24,7 @@ Bill Currie           bcurrie@tssc.co.nz
 Bill Davidson          bill@kayhay.com
 Bill Fenner            fenner@parc.xerox.com
 Bob Proulx             rwp@hprwp.fc.hp.com
+Braden N. McDaniel     braden@endoframe.com
 Brendan O'Dea          bod@compusol.com.au
 Brian Ford             ford@vss.fsi.com
 Brian Jones            cbj@nortel.net
index 5191d74..bf252a1 100755 (executable)
@@ -6666,6 +6666,11 @@ sub read_am_file ($)
     my $blank = 0;
     my $saw_bk = 0;
 
+    use constant IN_VAR_DEF => 0;
+    use constant IN_RULE_DEF => 1;
+    use constant IN_COMMENT => 2;
+    my $prev_state = IN_RULE_DEF;
+
     while ($_ = $am_file->getline)
     {
        if (/$IGNORE_PATTERN/o)
@@ -6695,6 +6700,7 @@ sub read_am_file ($)
            $blank = 1;
            $comment .= $spacing . $_;
            $spacing = '';
+           $prev_state = IN_COMMENT;
        }
        else
        {
@@ -6709,7 +6715,6 @@ sub read_am_file ($)
     my @saved_cond_stack = @cond_stack;
     my $cond = conditional_string (@cond_stack);
 
-    my $was_rule = 0;
     my $last_var_name = '';
     my $last_var_type = '';
     my $last_var_value = '';
@@ -6747,15 +6752,20 @@ sub read_am_file ($)
            $spacing = '';
            file_error ($here, "comment following trailing backslash")
                if $saw_bk && $comment eq '';
+           $prev_state = IN_COMMENT;
        }
        elsif ($saw_bk)
        {
-           if ($was_rule)
+           if ($prev_state == IN_RULE_DEF)
            {
                $output_trailer .= &make_condition (@cond_stack);
                $output_trailer .= $_;
            }
-           else
+           elsif ($prev_state == IN_COMMENT)
+           {
+               $comment .= $spacing . $_;
+           }
+           else # $prev_state == IN_VAR_DEF
            {
              $last_var_value .= ' '
                unless $last_var_value =~ /\s$/;
@@ -6790,7 +6800,7 @@ sub read_am_file ($)
        elsif (/$RULE_PATTERN/o)
        {
            # Found a rule.
-           $was_rule = 1;
+           $prev_state = IN_RULE_DEF;
 
            rule_define ($1, 0, $cond, $here);
 
@@ -6802,7 +6812,7 @@ sub read_am_file ($)
        elsif (/$ASSIGNMENT_PATTERN/o)
        {
            # Found a macro definition.
-           $was_rule = 0;
+           $prev_state = IN_VAR_DEF;
            $last_var_name = $1;
            $last_var_type = $2;
            $last_var_value = $3;
@@ -6850,7 +6860,7 @@ sub read_am_file ($)
         {
            # This isn't an error; it is probably a continued rule.
            # In fact, this is what we assume.
-           $was_rule = 1;
+           $prev_state = IN_RULE_DEF;
            $output_trailer .= $comment . $spacing;
            $output_trailer .= &make_condition  (@cond_stack);
            $output_trailer .= $_;
index 4798be8..837a13f 100644 (file)
@@ -60,6 +60,7 @@ comment2.test \
 comment3.test \
 comment4.test \
 comment5.test \
+comment6.test \
 compile_f_c_cxx.test \
 cond.test \
 cond2.test \
index 1fbe417..12618e1 100644 (file)
@@ -144,6 +144,7 @@ comment2.test \
 comment3.test \
 comment4.test \
 comment5.test \
+comment6.test \
 compile_f_c_cxx.test \
 cond.test \
 cond2.test \
diff --git a/tests/comment6.test b/tests/comment6.test
new file mode 100755 (executable)
index 0000000..3821394
--- /dev/null
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Test for PR/322.
+
+. $srcdir/defs || exit 1
+
+set -e
+
+cat >> configure.in <<'EOF'
+AC_OUTPUT
+EOF
+
+## There are two tests: one with backslashed comments at the top
+## of the file, and one with a rule first.  This is because
+## Comments at the top of the file are handled specially
+## since Automake 1.5.
+
+cat > Makefile.am << 'EOF'
+# SOME_FILES = \
+         file1 \
+         file2 \
+         file3
+
+all-local:
+       @echo Good
+
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+cat > Makefile.am << 'EOF'
+all-local:
+       @echo Good
+
+# SOME_FILES = \
+         file1 \
+         file2 \
+         file3
+EOF
+
+$AUTOMAKE
+./configure
+$MAKE