From: Alexandre Duret-Lutz Date: Tue, 14 May 2002 14:12:16 +0000 (+0000) Subject: Fix for PR automake/322: X-Git-Tag: Release-1-6b~103 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=29cd2ec0685f2f1ecfe5dd355194bb3f0e3133b0;p=automake.git 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. --- diff --git a/ChangeLog b/ChangeLog index ddf3aee6..15ac16d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-05-14 Alexandre Duret-Lutz + + 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 Alexandre Duret-Lutz diff --git a/THANKS b/THANKS index 7fc11afa..58013831 100644 --- 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 diff --git a/automake.in b/automake.in index 5191d748..bf252a15 100755 --- a/automake.in +++ b/automake.in @@ -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 .= $_; diff --git a/tests/Makefile.am b/tests/Makefile.am index 4798be8a..837a13fd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -60,6 +60,7 @@ comment2.test \ comment3.test \ comment4.test \ comment5.test \ +comment6.test \ compile_f_c_cxx.test \ cond.test \ cond2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 1fbe417e..12618e1b 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 index 00000000..38213940 --- /dev/null +++ b/tests/comment6.test @@ -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