From 64aa6bf18d294c68fa4661d7c6d7c4bf7cefac39 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 14 May 2002 14:12:21 +0000 Subject: 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. --- automake.in | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'automake.in') diff --git a/automake.in b/automake.in index 5191d7483..bf252a151 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 .= $_; -- cgit v1.2.1